3
0

2 Commits 3c69ef5060 ... 002814ba06

Autor SHA1 Nachricht Datum
  ‘linchangsheng’ 002814ba06 Merge remote-tracking branch 'origin/master' vor 4 Tagen
  ‘linchangsheng’ b2f1eccb40 需求 vor 4 Tagen

+ 19 - 0
src/main/java/com/gree/mall/contest/bean/goods/GoodsShareDTO.java

@@ -0,0 +1,19 @@
+package com.gree.mall.contest.bean.goods;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.gree.mall.contest.plus.entity.GoodsShare;
+import com.gree.mall.contest.plus.entity.GoodsShareList;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class GoodsShareDTO extends GoodsShare {
+
+
+    @Schema(description = "绑定商品")
+    private List<GoodsShareList> goodsShareLists;
+
+
+}

+ 20 - 0
src/main/java/com/gree/mall/contest/bean/goods/GoodsShareDetail.java

@@ -0,0 +1,20 @@
+package com.gree.mall.contest.bean.goods;
+
+import com.gree.mall.contest.plus.entity.Goods;
+import com.gree.mall.contest.plus.entity.GoodsShare;
+import com.gree.mall.contest.plus.entity.GoodsShareList;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class GoodsShareDetail extends GoodsShare {
+
+    @Schema(description = "绑定商品")
+    private List<GoodsShareList> goodsShareLists;
+
+    @Schema(description = "商品")
+    private List<Goods> goodsList;
+
+}

+ 3 - 5
src/main/java/com/gree/mall/contest/commonmapper/CustomGoodsMapper.java

@@ -3,12 +3,8 @@ package com.gree.mall.contest.commonmapper;
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.gree.mall.contest.bean.goods.GoodsPackageList;
-import com.gree.mall.contest.bean.goods.GoodsSpecBean;
-import com.gree.mall.contest.bean.goods.GoodsTypeCount;
-import com.gree.mall.contest.bean.goods.GoodsVO;
+import com.gree.mall.contest.bean.goods.*;
 import com.gree.mall.contest.bean.zfire.ZfireParamBean;
-import com.gree.mall.contest.bean.goods.GoodsFavoriteBean;
 import com.gree.mall.contest.plus.entity.Goods;
 import com.gree.mall.contest.plus.entity.GoodsCategory;
 import org.apache.ibatis.annotations.Param;
@@ -112,4 +108,6 @@ public interface CustomGoodsMapper {
     Integer queryGoodsFavoriteCount(@Param("userId") String userId);
 
     IPage<GoodsVO> goodsList(Page page, @Param("ex") ZfireParamBean zfireParam);
+
+    IPage<GoodsShareVO> goodsShareList(Page page, @Param("ex") ZfireParamBean zfireParam);
 }

+ 16 - 17
src/main/java/com/gree/mall/contest/controller/pc/goods/GoodsShareController.java

@@ -4,15 +4,14 @@ import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.contest.annotation.ZfireList;
-import com.gree.mall.contest.bean.goods.GoodsCategoryBean;
-import com.gree.mall.contest.bean.goods.GoodsShareVO;
-import com.gree.mall.contest.bean.goods.GoodsVO;
+import com.gree.mall.contest.bean.goods.*;
 import com.gree.mall.contest.bean.zfire.ZfireParamBean;
 import com.gree.mall.contest.exception.RemoteServiceException;
 import com.gree.mall.contest.helper.ResponseHelper;
 import com.gree.mall.contest.logic.goods.GoodsCategoryLogic;
 import com.gree.mall.contest.logic.goods.GoodsLogic;
 import com.gree.mall.contest.plus.entity.GoodsCategory;
+import com.gree.mall.contest.plus.entity.GoodsShare;
 import com.gree.mall.contest.utils.zfire.FieldUtils;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -57,37 +56,37 @@ public class GoodsShareController {
         //3.导出
         FieldUtils.exportData(adminDeptVOIPage.getRecords(), zfireParam.getExportFields(), request, response);
     }
-   /* @PostMapping("/add")
-    @Operation(summary = "新增分")
+    @PostMapping("/add")
+    @Operation(summary = "新增分享图片")
     public ResponseHelper add(
-            @Parameter(description = "object",required = true) @RequestBody GoodsCategoryBean goodsCategoryBean,HttpServletRequest request) {
-        goodsCategoryLogic.add(goodsCategoryBean,request);
+            @Parameter(description = "object",required = true) @RequestBody GoodsShareDTO goodsShareDTO, HttpServletRequest request) {
+        goodsLogic.addShare(goodsShareDTO,request);
         return ResponseHelper.success();
     }
 
     @PostMapping("/update")
-    @Operation(summary = "修改分")
+    @Operation(summary = "修改分享图片")
     public ResponseHelper update(
-            @Parameter(description = "object",required = true) @RequestBody GoodsCategory goodsCategory) {
-        goodsCategoryLogic.update(goodsCategory);
+            @Parameter(description = "object",required = true) @RequestBody GoodsShareDTO goodsShareDTO) {
+        goodsLogic.updateShare(goodsShareDTO);
         return ResponseHelper.success();
     }
 
     @PostMapping("/delete")
-    @Operation(summary = "删除分")
+    @Operation(summary = "删除分享图片")
     public ResponseHelper delete(
-            @Parameter(description = "分类id",required = true) @RequestParam String categoryId
+            @Parameter(description = "分享id",required = true) @RequestParam String shareId
     ) {
-        goodsCategoryLogic.delete(categoryId);
+        goodsLogic.deleteShare(shareId);
         return ResponseHelper.success();
     }
 
     @GetMapping("/detail")
     @Operation(summary = "详情")
-    public ResponseHelper<GoodsCategory> detail(
-            @Parameter(description = "分类id",required = true) @RequestParam String categoryId
+    public ResponseHelper<GoodsShareDetail> detail(
+            @Parameter(description = "分享id",required = true) @RequestParam String shareId
     ){
-        GoodsCategory detail = goodsCategoryLogic.detail(categoryId);
+        GoodsShareDetail detail = goodsLogic.detailShare(shareId);
         return ResponseHelper.success(detail);
-    }*/
+    }
 }

+ 64 - 1
src/main/java/com/gree/mall/contest/logic/goods/GoodsLogic.java

@@ -75,6 +75,8 @@ public class GoodsLogic {
     private final PromotionGroupSpecService promotionGroupSpecService;
     private final PromotionGroupService promotionGroupService;
     private final WechatLogic wechatLogic;
+    private final GoodsShareService goodsShareService;
+    private final GoodsShareListService goodsShareListService;
     @Value("${goods.share.limit.percent}")
     private String percentLimit;
 
@@ -1567,6 +1569,67 @@ public class GoodsLogic {
     }
 
     public IPage<GoodsShareVO> goodsSharePage(Page page, ZfireParamBean zfireParam) {
-        return null;
+        //获取当前登录企业id
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        //1.组装查询条件
+        FieldUtils.supplyParam(zfireParam, GoodsVO.class,adminUser);
+
+        IPage<GoodsShareVO> goodsVOIPage = customGoodsMapper.goodsShareList(page, zfireParam);
+        return goodsVOIPage;
+    }
+
+    public void addShare(GoodsShareDTO goodsShareDTO, HttpServletRequest request) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        goodsShareDTO.setCompanyName(adminUser.getAdminCompanyWechat().getCompanyName());
+        goodsShareDTO.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+        goodsShareDTO.insert();
+
+        for (GoodsShareList goodsShareList : goodsShareDTO.getGoodsShareLists()) {
+            goodsShareList.setGoodsShareId(goodsShareDTO.getGoodsShareId());
+        }
+
+        goodsShareListService.saveBatch(goodsShareDTO.getGoodsShareLists());
+    }
+
+    public void updateShare(GoodsShareDTO goodsShareDTO) {
+
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        goodsShareDTO.setCompanyName(adminUser.getAdminCompanyWechat().getCompanyName());
+        goodsShareDTO.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+        goodsShareDTO.updateById();
+
+        goodsShareListService.lambdaUpdate().eq(GoodsShareList::getGoodsShareId,goodsShareDTO.getGoodsShareId())
+                .remove();
+        for (GoodsShareList goodsShareList : goodsShareDTO.getGoodsShareLists()) {
+            goodsShareList.setGoodsShareId(goodsShareDTO.getGoodsShareId());
+        }
+
+        goodsShareListService.saveBatch(goodsShareDTO.getGoodsShareLists());
+    }
+
+    public void deleteShare(String shareId) {
+        goodsShareService.removeById(shareId);
+    }
+
+    public GoodsShareDetail detailShare(String shareId) {
+        GoodsShare goodsShare = goodsShareService.getById(shareId);
+
+        GoodsShareDetail goodsShareDetail = BeanUtil.toBean(goodsShare, GoodsShareDetail.class);
+
+        List<GoodsShareList> goodsShareLists = goodsShareListService.lambdaQuery()
+                .eq(GoodsShareList::getGoodsShareId, goodsShareDetail.getGoodsShareId())
+                .list();
+        goodsShareDetail.setGoodsShareLists(goodsShareLists);
+        List<String> collect = goodsShareLists.stream().map(GoodsShareList::getGoodsId).collect(Collectors.toList());
+        if (CollectionUtils.isNotEmpty(collect)){
+            List<Goods> list = goodsService.lambdaQuery().in(Goods::getGoodsId, collect).list();
+
+            goodsShareDetail.setGoodsList(list);
+        }
+
+        return goodsShareDetail;
     }
 }

+ 10 - 0
src/main/resources/mapper/CustomGoodsMapper.xml

@@ -238,5 +238,15 @@
                            on gs.goods_id = gf.goods_id
         where gf.user_id = #{userId}
     </select>
+    <select id="goodsShareList" resultType="com.gree.mall.contest.bean.goods.GoodsShareVO">
+        SELECT
+        ${ex.selected}
+        FROM goods_share a
+        ${ex.query}
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 
 </mapper>