|
@@ -0,0 +1,51 @@
|
|
|
|
+package com.chelvc.cloud.maintain.controller;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.param.GoodsPagingParam;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.service.GoodsService;
|
|
|
|
+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.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
+import javax.validation.constraints.Min;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 商家接口
|
|
|
|
+ *
|
|
|
|
+ * @author liude
|
|
|
|
+ * @date 2023/7/20
|
|
|
|
+ */
|
|
|
|
+@Validated
|
|
|
|
+@RestController
|
|
|
|
+@UnifiedResponseBody
|
|
|
|
+public class GoodsController {
|
|
|
|
+ @DubboReference
|
|
|
|
+ private GoodsService goodsService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取商品信息
|
|
|
|
+ *
|
|
|
|
+ * @param id 商品主键
|
|
|
|
+ * @return 商品信息
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/goods/{id}")
|
|
|
|
+ public GoodsDTO getGoods(@PathVariable("id") @Min(value = 1, message = "商品主键不能小于1") Long id) {
|
|
|
|
+ GoodsDTO goods = this.goodsService.getGoods(id);
|
|
|
|
+ ErrorUtils.requireResource(goods, "商品不存在");
|
|
|
|
+ return goods;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 查询商品分页
|
|
|
|
+ *
|
|
|
|
+ * @param param 查询参数
|
|
|
|
+ * @return 商品分页信息
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/goods/paging")
|
|
|
|
+ public Pagination<GoodsDTO> getGoodsPaging(@Valid GoodsPagingParam param) {
|
|
|
|
+ return this.goodsService.getGoodsPaging(param);
|
|
|
|
+ }
|
|
|
|
+}
|