diff --git a/pom.xml b/pom.xml index f48bd55..5f4ace1 100644 --- a/pom.xml +++ b/pom.xml @@ -530,10 +530,6 @@ - - - - diff --git a/src/main/java/com/guwan/backend/controller/CategotyController.java b/src/main/java/com/guwan/backend/controller/CategotyController.java index fdd0f45..5d9541f 100644 --- a/src/main/java/com/guwan/backend/controller/CategotyController.java +++ b/src/main/java/com/guwan/backend/controller/CategotyController.java @@ -7,12 +7,11 @@ import com.guwan.backend.common.Result; import com.guwan.backend.common.SearchResult; import com.guwan.backend.pojo.entity.BSCategory; import com.guwan.backend.service.BSCategoryService; +import com.guwan.backend.util.UUIDUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.checkerframework.checker.units.qual.C; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -44,4 +43,40 @@ public class CategotyController { } } + @PostMapping("/addCategory") + public Result addCategory(@RequestBody BSCategory bsCategory) { + try { + bsCategory.setId(UUIDUtil.uuid()); + categoryService.save(bsCategory); + return Result.success(); + } catch (Exception e) { + log.error("Failed to add category", e); + return Result.error("Failed to add category"); + } + } + + @PostMapping("/editCategory") + public Result editCategory(@RequestBody BSCategory bsCategory) { + try { + + categoryService.updateById(bsCategory); + return Result.success(); + } catch (Exception e) { + log.error("Failed to edit category", e); + return Result.error("Failed to edit category"); + } + } + + @PostMapping("/deleteCategory") + public Result deleteCategory(@RequestParam String id) { + try { + + categoryService.removeById(id); + return Result.success(); + } catch (Exception e) { + log.error("Failed to remove category", e); + return Result.error("Failed to remove category"); + } + } + }