فهرست منبع

商家及商品查询

liude 1 سال پیش
والد
کامیت
78435adbe4

+ 51 - 0
src/main/java/com/chelvc/cloud/maintain/controller/GoodsController.java

@@ -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);
+    }
+}

+ 48 - 0
src/main/java/com/chelvc/cloud/maintain/controller/MerchantController.java

@@ -0,0 +1,48 @@
+package com.chelvc.cloud.maintain.controller;
+import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
+import com.chelvc.cloud.vehicle.api.param.MerchantPagingParam;
+import com.chelvc.cloud.vehicle.api.service.MerchantService;
+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;
+/**
+ * 商家接口
+ *
+ * @author liude
+ * @date 2023/7/20
+ */
+@Validated
+@RestController
+@UnifiedResponseBody
+public class MerchantController {
+    @DubboReference
+    private MerchantService merchantService;
+
+    /**
+     * 获取商家信息
+     *
+     * @param id 商家主键
+     * @return 商家信息
+     */
+    @GetMapping("/merchant/{id}")
+    public MerchantDTO getRole(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id) {
+        MerchantDTO merchant = this.merchantService.getMerchant(id);
+        ErrorUtils.requireResource(merchant, "商家不存在");
+        return merchant;
+    }
+    /**
+     * 查询商家分页
+     *
+     * @param param 查询参数
+     * @return 商家分页信息
+     */
+    @GetMapping("/merchant/paging")
+    public Pagination<MerchantDTO> getMerchantPaging(@Valid MerchantPagingParam param) {
+        return this.merchantService.getMerchantPaging(param);
+    }
+}