소스 검색

feat: 添加查询平台商品、设置货道商品、设备商品接口

pangqijun 3 달 전
부모
커밋
e2e759f2d9

+ 37 - 0
src/main/java/org/springblade/modules/api/controller/ApiFacilityCargoWayController.java

@@ -0,0 +1,37 @@
+package org.springblade.modules.api.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.core.tool.api.R;
+import org.springblade.modules.business.entity.FacilityCargoWay;
+import org.springblade.modules.business.service.IFacilityCargoWayService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping(CommonConstant.API_URL + "/cargo-way")
+@Api(value = "货道管理接口", tags = "货道管理接口")
+public class ApiFacilityCargoWayController {
+
+    private final IFacilityCargoWayService iFacilityCargoWayService;
+
+    /**
+     * 设置货道商品
+     */
+    @PostMapping("/goods/setting")
+    @ApiOperationSupport(order = 6)
+    @ApiOperation(value = "设置货道商品", notes = "传入facilityCargoWay")
+    public R<Void> submit(@Valid @RequestBody FacilityCargoWay facilityCargoWay) {
+        return R.status(iFacilityCargoWayService.saveOrUpdate(facilityCargoWay));
+    }
+
+
+}

+ 25 - 4
src/main/java/org/springblade/modules/api/controller/ApiGoodsController.java

@@ -14,6 +14,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.enums.*;
 import org.springblade.core.boot.ctrl.BladeController;
@@ -21,6 +22,7 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.modules.api.request.GoodsListRequest;
+import org.springblade.modules.business.service.IFacilityService;
 import org.springblade.modules.mall.entity.CategoryInfo;
 import org.springblade.modules.mall.entity.GoodsInfo;
 import org.springblade.modules.mall.service.ICategoryInfoService;
@@ -40,14 +42,14 @@ import java.util.List;
  * Description
  */
 @RestController
+@AllArgsConstructor
 @RequestMapping(CommonConstant.API_URL)
 @Api(value = "商城模块接口", tags = "05.商城模块接口")
 public class ApiGoodsController extends BladeController {
 
-    @Resource
-    private ICategoryInfoService categoryInfoService;
-    @Resource
-    private IGoodsInfoService goodsInfoService;
+    private final ICategoryInfoService categoryInfoService;
+    private final IGoodsInfoService goodsInfoService;
+    private final IFacilityService iFacilityService;
 
     @GetMapping("/category/list")
     @ApiOperationSupport(order = 1)
@@ -84,4 +86,23 @@ public class ApiGoodsController extends BladeController {
         return R.data(goodsInfoVOS);
     }
 
+    @GetMapping("/goods")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "查询平台商品列表")
+    public R<IPage<GoodsInfo>> getPlatGoods(GoodsListRequest request, Query query) {
+        LambdaQueryWrapper<GoodsInfo> wrapper = Wrappers.lambdaQuery(GoodsInfo.class);
+        wrapper.eq(GoodsInfo::getIsSale, GoodsStateEnum.ON_SALE.getValue());
+        wrapper.like(StrUtil.isNotBlank(request.getGoodsName()), GoodsInfo::getGoodsName, request.getGoodsName());
+        IPage<GoodsInfo> pages = goodsInfoService.page(Condition.getPage(query), wrapper);
+        return R.data(pages);
+    }
+
+    @GetMapping("/goods/byDeviceId")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "查询设备商品")
+    public R<List<GoodsInfo>> getByDeviceId(Long deviceId) {
+        List<GoodsInfo> goods = iFacilityService.getGoods(deviceId);
+        return R.data(goods);
+    }
+
 }

+ 3 - 0
src/main/java/org/springblade/modules/business/mapper/FacilityMapper.java

@@ -20,6 +20,8 @@ import org.springblade.modules.business.entity.Facility;
 import org.springblade.modules.business.vo.FacilityVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.mall.entity.GoodsInfo;
+
 import java.util.List;
 
 /**
@@ -39,4 +41,5 @@ public interface FacilityMapper extends BaseMapper<Facility> {
 	 */
 	List<FacilityVO> selectFacilityPage(IPage page, FacilityVO facility);
 
