|
@@ -0,0 +1,111 @@
|
|
|
+package com.chelvc.cloud.admin.controller;
|
|
|
+
|
|
|
+import com.chelvc.cloud.trade.api.dto.GoodsCategoryDTO;
|
|
|
+import com.chelvc.cloud.trade.api.param.GoodsCategoryModifyParam;
|
|
|
+import com.chelvc.cloud.trade.api.param.GoodsCategoryPagingParam;
|
|
|
+import com.chelvc.cloud.trade.api.param.GoodsCategoryQueryParam;
|
|
|
+import com.chelvc.cloud.trade.api.service.GoodsCategoryService;
|
|
|
+import com.chelvc.framework.base.annotation.UnifiedResponseBody;
|
|
|
+import com.chelvc.framework.base.model.Pagination;
|
|
|
+import com.chelvc.framework.base.util.ErrorUtils;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 商品分类接口
|
|
|
+ *
|
|
|
+ * @author 七仔
|
|
|
+ * @Date 2023/4/4
|
|
|
+ **/
|
|
|
+@Validated
|
|
|
+@RestController
|
|
|
+@UnifiedResponseBody
|
|
|
+public class GoodsCategoryController {
|
|
|
+ @DubboReference
|
|
|
+ private GoodsCategoryService goodsCategoryService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增商品分类
|
|
|
+ *
|
|
|
+ * @param param 新增参数
|
|
|
+ * @return 商品分类主键
|
|
|
+ */
|
|
|
+ @PostMapping("/goodsCategory")
|
|
|
+ public Long addGoodsCategory(@RequestBody @Valid GoodsCategoryModifyParam param) {
|
|
|
+ return this.goodsCategoryService.addGoodsCategory(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改商品分类
|
|
|
+ *
|
|
|
+ * @param id 商品分类主键
|
|
|
+ * @param param 修改参数
|
|
|
+ */
|
|
|
+ @PutMapping("/goodsCategory/{id}")
|
|
|
+ public void updateGoodsCategory(@PathVariable("id") @Min(value = 1, message = "商品分类主键不能小于1") Long id,
|
|
|
+ @RequestBody @Valid GoodsCategoryModifyParam param) {
|
|
|
+ this.goodsCategoryService.updateGoodsCategory(id, param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取商品分类信息
|
|
|
+ *
|
|
|
+ * @param id 商品分类主键
|
|
|
+ * @return 商品分类信息
|
|
|
+ */
|
|
|
+ @GetMapping("/goodsCategory/{id}")
|
|
|
+ public GoodsCategoryDTO getGoodsCategory(@PathVariable("id") @Min(value = 1, message = "商品分类主键不能小于1")
|
|
|
+ Long id) {
|
|
|
+ GoodsCategoryDTO goodsCategory = this.goodsCategoryService.getGoodsCategory(id);
|
|
|
+ ErrorUtils.requireResource(goodsCategory, "商品分类不存在");
|
|
|
+ return goodsCategory;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询商品分类分页
|
|
|
+ *
|
|
|
+ * @param param 查询参数
|
|
|
+ * @return 商品分类分页信息
|
|
|
+ */
|
|
|
+ @GetMapping("/goodsCategory/paging")
|
|
|
+ public Pagination<GoodsCategoryDTO> getGoodsCategoryPaging(@Valid GoodsCategoryPagingParam param) {
|
|
|
+ return this.goodsCategoryService.getGoodsCategoryPaging(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询商品分类树列表
|
|
|
+ *
|
|
|
+ * @param param 查询参数
|
|
|
+ * @return 商品分类树列表
|
|
|
+ */
|
|
|
+ @GetMapping("/goodsCategory/trees")
|
|
|
+ public List<GoodsCategoryDTO> listGoodsCategoryTrees(@Valid GoodsCategoryQueryParam param) {
|
|
|
+ return this.goodsCategoryService.listGoodsCategoryTrees(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除商品分类
|
|
|
+ *
|
|
|
+ * @param id 商品分类主键
|
|
|
+ */
|
|
|
+ @DeleteMapping("/goodsCategory/{id}")
|
|
|
+ public void deleteGoodsCategory(@PathVariable("id") @Min(value = 1, message = "商品分类主键不能小于1") Long id) {
|
|
|
+ this.goodsCategoryService.deleteGoodsCategory(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 启用/禁用商品分类
|
|
|
+ *
|
|
|
+ * @param id 商品分类主键
|
|
|
+ */
|
|
|
+ @PutMapping("/goodsCategory/{id}")
|
|
|
+ public void enableGoodsCategory(@PathVariable("id") @Min(value = 1, message = "商品分类主键不能小于1") Long id,
|
|
|
+ @RequestParam Boolean enableOperation) {
|
|
|
+ this.goodsCategoryService.enableGoodsCategory(id, enableOperation);
|
|
|
+ }
|
|
|
+}
|