Selaa lähdekoodia

规格、规格值基础方法与模糊查询上传

Sakana 1 viikko sitten
vanhempi
commit
d987131977

+ 5 - 0
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/ShopSpecService.java

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import edu.travel.commodity.entity.ShopSpec;
 import edu.travel.remote.dto.SpecDto;
 import edu.travel.remote.vo.SpecVo;
+import edu.travel.rpc.RPCBaseResponse;
+
+import java.util.List;
 
 
 public interface ShopSpecService extends IService<ShopSpec> {
@@ -14,4 +17,6 @@ public interface ShopSpecService extends IService<ShopSpec> {
 
 
     void insertOrUpdate(SpecDto specDto);
+
+    RPCBaseResponse<List<SpecVo>> getSpecName(String specName);
 }

+ 5 - 0
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/ShopSpecValueService.java

@@ -2,8 +2,13 @@ package edu.travel.commodity.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import edu.travel.commodity.entity.ShopSpecValue;
+import edu.travel.remote.vo.ShopSpecValueVo;
+import edu.travel.rpc.RPCBaseResponse;
+
+import java.util.List;
 
 public interface ShopSpecValueService extends IService<ShopSpecValue> {
 
 
+    RPCBaseResponse<List<ShopSpecValueVo>> getSpecValue(String specValue);
 }

+ 19 - 1
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/impl/ShopSpecServiceImpl.java

@@ -11,10 +11,14 @@ import edu.travel.commodity.service.ShopSpecService;
 import edu.travel.commodity.utils.PageUtil;
 import edu.travel.remote.dto.SpecDto;
 import edu.travel.remote.vo.SpecVo;
+import edu.travel.rpc.RPCBaseResponse;
+import edu.travel.service.SysServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
-public class ShopSpecServiceImpl extends ServiceImpl<ShopSpecMapper, ShopSpec> implements ShopSpecService {
+public class ShopSpecServiceImpl extends SysServiceImpl<ShopSpecMapper, ShopSpec> implements ShopSpecService {
 
 
     @Override
@@ -43,4 +47,18 @@ public class ShopSpecServiceImpl extends ServiceImpl<ShopSpecMapper, ShopSpec> i
         spec.setSpecName(specDto.getSpecName());
         updateById(spec);
     }
+
+    /**
+     * 获取规格名称(模糊查询)
+     * @param specName
+     * @return
+     */
+    @Override
+    public RPCBaseResponse<List<SpecVo>> getSpecName(String specName) {
+        // 模糊查询规格
+        LambdaQueryWrapper<ShopSpec> query = Wrappers.<ShopSpec>lambdaQuery()
+                .like(ShopSpec::getSpecName, specName);
+        List<ShopSpec> specs = list(query);
+        return RPCBaseResponse.success(BeanUtil.copyToList(specs, SpecVo.class));
+    }
 }

+ 15 - 0
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/impl/ShopSpecValueServiceImpl.java

@@ -1,12 +1,27 @@
 package edu.travel.commodity.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import edu.travel.commodity.entity.ShopSpecValue;
 import edu.travel.commodity.mapper.ShopSpecValueMapper;
 import edu.travel.commodity.service.ShopSpecValueService;
+import edu.travel.remote.vo.ShopSpecValueVo;
+import edu.travel.rpc.RPCBaseResponse;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class ShopSpecValueServiceImpl extends ServiceImpl<ShopSpecValueMapper, ShopSpecValue> implements ShopSpecValueService {
 
+    @Override
+    public RPCBaseResponse<List<ShopSpecValueVo>> getSpecValue(String specValue) {
+        //模糊查询规格值
+        LambdaQueryWrapper<ShopSpecValue> query = Wrappers.<ShopSpecValue>lambdaQuery()
+                .like(ShopSpecValue::getSpecValue, specValue);
+        List<ShopSpecValue> specValues = list(query);
+        return RPCBaseResponse.success(BeanUtil.copyToList(specValues, ShopSpecValueVo.class));
+    }
 }

+ 4 - 13
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopProductSpecController.java

@@ -33,7 +33,6 @@ public class ShopProductSpecController extends BaseController<ShopProductSpec> i
     /**
      * 查询商品详情
      *
-     * @param param
      * @return {@link BaseResponse }<{@link List }<{@link ProductSpecVo }>>
      */
     @GetMapping("/getShopSpec")
@@ -43,8 +42,6 @@ public class ShopProductSpecController extends BaseController<ShopProductSpec> i
 
     /**
      * 查找商品规格中间表
-     * @param id
-     * @return
      */
     @Override
     @GetMapping("/getFormId")
@@ -57,12 +54,10 @@ public class ShopProductSpecController extends BaseController<ShopProductSpec> i
 
     /**
      * 更新商品规格中间表
-     * @param entity
-     * @return
      */
     @Override
-    @PostMapping("/updateById")
-    public RPCBaseResponse<ProductSpecVo> updateTargetFormId(ProductSpecDto entity) {
+    @PostMapping("/updateTargetFormId")
+    public RPCBaseResponse<ProductSpecVo> updateTargetFormId(@RequestBody ProductSpecDto entity) {
         ShopProductSpec shopProductSpec = new ShopProductSpec();
         BeanUtils.copyProperties(entity, shopProductSpec);
         RPCBaseResponse<ShopProductSpec> shopProductSpecRPCBaseResponse = super.updateTargetById(shopProductSpec);
@@ -73,12 +68,10 @@ public class ShopProductSpecController extends BaseController<ShopProductSpec> i
 
     /**
      * 新增商品规格中间表
-     * @param entity
-     * @return
      */
     @Override
     @PostMapping("/saveFormTarget")
-    public RPCBaseResponse<ProductSpecVo> saveFormTarget(ProductSpecDto entity) {
+    public RPCBaseResponse<ProductSpecVo> saveFormTarget(@RequestBody ProductSpecDto entity) {
         ShopProductSpec shopProductSpec = new ShopProductSpec();
         BeanUtils.copyProperties(entity, shopProductSpec);
         RPCBaseResponse<ShopProductSpec> shopProductSpecRPCBaseResponse = super.saveTarget(shopProductSpec);
@@ -89,11 +82,9 @@ public class ShopProductSpecController extends BaseController<ShopProductSpec> i
 
     /**
      * 删除商品规格中间表
-     * @param ids
-     * @return
      */
     @Override
-    @PostMapping("/deleteFormId")
+    @PostMapping("/deleteTargetFormId")
     public RPCBaseResponse<ProductSpecVo> deleteTargetFormId(@RequestBody List<String> ids) {
         RPCBaseResponse<ShopProductSpec> shopProductSpecRPCBaseResponse = super.deleteTargetById(ids);
         RPCBaseResponse<ProductSpecVo> productSpecVoRPCBaseResponse = new RPCBaseResponse<>();

+ 8 - 15
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopSpecController.java

@@ -40,9 +40,6 @@ public class ShopSpecController extends BaseController<ShopSpec> implements Shop
 
     /**
      * 分页查询规格
-     *
-     * @param currentPage
-     * @param pageSize
      * @return {@link RPCBaseResponse }<{@link Page }<{@link SpecVo }>>
      */
 
@@ -62,12 +59,16 @@ public class ShopSpecController extends BaseController<ShopSpec> implements Shop
         shopSpecService.insertOrUpdate(specDto);
         return success();
     }
-
+    /**
+     * 获取全部规格名信息(可模糊查询)
+     */
+    @GetMapping("/getSpecName")
+    public RPCBaseResponse<List<SpecVo>> getSpecName(@RequestParam(required = false) String specName) {
+        // 调用 Service 层的方法进行模糊查询
+        return shopSpecService.getSpecName(specName);
+    }
     /**
      * 通过id查找规格
-     *
-     * @param id
-     * @return
      */
     @Override
     @GetMapping("/getFormId")
@@ -100,9 +101,6 @@ public class ShopSpecController extends BaseController<ShopSpec> implements Shop
 
     /**
      * 更新规格
-     *
-     * @param entity
-     * @return
      */
     @Override
     @PostMapping("/updateTargetFormId")
@@ -118,8 +116,6 @@ public class ShopSpecController extends BaseController<ShopSpec> implements Shop
     /**
      * 新增规格
      *
-     * @param entity
-     * @return
      */
     @Override
     @PostMapping("/saveFormTarget")
@@ -135,8 +131,6 @@ public class ShopSpecController extends BaseController<ShopSpec> implements Shop
     /**
      * 删除规格
      *
-     * @param ids
-     * @return
      */
     @Override
     @PostMapping("/deleteTargetFormId")
@@ -150,7 +144,6 @@ public class ShopSpecController extends BaseController<ShopSpec> implements Shop
     /**
      * 获取所有规格
      *
-     * @return
      */
     @Override
     @GetMapping("/getAllForm")

+ 15 - 10
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopSpecValueController.java

@@ -9,10 +9,7 @@ import edu.travel.rpc.RPCBaseResponse;
 import edu.travel.web.BaseController;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-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.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -29,12 +26,16 @@ public class ShopSpecValueController extends BaseController<ShopSpecValue> imple
      */
     @Autowired
     private ShopSpecValueService shopSpecValueService;
-
+    /**
+     * 获取全部规格值信息(可模糊查询)
+     */
+    @GetMapping("/getSpecValue")
+    public RPCBaseResponse<List<ShopSpecValueVo>> getSpecValue(@RequestParam(required = false) String specValue) {
+        return shopSpecValueService.getSpecValue(specValue);
+    }
     /**
      * 通过id查找规格值
      *
-     * @param id
-     * @return
      */
     @Override
     @GetMapping("/getFormId")
@@ -51,7 +52,8 @@ public class ShopSpecValueController extends BaseController<ShopSpecValue> imple
      * @return
      */
     @Override
-    public RPCBaseResponse<ShopSpecValueVo> updateTargetFormId(ShopSpecValueDto entity) {
+    @PostMapping("/updateTargetFormId")
+    public RPCBaseResponse<ShopSpecValueVo> updateTargetFormId(@RequestBody ShopSpecValueDto entity) {
         ShopSpecValue shopSpecValue = new ShopSpecValue();
         BeanUtils.copyProperties(entity, shopSpecValue);
         RPCBaseResponse<ShopSpecValue> shopSpecValueRPCBaseResponse = super.updateTargetById(shopSpecValue);
@@ -66,7 +68,8 @@ public class ShopSpecValueController extends BaseController<ShopSpecValue> imple
      * @return
      */
     @Override
-    public RPCBaseResponse<ShopSpecValueVo> saveFormTarget(ShopSpecValueDto entity) {
+    @PostMapping("/saveFormTarget")
+    public RPCBaseResponse<ShopSpecValueVo> saveFormTarget(@RequestBody ShopSpecValueDto entity) {
         ShopSpecValue shopSpecValue = new ShopSpecValue();
         BeanUtils.copyProperties(entity, shopSpecValue);
         RPCBaseResponse<ShopSpecValue> shopSpecValueRPCBaseResponse = super.saveTarget(shopSpecValue);
@@ -81,7 +84,8 @@ public class ShopSpecValueController extends BaseController<ShopSpecValue> imple
      * @return
      */
     @Override
-    public RPCBaseResponse<ShopSpecValueVo> deleteTargetFormId(List<String> ids) {
+    @PostMapping("/deleteTargetFormId")
+    public RPCBaseResponse<ShopSpecValueVo> deleteTargetFormId(@RequestBody List<String> ids) {
         RPCBaseResponse<ShopSpecValue> shopSpecValueRPCBaseResponse = super.deleteTargetById(ids);
         RPCBaseResponse<ShopSpecValueVo> shopSpecValueVoRPCBaseResponse = new RPCBaseResponse<>();
         BeanUtils.copyProperties(shopSpecValueRPCBaseResponse, shopSpecValueVoRPCBaseResponse);
@@ -93,6 +97,7 @@ public class ShopSpecValueController extends BaseController<ShopSpecValue> imple
      * @return
      */
     @Override
+    @GetMapping("/getAllForm")
     public RPCBaseResponse<List<ShopSpecValueVo>> getAllForm() {
         RPCBaseResponse<List<ShopSpecValue>> shopSpecValueRPCBaseResponse = super.listAll();
         RPCBaseResponse<List<ShopSpecValueVo>> shopSpecValueVoRPCBaseResponse = new RPCBaseResponse<>();