+    List<GoodsInfo> selectGoods(Long deviceId);
 }

+ 13 - 0
src/main/java/org/springblade/modules/business/mapper/FacilityMapper.xml

@@ -25,5 +25,18 @@
     <select id="selectFacilityPage" resultMap="facilityResultMap">
         select * from t_facility where is_delete = 0
     </select>
+    <select id="selectGoods" resultType="org.springblade.modules.mall.entity.GoodsInfo">
+        SELECT
+            gi.id,
+            gi.goods_name,
+            gi.goods_cover,
+            fcw.goods_store totalStock,
+            fcw.discount,
+            fcw.sale_price
+        FROM
+            t_facility_cargo_way fcw
+                JOIN t_goods_info gi ON fcw.goods_id = gi.id
+        where fcw.facility_id = #{deviceId}
+    </select>
 
 </mapper>

+ 9 - 0
src/main/java/org/springblade/modules/business/service/IFacilityService.java

@@ -20,6 +20,9 @@ import org.springblade.modules.business.entity.Facility;
 import org.springblade.modules.business.vo.FacilityVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.mall.entity.GoodsInfo;
+
+import java.util.List;
 
 /**
  * 售货设备表 服务类
@@ -38,4 +41,10 @@ public interface IFacilityService extends IService<Facility> {
 	 */
 	IPage<FacilityVO> selectFacilityPage(IPage<FacilityVO> page, FacilityVO facility);
 
+	/**
+	 * 查询设备商品
+	 * @param deviceId 设备id
+	 * @return 商品列表
+	 */
+    List<GoodsInfo> getGoods(Long deviceId);
 }

+ 8 - 0
src/main/java/org/springblade/modules/business/service/impl/FacilityServiceImpl.java

@@ -21,9 +21,12 @@ import org.springblade.modules.business.vo.FacilityVO;
 import org.springblade.modules.business.mapper.FacilityMapper;
 import org.springblade.modules.business.service.IFacilityService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.mall.entity.GoodsInfo;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.util.List;
+
 /**
  * 售货设备表 服务实现类
  *
@@ -38,4 +41,9 @@ public class FacilityServiceImpl extends ServiceImpl<FacilityMapper, Facility> i
 		return page.setRecords(baseMapper.selectFacilityPage(page, facility));
 	}
 
+	@Override
+	public List<GoodsInfo> getGoods(Long deviceId) {
+		return baseMapper.selectGoods(deviceId);
+	}
+
 }

+ 1 - 7
src/main/java/org/springblade/modules/mall/mapper/GoodsInfoMapper.xml

@@ -35,7 +35,7 @@
 
 
     <select id="selectGoodsInfoPage" resultType="org.springblade.modules.mall.vo.GoodsInfoVO">
-        select g.*,v.name supplierName from t_goods_info g LEFT JOIN t_store v on g.supplier_id = v.id
+        select g.* from t_goods_info g
         WHERE g.is_delete = 0
         <if test="@cn.hutool.core.util.StrUtil@isNotBlank(goodsInfo.goodsName)">
             and instr(g.goods_name, #{goodsInfo.goodsName}) > 0
@@ -55,12 +55,6 @@
         <if test="@cn.hutool.core.util.StrUtil@isNotBlank(goodsInfo.goodsCategoryId)">
             and instr(g.goods_category_id, #{goodsInfo.goodsCategoryId}) > 0
         </if>
-        <if test="@cn.hutool.core.util.StrUtil@isNotBlank(goodsInfo.supplierName)">
-            and instr(v.name, #{goodsInfo.supplierName}) > 0
-        </if>
-        <if test="@cn.hutool.core.util.ObjectUtil@isNotEmpty(goodsInfo.supplierId)">
-            and g.supplier_id = #{goodsInfo.supplierId}
-        </if>
     </select>
 
     <select id="activityGoods" resultType="org.springblade.modules.mall.entity.GoodsInfo">

+ 1 - 0
src/main/resources/application.yml

@@ -270,6 +270,7 @@ blade:
       - /v1/groupon/detail
       - /v1/groupon/detail
       - /v1/article-detail
+      - /v1/shop/all
       - /groupon/groupon/gen
     #授权认证配置
     auth: