Browse Source

内容库V1.0.0

kaick 1 year ago
parent
commit
40eab7a047

+ 150 - 0
src/main/java/com/caimei365/commodity/controller/ProductArchiveApi.java

@@ -0,0 +1,150 @@
+package com.caimei365.commodity.controller;
+
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.po.KeyPo;
+import com.caimei365.commodity.model.vo.CmProductArchiveVO;
+import com.caimei365.commodity.service.CmProductArchiveContentService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 功能描述:内容库相关
+ *
+ * @auther: Kaick
+ * @date: 2023/12/25 10:21
+ * @params:
+ * @return:
+ */
+@Api(tags = "内容库API")
+@RestController
+@RequestMapping("/commodity/product/archive")
+public class ProductArchiveApi {
+
+    @Resource
+    private CmProductArchiveContentService cmProductArchiveContentService;
+
+
+    @ApiOperation("商品资料列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @GetMapping("/list")
+    public ResponseJson list(@RequestParam(required=false)String title,
+                             String userId,
+                             @RequestParam(required=false)String type,
+                             @RequestParam(required=false)Integer productId,
+                             @RequestParam(required=false)Integer stageStatus,
+                             @RequestParam(required=false)Integer allStatus,
+                             @RequestParam(required=false)String labelIds,
+                             Integer spId,
+                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum) {
+
+        List list = new ArrayList();
+        pageNum = (pageNum - 1) * 5;
+        if (StringUtils.isBlank(type)) {
+            for (int i = 1; i <= 5; i++) {
+                list.addAll(cmProductArchiveContentService.getCmProductArchiveContentList(new CmProductArchiveVO()
+                        .setTitle(title)
+                        .setUserId(userId)
+                        .setType(String.valueOf(i))
+                        .setProductId(productId)
+                        .setStageStatus(stageStatus)
+                        .setAllStatus(allStatus)
+                        .setLabelIds(labelIds)
+                        .setSpId(spId)
+                        .setPageNum(0)));
+            }
+            list.addAll(cmProductArchiveContentService.getCmProductArchiveInfoList(0, title, labelIds));
+            list.addAll(cmProductArchiveContentService.getCmProductArchiveBaikeList(0, title, labelIds));
+        } else if ("6".equals(type)) {
+            list.addAll(cmProductArchiveContentService.getCmProductArchiveInfoList(pageNum, title, labelIds));
+        } else if ("7".equals(type)) {
+            list.addAll(cmProductArchiveContentService.getCmProductArchiveBaikeList(pageNum, title, labelIds));
+        } else {
+            list.addAll(cmProductArchiveContentService.getCmProductArchiveContentList(new CmProductArchiveVO()
+                    .setTitle(title)
+                    .setUserId(userId)
+                    .setType(type)
+                    .setProductId(productId)
+                    .setStageStatus(stageStatus)
+                    .setAllStatus(allStatus)
+                    .setLabelIds(labelIds)
+                    .setSpId(spId)
+                    .setPageNum(pageNum)));
+        }
+        return ResponseJson.success(list);
+    }
+
+    @GetMapping("/from")
+    public ResponseJson from(String id, String userId) {
+
+        CmProductArchiveVO archiveContent = cmProductArchiveContentService.getByCmProductArchiveContent(new CmProductArchiveVO()
+                .setId(id)
+                .setUserId(userId)
+        );
+        return ResponseJson.success(archiveContent);
+    }
+
+    @PostMapping("/add")
+    public ResponseJson add(CmProductArchiveVO cmProductArchiveVO) {
+        cmProductArchiveVO.setAllStatus(2);
+        cmProductArchiveVO.setType("5");
+        cmProductArchiveContentService.addCmProductArchiveContent(cmProductArchiveVO);
+        return ResponseJson.success();
+    }
+
+    @GetMapping("/findKeyWordList")
+    public ResponseJson findKeyWordList(String v,
+                                        @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                        @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<KeyPo> keyList = cmProductArchiveContentService.findKeyWordList(v);
+        return ResponseJson.success(new PageInfo(keyList));
+    }
+
+    @GetMapping("/findProductList")
+    public ResponseJson findProductList(String productName,
+                                        String shopName,
+                                        Integer productId,
+                                        @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                        @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<CmProductArchiveVO> list = cmProductArchiveContentService.findProductList(new CmProductArchiveVO()
+                .setProductId(productId)
+                .setProductName(productName)
+                .setShopName(shopName)
+        );
+        return ResponseJson.success(new PageInfo<>(list));
+    }
+
+    @GetMapping("/{userId}/{type}/{id}/details")
+    public ResponseJson details(@PathVariable String id,
+                                @PathVariable String type,
+                                @PathVariable String userId) {
+
+        if (StringUtils.isBlank(id)||
+                StringUtils.isBlank(type)||
+                StringUtils.isBlank(userId)) {
+            ResponseJson.error("权限异常!");
+        }
+
+        CmProductArchiveVO archiveContent = cmProductArchiveContentService.getByCmProductArchiveContent(new CmProductArchiveVO()
+                .setId(id)
+                .setType(type)
+                .setUserId(userId)
+        );
+        return ResponseJson.success(archiveContent);
+    }
+
+}

+ 2 - 2
src/main/java/com/caimei365/commodity/feign/ToolsFeign.java

@@ -1,9 +1,7 @@
 package com.caimei365.commodity.feign;
 package com.caimei365.commodity.feign;
 
 
-import com.caimei365.commodity.model.dto.MessageDto;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestParam;
 
 
 /**
 /**
@@ -30,4 +28,6 @@ public interface ToolsFeign {
      */
      */
     @PostMapping("/tools/sms/send")
     @PostMapping("/tools/sms/send")
     String getSendSms(@RequestParam String mobile, @RequestParam String content);
     String getSendSms(@RequestParam String mobile, @RequestParam String content);
+
+
 }
 }

+ 20 - 0
src/main/java/com/caimei365/commodity/feign/UserFeign.java

@@ -0,0 +1,20 @@
+package com.caimei365.commodity.feign;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/9/8
+ */
+@FeignClient("CAIMEI365-CLOUD-USER")
+public interface UserFeign {
+
+
+    @GetMapping("/user/getUserType")
+    public int getUserType(String userId);
+
+
+}

+ 71 - 0
src/main/java/com/caimei365/commodity/mapper/CmProductArchiveContentMapper.java

@@ -0,0 +1,71 @@
+package com.caimei365.commodity.mapper;
+
+import com.caimei365.commodity.model.po.KeyPo;
+import com.caimei365.commodity.model.vo.CmProductArchiveVO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 商品资料内容Mapper接口
+ *
+ * @author Kaick
+ * @date 2023-12-25
+ */
+@Mapper
+public interface CmProductArchiveContentMapper {
+    /**
+     * 通过对象查询商品资料内容列表
+     *
+     * @return 商品资料内容集合
+     */
+    List<CmProductArchiveVO> getCmProductArchiveContentList(CmProductArchiveVO cmProductArchiveVO);
+
+    List<CmProductArchiveVO> getCmProductArchiveInfoList(Integer pageNum,String title,String labelIds);
+
+    List<CmProductArchiveVO> getCmProductArchiveBaikeList(Integer pageNum,String title,String labelIds);
+    /**
+     * 通过对象查询商品资料内容列表
+     *
+     * @return 商品资料内容集合
+     */
+    List<String> getProductArchiveFileList(String id);
+
+
+    /**
+     * 通过对象查询商品资料内容对象
+     *
+     * @return 商品资料内容
+     */
+    CmProductArchiveVO getByCmProductArchiveContent(CmProductArchiveVO cmProductArchiveContent);
+
+
+    /**
+     * 新增商品资料内容
+     *
+     * @return 结果
+     */
+    int addCmProductArchiveContent(CmProductArchiveVO cmProductArchiveContent);
+
+    /**
+     * 修改商品资料内容
+     *
+     * @return 结果
+     */
+    int updateCmProductArchiveContent(CmProductArchiveVO cmProductArchiveContent);
+
+    /**
+     * 删除商品资料内容
+     *
+     * @return 结果
+     */
+    int delCmProductArchiveContentById(String id);
+    /**
+     * 关键词下拉选择项
+     */
+    List<KeyPo> findKeyWordList(String v);
+    /**
+     * 已上线商品列表
+     */
+    List<CmProductArchiveVO> findProductList(CmProductArchiveVO cmProductArchiveVO);
+}

+ 4 - 4
src/main/java/com/caimei365/commodity/model/po/ArchivePo.java

@@ -39,10 +39,10 @@ public class ArchivePo implements Serializable {
      * 商品属性:1产品,2仪器
      * 商品属性:1产品,2仪器
      */
      */
     private Integer productType;
     private Integer productType;
-    /**
-     * 资料等级:1一类资料,2二类资料,3三类资料
-     */
-    private Integer archiveLevel;
+    // /**
+    //  * 资料等级:1一类资料,2二类资料,3三类资料
+    //  */
+    // private Integer archiveLevel;
     /**
     /**
      * 商品分类:1医美,2生美
      * 商品分类:1医美,2生美
      */
      */

+ 31 - 0
src/main/java/com/caimei365/commodity/model/po/KeyPo.java

@@ -0,0 +1,31 @@
+package com.caimei365.commodity.model.po;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+
+import java.io.Serializable;
+
+/**
+ * KeyPo
+ *
+ * @author Kaick
+ * @date 2023-12-25
+ */
+@Accessors(chain = true)
+@Data
+@Alias("KeyPo")
+public class KeyPo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * key
+     */
+    private String k;
+
+
+    /**
+     * value
+     */
+    private Object v;
+
+}

+ 155 - 0
src/main/java/com/caimei365/commodity/model/vo/CmProductArchiveVO.java

@@ -0,0 +1,155 @@
+package com.caimei365.commodity.model.vo;
+
+import com.caimei365.commodity.utils.AesEncryptUtil;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 商品资料库对象 cm_product_archive VO对象
+ *
+ * @author Kaick
+ * @date 2023-12-25
+ */
+@Accessors(chain = true)
+@Data
+@Alias("CmProductArchiveVO")
+public class CmProductArchiveVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 商品资料库id
+     */
+    private Integer productArchiveId;
+
+    /**
+     * id
+     */
+    private String id;
+    /**
+     * userId
+     */
+    private String userId;
+    /**
+     * permission:0可查看,1未登录,2需升级会员机构(已弃用),3需升级医美会员机构,4需要抵扣采美豆(已弃用),5无权限查看
+     */
+    private Integer permission;
+
+    /**
+     * 商品id
+     */
+    private Integer productId;
+
+    /**
+     * 商品名称
+     */
+    private String productName;
+
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+
+    /**
+     * 商品图片
+     */
+    private String image;
+
+    /**
+     * 商品属性:1产品,2仪器
+     */
+    private String productType;
+
+    /**
+     * 商品分类:1医美,2生美
+     */
+    private Integer productClassify;
+
+    /**
+     * 添加时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date addTime;
+
+    /**
+     * 标签库ids
+     */
+    private String labelIds;
+    /**
+     * 标签库s
+     */
+    private String keywords;
+
+
+    /**
+     * 资料标题
+     */
+    private String title;
+
+    /**
+     * 资料类型:
+     * 1图片资料,
+     * 2视频资料,
+     * 3文件资料,
+     * 4文本资料
+     * 5话术资料
+     */
+    private String type;
+
+    /**
+     * 内容
+     */
+    private String content;
+
+    /**
+     * 用户阶段状态:
+     * 1认知阶段、
+     * 2兴趣阶段、
+     * 3决策阶段、
+     * 4购买阶段
+     */
+    private Integer stageStatus;
+
+    /**
+     * 所有状态:
+     * 1企业,
+     * 2个人
+     */
+    private Integer allStatus;
+    /**
+     * 协销Id
+     */
+    private Integer spId;
+    /**
+     * createBy
+     */
+    private String createBy;
+    /**
+     * 点击量
+     */
+    private Integer pv;
+
+    private Integer pageNum;
+
+    /**
+     * 水印oss链接
+     */
+    private List<String> waters;
+
+    public CmProductArchiveVO setWaters(List<String> waters) {
+        List<String> strings = new ArrayList(waters.size());
+        if (waters != null) {
+            waters.forEach(s -> {
+                strings.add(AesEncryptUtil.encrypt(s));
+            });
+        }
+        this.waters = strings;
+        return this;
+    }
+}

+ 39 - 0
src/main/java/com/caimei365/commodity/service/CmProductArchiveContentService.java

@@ -0,0 +1,39 @@
+package com.caimei365.commodity.service;
+
+import com.caimei365.commodity.model.po.KeyPo;
+import com.caimei365.commodity.model.vo.CmProductArchiveVO;
+
+import java.util.List;
+
+/**
+ * 商品资料内容Service接口
+ *
+ * @author Kaick
+ * @date 2023-12-25
+ */
+public interface CmProductArchiveContentService {
+
+    List<CmProductArchiveVO> getCmProductArchiveContentList(CmProductArchiveVO cmProductArchiveVO);
+
+    List<CmProductArchiveVO> getCmProductArchiveInfoList(Integer pageNum,String title,String labelIds);
+
+    List<CmProductArchiveVO> getCmProductArchiveBaikeList(Integer pageNum,String title,String labelIds);
+    /**
+     * 关键词下拉选择项
+     */
+    List<KeyPo> findKeyWordList(String v);
+    /**
+     * 已上线商品列表
+     */
+    List<CmProductArchiveVO> findProductList(CmProductArchiveVO cmProductArchiveVO);
+
+    CmProductArchiveVO getByCmProductArchiveContent(CmProductArchiveVO cmProductArchiveVO);
+
+
+    int addCmProductArchiveContent(CmProductArchiveVO cmProductArchiveVO);
+
+
+    int delCmProductArchiveContentById(String id);
+
+}
+

+ 118 - 0
src/main/java/com/caimei365/commodity/service/impl/CmProductArchiveContentServiceImpl.java

@@ -0,0 +1,118 @@
+package com.caimei365.commodity.service.impl;
+
+import com.caimei365.commodity.feign.UserFeign;
+import com.caimei365.commodity.mapper.CmProductArchiveContentMapper;
+import com.caimei365.commodity.mapper.PageMapper;
+import com.caimei365.commodity.mapper.PriceMapper;
+import com.caimei365.commodity.model.po.KeyPo;
+import com.caimei365.commodity.model.vo.CmProductArchiveVO;
+import com.caimei365.commodity.service.CmProductArchiveContentService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 商品资料内容Service业务层处理
+ *
+ * @author Kaick
+ * @date 2023-12-25
+ */
+@Service
+public class CmProductArchiveContentServiceImpl implements CmProductArchiveContentService
+{
+    @Resource
+    private PageMapper pageMapper;
+
+    @Resource
+    private PriceMapper priceMapper;
+    @Resource
+    private CmProductArchiveContentMapper cmProductArchiveContentMapper;
+    @Resource
+    private UserFeign userFeign;
+
+    @Override
+    public List<CmProductArchiveVO> getCmProductArchiveContentList(CmProductArchiveVO cmProductArchiveVO) {
+        List<CmProductArchiveVO> cmProductArchiveContentList = cmProductArchiveContentMapper.getCmProductArchiveContentList(cmProductArchiveVO);
+        if (cmProductArchiveContentList != null) {
+            for (CmProductArchiveVO productArchiveVO : cmProductArchiveContentList) {
+                productArchiveVO.setWaters(cmProductArchiveContentMapper.getProductArchiveFileList(productArchiveVO.getId()));
+            }
+        }
+        return cmProductArchiveContentList;
+    }
+
+    @Override
+    public List<CmProductArchiveVO> getCmProductArchiveInfoList(Integer pageNum,String title,String labelIds) {
+        return cmProductArchiveContentMapper.getCmProductArchiveInfoList(pageNum, title, labelIds);
+    }
+
+    @Override
+    public List<CmProductArchiveVO> getCmProductArchiveBaikeList(Integer pageNum,String title,String labelIds) {
+        return cmProductArchiveContentMapper.getCmProductArchiveBaikeList(pageNum, title, labelIds);
+    }
+
+    @Override
+    public List<KeyPo> findKeyWordList(String v) {
+        return cmProductArchiveContentMapper.findKeyWordList(v);
+    }
+
+    @Override
+    public List<CmProductArchiveVO> findProductList(CmProductArchiveVO cmProductArchiveVO) {
+        return cmProductArchiveContentMapper.findProductList(cmProductArchiveVO);
+    }
+
+    @Override
+    public CmProductArchiveVO getByCmProductArchiveContent(CmProductArchiveVO cmProductArchiveVO) {
+        CmProductArchiveVO byCmProductArchiveContent = cmProductArchiveContentMapper.getByCmProductArchiveContent(cmProductArchiveVO);
+        if (byCmProductArchiveContent != null) {
+            int permission = checkArchivePermission(byCmProductArchiveContent.getProductClassify(), Integer.valueOf(cmProductArchiveVO.getUserId()));
+            byCmProductArchiveContent.setPermission(permission);
+            byCmProductArchiveContent.setWaters(cmProductArchiveContentMapper.getProductArchiveFileList(byCmProductArchiveContent.getId()));
+
+        }
+        return byCmProductArchiveContent;
+    }
+
+    @Override
+    public int addCmProductArchiveContent(CmProductArchiveVO cmProductArchiveVO) {
+       if(null!=cmProductArchiveVO.getId()){
+           cmProductArchiveContentMapper.updateCmProductArchiveContent(cmProductArchiveVO);
+       }else {
+           cmProductArchiveVO.setAddTime(new Date());
+           cmProductArchiveContentMapper.addCmProductArchiveContent(cmProductArchiveVO);
+       }
+        return 1;
+    }
+
+
+    @Override
+    public int delCmProductArchiveContentById(String id) {
+        return cmProductArchiveContentMapper.delCmProductArchiveContentById(id);
+    }
+
+    private Integer checkArchivePermission(Integer productClassify, Integer userId) {
+        // 根据用户Id查询用户身份
+        Integer identity = priceMapper.getIdentityByUserId(userId);
+        // 1生美机构,2医美机构
+        Integer clubType = pageMapper.getClubTypeByUserId(userId);
+        // permission:0可查看,1未登录,2需升级会员机构(已弃用),3需升级医美会员机构,4需要抵扣采美豆(已弃用),5无权限查看
+        int permission;
+        if (null == identity) {
+            // 未登录
+            permission = 1;
+        } else if (1 == identity  || 2 == clubType) {
+            //协销和医美可查看所有资料
+            permission = 0;
+        } else if (2 != clubType) {
+            //个人机构、医美、生美、项目公司、其他 仅可以访问生美资料
+            permission = 1 == productClassify ? 3 : 0;
+        } else {
+            permission = 5;
+        }
+        return permission;
+    }
+
+}
+

+ 16 - 44
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -10,6 +10,7 @@ import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.PageService;
 import com.caimei365.commodity.service.PageService;
+import com.caimei365.commodity.utils.AesEncryptUtil;
 import com.caimei365.commodity.utils.AppletsLinkUtil;
 import com.caimei365.commodity.utils.AppletsLinkUtil;
 import com.caimei365.commodity.utils.ImageUtils;
 import com.caimei365.commodity.utils.ImageUtils;
 import com.caimei365.commodity.utils.MathUtil;
 import com.caimei365.commodity.utils.MathUtil;
@@ -1250,7 +1251,7 @@ public class PageServiceImpl implements PageService {
             return ResponseJson.error("商品资料不存在", null);
             return ResponseJson.error("商品资料不存在", null);
         }
         }
         // 判断该用户是否拥有访问该资料的权限
         // 判断该用户是否拥有访问该资料的权限
-        int permission = checkArchivePermission(archive, userId);
+        int permission = checkArchivePermission(archive.getProductId(),archive.getProductClassify(), userId);
         List<ArchiveContentVo> imageArchiveList = pageMapper.getImageArchiveList(archiveId);
         List<ArchiveContentVo> imageArchiveList = pageMapper.getImageArchiveList(archiveId);
         List<ArchiveContentVo> videoArchiveList = pageMapper.getVideoArchiveList(archiveId);
         List<ArchiveContentVo> videoArchiveList = pageMapper.getVideoArchiveList(archiveId);
         List<ArchiveContentVo> fileArchiveList = pageMapper.getFileArchiveList(archiveId);
         List<ArchiveContentVo> fileArchiveList = pageMapper.getFileArchiveList(archiveId);
@@ -1270,7 +1271,6 @@ public class PageServiceImpl implements PageService {
             } else if (2 == productClassify && imageArchive.getImageNum() >= 5) {
             } else if (2 == productClassify && imageArchive.getImageNum() >= 5) {
                 imageArchive.setImageList(imageList.subList(0, 2));
                 imageArchive.setImageList(imageList.subList(0, 2));
             }
             }
-
         }
         }
         videoArchiveList.forEach(videoArchive -> {
         videoArchiveList.forEach(videoArchive -> {
             ArchiveFilePo archiveFile = pageMapper.getArchiveFile(videoArchive.getArchiveContentId());
             ArchiveFilePo archiveFile = pageMapper.getArchiveFile(videoArchive.getArchiveContentId());
@@ -1322,65 +1322,37 @@ public class PageServiceImpl implements PageService {
         return ResponseJson.success(archiveDetail);
         return ResponseJson.success(archiveDetail);
     }
     }
 
 
-    private Integer checkArchivePermission(ArchivePo archive, Integer userId) {
-        //资料等级:1一类资料,2二类资料,3三类资料
-        Integer archiveLevel = archive.getArchiveLevel();
-        //商品分类:1医美,2生美
-        Integer productClassify = archive.getProductClassify();
+    private Integer checkArchivePermission(Integer productId,Integer productClassify, Integer userId) {
         // 根据用户Id查询用户身份
         // 根据用户Id查询用户身份
-
         Integer identity = priceMapper.getIdentityByUserId(userId);
         Integer identity = priceMapper.getIdentityByUserId(userId);
         // 1生美机构,2医美机构
         // 1生美机构,2医美机构
         Integer clubType = pageMapper.getClubTypeByUserId(userId);
         Integer clubType = pageMapper.getClubTypeByUserId(userId);
-        // permission:0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
+        // permission:0可查看,1未登录,2需升级会员机构(已弃用),3需升级医美会员机构,4需要抵扣采美豆(已弃用),5无权限查看
         int permission;
         int permission;
         if (null == identity) {
         if (null == identity) {
             // 未登录
             // 未登录
             permission = 1;
             permission = 1;
-        } else if (1 == identity || 7 == identity) {
-            if(7 == identity){
+        } else if (1 == identity || 7 == identity || 2 == clubType) {
+            if (7 == identity) {
                 //分销人员可查看团队所有资料
                 //分销人员可查看团队所有资料
                 CmDistribution byCmDistribution = cmDistributionMapper.getByCmDistribution(new CmDistribution().userId(userId));
                 CmDistribution byCmDistribution = cmDistributionMapper.getByCmDistribution(new CmDistribution().userId(userId));
-                if(!byCmDistribution.parentId().equals("0")){
+                if (!byCmDistribution.parentId().equals("0")) {
                     byCmDistribution.id(String.valueOf(byCmDistribution.parentId()));
                     byCmDistribution.id(String.valueOf(byCmDistribution.parentId()));
                 }
                 }
                 int productCount = cmDistributionProductMapper.getCmDistributionTeamProductCount(new CmDistributionTeamProduct()
                 int productCount = cmDistributionProductMapper.getCmDistributionTeamProductCount(new CmDistributionTeamProduct()
                         .distributionId(Integer.valueOf(byCmDistribution.id()))
                         .distributionId(Integer.valueOf(byCmDistribution.id()))
-                        .productId(archive.getProductId())
+                        .productId(productId)
                 );
                 );
-                if(productCount==0){
-                    permission = 5;
+                // 商品团队不存在该商品的访问权限
+                if (productCount == 0) {
+                    return 5;
                 }
                 }
             }
             }
-            //协销可查看所有资料
+            //协销和医美可查看所有资料
             permission = 0;
             permission = 0;
-        } else if (4 == identity) {
-            // 普通机构
-            if (archiveLevel > 1) {
-                // 二级资料,普通机构
-                permission = 2 == productClassify ? 2 : 3;
-            } else {
-                permission = 0;
-            }
-        } else if (2 == identity) {
-            // 会员机构
-            if (2 == archiveLevel && 1 == productClassify && (0 == clubType || 2 == clubType)) {
-                // 二级医美资料,生美会员机构
-                permission = 3;
-            } else if (3 == archiveLevel) {
-                // 查询用户对该资料的抵扣记录
-                Integer historyId = pageMapper.findBeansHistoryByArchiveId(userId, archive.getArchiveId());
-                if (1 == productClassify && (0 == clubType || 2 == clubType)) {
-                    // 三级医美资料,生美会员机构
-                    permission = 3;
-                } else if (null == historyId) {
-                    permission = 4;
-                } else {
-                    permission = 0;
-                }
-            } else {
-                permission = 0;
-            }
+        } else if (2 != clubType) {
+            //个人机构、医美、生美、项目公司、其他 仅可以访问生美资料
+            permission = 1 == productClassify ? 3 : 0;
         } else {
         } else {
             permission = 5;
             permission = 5;
         }
         }
@@ -1406,7 +1378,7 @@ public class PageServiceImpl implements PageService {
             log.info("格式化时间错误", e);
             log.info("格式化时间错误", e);
         }
         }
 //        String url = ossClient.generatePresignedUrl(bucketName, active + "/archiveFile/" + ossName, expiration).toString();
 //        String url = ossClient.generatePresignedUrl(bucketName, active + "/archiveFile/" + ossName, expiration).toString();
-        String url = ossClient.generatePresignedUrl(bucketName, ossName, expiration).toString();
+        String url = AesEncryptUtil.encrypt( ossClient.generatePresignedUrl(bucketName, ossName, expiration).toString());
         ossClient.shutdown();
         ossClient.shutdown();
         return url;
         return url;
     }
     }

+ 123 - 0
src/main/java/com/caimei365/commodity/utils/AesEncryptUtil.java

@@ -0,0 +1,123 @@
+package com.caimei365.commodity.utils; /**
+ * AES 128bit 加密解密工具类
+ * @author dufy
+ */
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+@Slf4j
+public class AesEncryptUtil {
+
+    //使用AES-128-CBC加密模式,key需要为16位,key和iv可以相同!
+    private static String KEY = "caimei--20240103";
+
+    private static String IV = "caimei--20240103";
+
+    /**
+     * 加密方法
+     * @param data  要加密的数据
+     * @param key 加密key
+     * @param iv 加密iv
+     * @return 加密的结果
+     * @
+     */
+    public static String encrypt(String data, String key, String iv) {
+        try {
+            Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");//"算法/模式/补码方式"
+            int blockSize = cipher.getBlockSize();
+
+            byte[] dataBytes = data.getBytes();
+            int plaintextLength = dataBytes.length;
+            if (plaintextLength % blockSize != 0) {
+                plaintextLength = plaintextLength + (blockSize - (plaintextLength % blockSize));
+            }
+
+            byte[] plaintext = new byte[plaintextLength];
+            System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length);
+
+            SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
+            IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
+
+            cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
+            byte[] encrypted = cipher.doFinal(plaintext);
+
+            return new Base64().encodeToString(encrypted);
+
+        } catch (Exception e) {
+            log.error("AES加密失败!>>>>>>>>>>>data:"+data+">>>>>>>>>>>>>>"+e.getMessage());
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 解密方法
+     * @param data 要解密的数据
+     * @param key  解密key
+     * @param iv 解密iv
+     * @return 解密的结果
+     * @
+     */
+    public static String desEncrypt(String data, String key, String iv)  {
+        try {
+            byte[] encrypted1 = new Base64().decode(data);
+
+            Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
+            SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
+            IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
+
+            cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);
+
+            byte[] original = cipher.doFinal(encrypted1);
+            String originalString = new String(original);
+            return originalString;
+        } catch (Exception e) {
+            log.error("AES解密失败!>>>>>>>>>>>data:"+data+">>>>>>>>>>>>>>"+e.getMessage());
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 使用默认的key和iv加密
+     * @param data
+     * @return
+     * @
+     */
+    public static String encrypt(String data) {
+        return encrypt(data, KEY, IV);
+    }
+
+    /**
+     * 使用默认的key和iv解密
+     * @param data
+     * @return
+     * @
+     */
+    public static String desEncrypt(String data)  {
+        return desEncrypt(data, KEY, IV);
+    }
+
+
+
+    /**
+    * 测试
+    */
+    public static void main(String args[])  {
+
+        String test = "https://img.caimei365.com/group1/M00/04/AC/rB-lGGWTaZ-ALW9_AAZ2C3JI58Q630.jpg";
+
+        String data = null;
+        String key = "caimei--20240103";
+        String iv = "caimei--20240103";
+        data = encrypt(test, key, iv);
+        System.out.println(data);
+        System.out.println(desEncrypt(data, key, iv));
+    }
+
+}

+ 232 - 0
src/main/resources/mapper/CmProductArchiveContentMapper.xml

@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+		PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+		"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.commodity.mapper.CmProductArchiveContentMapper">
+
+	<select id="getByCmProductArchiveContent" parameterType="CmProductArchiveVO" resultType="CmProductArchiveVO">
+		select
+		cm_product_archive_content.id,
+		cm_product_archive_content.productArchiveId,
+		cm_product_archive_content.title,
+		cm_product_archive_content.type,
+		cm_product_archive_content.content,
+		cm_product_archive_content.stageStatus,
+		cm_product_archive_content.allStatus,
+		cm_product_archive_content.labelIds,
+		(SELECT GROUP_CONCAT(cusf.keyword) FROM cm_user_search_frequency cusf WHERE FIND_IN_SET(cusf.id ,cm_product_archive_content.labelIds)) as keywords,
+		cm_product_archive_content.addTime,
+		cm_product_archive_content.spId,
+		cpa.productId,
+		cpa.productName,
+		cpa.shopName,
+		cpa.productImage as image,
+		cpa.productType,
+		cpa.productClassify
+		,IFNULL((select sum(c.pv) from cm_praise_statistics c where  c.delFlag = 0 and c.type = 1 and cm_product_archive_content.id = c.authorId ), 0) as pv
+		from cm_product_archive_content AS cm_product_archive_content
+		left join cm_product_archive cpa on cpa.id = cm_product_archive_content.productArchiveId
+		<where>
+			<if test="id != null  and id != ''">and cm_product_archive_content.id = #{id}</if>
+			<if test="productArchiveId != null ">and cm_product_archive_content.productArchiveId = #{productArchiveId}
+			</if>
+			<if test="title != null  and title != ''">and cm_product_archive_content.title like concat('%', #{title}, '%')</if>
+			<if test="type != null  and type != ''">and cm_product_archive_content.type = #{type}</if>
+			<if test="content != null  and content != ''">and cm_product_archive_content.content = #{content}</if>
+			<if test="stageStatus != null ">and cm_product_archive_content.stageStatus = #{stageStatus}</if>
+			<if test="allStatus != null ">and cm_product_archive_content.allStatus = #{allStatus}</if>
+			<if test="labelIds != null  and labelIds != ''">and cm_product_archive_content.labelIds like concat('%', #{labelIds}, '%')</if>
+			<if test="spId != null ">and cm_product_archive_content.spId = #{spId}</if>
+			<if test="productId != null "> and cpa.productId = #{productId}</if>
+			<if test="productName != null  and productName != ''"> and cpa.productName like concat('%', #{productName}, '%')</if>
+			<if test="shopName != null  and shopName != ''"> and cpa.shopName like concat('%', #{shopName}, '%')</if>
+			<if test="productType != null  and productType != ''"> and cpa.productType = #{productType}</if>
+			<if test="productClassify != null "> and cpa.productClassify = #{productClassify}</if>
+		</where>
+		group by cm_product_archive_content.id
+		limit 0,1
+	</select>
+
+	<select id="getCmProductArchiveContentList" parameterType="CmProductArchiveVO" resultType="CmProductArchiveVO">
+		select
+		cm_product_archive_content.id,
+		cm_product_archive_content.productArchiveId,
+		cm_product_archive_content.title,
+		cm_product_archive_content.type,
+		cm_product_archive_content.content,
+		cm_product_archive_content.stageStatus,
+		cm_product_archive_content.allStatus,
+		cm_product_archive_content.labelIds,
+		(SELECT GROUP_CONCAT(cusf.keyword) FROM cm_user_search_frequency cusf WHERE FIND_IN_SET(cusf.id ,cm_product_archive_content.labelIds)) as keywords,
+		cm_product_archive_content.addTime,
+		cm_product_archive_content.spId,
+		cpa.productId,
+		cpa.productName,
+		cpa.shopName,
+		cpa.productImage as image,
+		cpa.productType,
+		cpa.productClassify
+		from cm_product_archive_content AS cm_product_archive_content
+		left join cm_product_archive cpa on cpa.id = cm_product_archive_content.productArchiveId
+		<where>
+			<if test="id != null  and id != ''">and cm_product_archive_content.id = #{id}</if>
+			<if test="productArchiveId != null ">and cm_product_archive_content.productArchiveId = #{productArchiveId}
+			</if>
+			<if test="title != null  and title != ''">and cm_product_archive_content.title like concat('%', #{title}, '%')</if>
+			<if test="type != null  and type != ''">and cm_product_archive_content.type = #{type}</if>
+			<if test="content != null  and content != ''">and cm_product_archive_content.content = #{content}</if>
+			<if test="stageStatus != null ">and cm_product_archive_content.stageStatus = #{stageStatus}</if>
+			<if test="allStatus != null ">and cm_product_archive_content.allStatus = #{allStatus}</if>
+			<if test="labelIds != null  and labelIds != ''">
+				AND
+				<foreach item="labelIdIn" collection="labelIds.split(',')" open="(" separator="or" close=")">
+					 cm_product_archive_content.labelIds like concat('%', #{labelIdIn}, '%')
+				</foreach>
+			</if>
+			<if test="spId != null ">and cm_product_archive_content.spId = #{spId}</if>
+			<if test="productId != null "> and cpa.productId = #{productId}</if>
+			<if test="productName != null  and productName != ''"> and cpa.productName like concat('%', #{productName}, '%')</if>
+			<if test="shopName != null  and shopName != ''"> and cpa.shopName like concat('%', #{shopName}, '%')</if>
+			<if test="productType != null  and productType != ''"> and cpa.productType = #{productType}</if>
+			<if test="productClassify != null "> and cpa.productClassify = #{productClassify}</if>
+		</where>
+		group by cm_product_archive_content.id
+		order by cm_product_archive_content.addTime desc
+		limit #{pageNum},5
+	</select>
+
+	<select id="getCmProductArchiveInfoList"  resultType="CmProductArchiveVO">
+		select
+		info.id,
+		info.guidanceImage as image,
+		info.title,
+		info.createDate as addTime,
+		6 as type
+		from info AS info
+		where info.delFlag=0
+		and	info.onlineStatus=2
+		and info.enabledStatus=1
+		<if test="labelIds != null  and labelIds != ''">
+			AND
+			<foreach item="labelIdIn" collection="labelIds.split(',')" open="(" separator="or" close=")">
+				info.labelIds like concat('%', #{labelIdIn}, '%')
+			</foreach>
+		</if>
+		<if test="title != null  and title != ''">and info.title like concat('%', #{title}, '%')</if>
+		order by info.createDate desc
+		limit #{pageNum},5
+	</select>
+
+	<select id="getCmProductArchiveBaikeList"  resultType="CmProductArchiveVO">
+		select
+			cbp.id,
+			cbp.image as image,
+			cbp.name as title,
+			cbp.addTime,
+			7 as type
+		from cm_baike_product AS cbp
+		where cbp.delFlag=0
+		and	cbp.onlineStatus=2
+		and cbp.status=1
+		<if test="labelIds != null  and labelIds != ''">
+		  AND
+			<foreach item="labelIdIn" collection="labelIds.split(',')" open="(" separator="or" close=")">
+				cbp.labelIds like concat('%', #{labelIdIn}, '%')
+			</foreach>
+		</if>
+		<if test="title != null  and title != ''">and cbp.name like concat('%', #{title}, '%')</if>
+		order by cbp.addTime desc
+		limit #{pageNum},5
+	</select>
+
+	<select id="getProductArchiveFileList"  resultType="String">
+		select
+		ifnull(waterOssUrl,ossUrl)
+		from cm_product_archive_file
+		<where>
+			archiveContentId=#{id}
+		</where>
+		order by uploadTime desc
+	</select>
+
+
+	<insert id="addCmProductArchiveContent" parameterType="CmProductArchiveVO" useGeneratedKeys="true" keyProperty="id">
+		insert into cm_product_archive_content
+		<trim prefix="(" suffix=")" suffixOverrides=",">
+			<if test="id != null and id != ''">id,</if>
+			<if test="productArchiveId != null">productArchiveId,</if>
+			<if test="title != null and title != ''">title,</if>
+			<if test="type != null and type != ''">type,</if>
+			<if test="content != null and content != ''">content,</if>
+			<if test="stageStatus != null">stageStatus,</if>
+			<if test="allStatus != null">allStatus,</if>
+			<if test="labelIds != null and labelIds != ''">labelIds,</if>
+			<if test="addTime != null">addTime,</if>
+			<if test="createBy != null and createBy != ''">createBy,</if>
+			<if test="spId != null">spId,</if>
+		</trim>
+		<trim prefix="values (" suffix=")" suffixOverrides=",">
+			<if test="id != null and id != ''">#{id},</if>
+			<if test="productArchiveId != null">#{productArchiveId},</if>
+			<if test="title != null and title != ''">#{title},</if>
+			<if test="type != null and type != ''">#{type},</if>
+			<if test="content != null and content != ''">#{content},</if>
+			<if test="stageStatus != null">#{stageStatus},</if>
+			<if test="allStatus != null">#{allStatus},</if>
+			<if test="labelIds != null and labelIds != ''">#{labelIds},</if>
+			<if test="addTime != null">#{addTime},</if>
+			<if test="createBy != null and createBy != ''">#{createBy},</if>
+			<if test="spId != null">#{spId},</if>
+		</trim>
+	</insert>
+
+	<update id="updateCmProductArchiveContent" parameterType="CmProductArchiveVO">
+		update cm_product_archive_content
+		<trim prefix="SET" suffixOverrides=",">
+			<if test="productArchiveId != null">productArchiveId = #{productArchiveId},</if>
+			<if test="title != null and title != ''">title = #{title},</if>
+			<if test="type != null and type != ''">type = #{type},</if>
+			<if test="content != null and content != ''">content = #{content},</if>
+			<if test="stageStatus != null">stageStatus = #{stageStatus},</if>
+			<if test="allStatus != null">allStatus = #{allStatus},</if>
+			<if test="labelIds != null and labelIds != ''">labelIds = #{labelIds},</if>
+			<if test="addTime != null">addTime = #{addTime},</if>
+			<if test="createBy != null and createBy != ''">createBy = #{createBy},</if>
+			<if test="spId != null">spId = #{spId},</if>
+		</trim>
+		where id = #{id}
+	</update>
+
+	<delete id="delCmProductArchiveContentById" parameterType="String">
+		delete
+		from cm_product_archive_content
+		where id = #{id}
+	</delete>
+	<select id="findKeyWordList" resultType="KeyPo">
+		SELECT cusf.id as k, cusf.keyword as v
+		FROM cm_user_search_frequency cusf
+		WHERE cusf.delStatus = 1
+		<if test="v != null  and v != ''">and cusf.keyword like concat('%', #{v}, '%')</if>
+		ORDER BY cusf.frequency DESC, cusf.searchTime DESC
+	</select>
+
+	<select id="findProductList" resultType="CmProductArchiveVO">
+		SELECT b.name as shopName,
+		a.name as productName,
+		a.`productID` as productId,
+		a.mainImage as image
+		FROM product a
+		LEFT JOIN shop b ON b.shopID = a.shopID
+		left join cm_organize_product_info copi on copi.productId = a.productID
+		WHERE copi.organizeId = 0
+		AND copi.validFlag = 2
+		AND a.productCategory = 1
+		AND a.shopID not in (SELECT s.`value` FROM `sys_dict` s WHERE s.type = 'heheShopID')
+		AND a.productID NOT IN (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069)
+		<if test="productId != null ">and a.productId = #{productId}</if>
+		<if test="productName != null  and productName != ''">and a.name like concat('%', #{productName}, '%')</if>
+		<if test="shopName != null  and shopName != ''">and b.name like concat('%', #{shopName}, '%')</if>
+		group by a.productID
+		order by a.productID desc
+	</select>
+</mapper>

+ 7 - 3
src/main/resources/mapper/PageMapper.xml

@@ -651,6 +651,7 @@
         from cm_product_archive_content
         from cm_product_archive_content
         where productArchiveId = #{archiveId}
         where productArchiveId = #{archiveId}
           and type = 1
           and type = 1
+          and stageStatus=1
         order by addTime desc
         order by addTime desc
     </select>
     </select>
 
 
@@ -659,6 +660,8 @@
         from cm_product_archive_content
         from cm_product_archive_content
         where productArchiveId = #{archiveId}
         where productArchiveId = #{archiveId}
           and type = 2
           and type = 2
+          and stageStatus=1
+
         order by addTime desc
         order by addTime desc
     </select>
     </select>
 
 
@@ -667,6 +670,8 @@
         from cm_product_archive_content
         from cm_product_archive_content
         where productArchiveId = #{archiveId}
         where productArchiveId = #{archiveId}
           and type = 3
           and type = 3
+          and stageStatus=1
+
         order by addTime desc
         order by addTime desc
     </select>
     </select>
 
 
@@ -677,7 +682,7 @@
     </select>
     </select>
 
 
     <select id="getArchiveFile" resultType="com.caimei365.commodity.model.po.ArchiveFilePo">
     <select id="getArchiveFile" resultType="com.caimei365.commodity.model.po.ArchiveFilePo">
-        select fileName, if(cc.type = 2, ossName, ifnull(waterOssName, ossName)) as ossName, uploadTime
+        select fileName, ifnull(waterOssName, ossName) as ossName, uploadTime
         from cm_product_archive_file cf
         from cm_product_archive_file cf
                  left join cm_product_archive_content cc on cf.archiveContentId = cc.id
                  left join cm_product_archive_content cc on cf.archiveContentId = cc.id
         where archiveContentId = #{archiveContentId}
         where archiveContentId = #{archiveContentId}
@@ -689,11 +694,10 @@
                if(cpa.productId is not null, p.name, cpa.productName)       AS "productName",
                if(cpa.productId is not null, p.name, cpa.productName)       AS "productName",
                if(cpa.productId is not null, s.name, cpa.shopName)          AS "shopName",
                if(cpa.productId is not null, s.name, cpa.shopName)          AS "shopName",
                if(cpa.productId is not null, p.mainImage, cpa.productImage) AS "productImage",
                if(cpa.productId is not null, p.mainImage, cpa.productImage) AS "productImage",
-               cpa.archiveLevel                                             AS "archiveLevel",
                if(cpa.productId is not null, ifnull(p.commodityType, cpa.productType),
                if(cpa.productId is not null, ifnull(p.commodityType, cpa.productType),
                   cpa.productType)                                          AS "productType",
                   cpa.productType)                                          AS "productType",
                cpa.productClassify                                          AS "productClassify",
                cpa.productClassify                                          AS "productClassify",
-                cpa.labelIds                                                AS "labelIds"
+               (SELECT  GROUP_CONCAT(cpac.labelIds) from cm_product_archive_content cpac WHERE cpac.productArchiveId=cpa.id)  AS "labelIds"
         from cm_product_archive cpa
         from cm_product_archive cpa
                  left join product p on cpa.productId = p.productID
                  left join product p on cpa.productId = p.productID
                  left join shop s on p.shopID = s.shopID
                  left join shop s on p.shopID = s.shopID