feature: [种类] 种类管理
This commit is contained in:
parent
00a247cfae
commit
572801683e
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue