瀏覽代碼

Merge remote-tracking branch 'origin/developerA' into developerH

Duan_xu 2 年之前
父節點
當前提交
8aff27507a

+ 10 - 4
pom.xml

@@ -102,12 +102,12 @@
         <dependency>
             <groupId>com.aliyun</groupId>
             <artifactId>aliyun-java-sdk-core</artifactId>
-            <version>4.5.18</version>
+            <version>4.0.6</version>
         </dependency>
         <dependency>
             <groupId>com.aliyun</groupId>
             <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
-            <version>2.1.0</version>
+            <version>1.1.0</version>
         </dependency>
         <!--邮箱发送-->
         <dependency>
@@ -160,8 +160,14 @@
         <dependency>
             <groupId>com.aliyun.oss</groupId>
             <artifactId>aliyun-sdk-oss</artifactId>
-            <version>3.12.0</version>
-        </dependency>
+            <version>3.10.2</version>
+        </dependency>
+        <!-- oss获取token -->
+<!--        <dependency>-->
+<!--            <groupId>com.aliyun</groupId>-->
+<!--            <artifactId>aliyun-java-sdk-sts</artifactId>-->
+<!--            <version>3.0.0</version>-->
+<!--        </dependency>-->
     </dependencies>
 
     <profiles>

+ 8 - 0
src/main/java/com/caimei365/user/controller/BaseApi.java

@@ -1,5 +1,6 @@
 package com.caimei365.user.controller;
 
+import com.aliyuncs.exceptions.ClientException;
 import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.MobileDto;
@@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -196,4 +198,10 @@ public class BaseApi {
     public ResponseJson findPackage(){
         return baseService.findPackage();
     }
+
+    @ApiOperation("获取阿里云token")
+    @GetMapping("/oss/token")
+    public ResponseJson<HashMap<String, String>> ossTokenGet() throws ClientException {
+        return baseService.ossTokenGet();
+    }
 }

+ 83 - 1
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -5,6 +5,7 @@ import com.caimei365.user.model.dto.BaikeProductDto;
 import com.caimei365.user.model.dto.ShopArticleDto;
 import com.caimei365.user.model.dto.ShopBannerDto;
 import com.caimei365.user.model.dto.ShopUpdateDto;
+import com.caimei365.user.model.po.BaikeProductPo;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.ShopService;
 import com.github.pagehelper.PageInfo;
@@ -56,7 +57,7 @@ public class ShopApi {
      *                      shopId                    供应商Id
      *                      userId                    用户Id
      *                      name                      组织名称
-     *                      shortName                     供应商公司简称(shortName)
+     *                      shortName                 供应商公司简称(shortName)
      *                      email                     邮箱
      *                      contractPhone             固定电话
      *                      linkMan                   联系人
@@ -236,16 +237,97 @@ public class ShopApi {
     }
 
     @ApiOperation("百科商品分类列表")
+    @ApiImplicitParam(required = true, name = "commodityType",value = "百科分类:1产品,2仪器")
     @GetMapping("/baike/product/type/list")
     public ResponseJson<List<BaikeProductTypeVo>> getBaikeProductTypeList(Integer commodityType){
         return shopService.getBaikeProductTypeList(commodityType);
     }
 
     @ApiOperation("删除百科商品")
+    @ApiImplicitParam(required = true, name = "productId",value = "百科商品id")
     @PostMapping("/baike/product/delete")
     public ResponseJson<Void> deleteBaikeProduct(Integer productId){
         return shopService.deleteBaikeProduct(productId);
     }
 
+    @ApiOperation("查询敏感词")
+    @ApiImplicitParam(required = true, name = "checkPoint", value = "检查位置:1供应商端文章,2供应商端百科,3管理员端文章,4管理员端百科")
+    @GetMapping("/sensitive/words")
+    public ResponseJson<String> getSensitiveWords(Integer checkPoint){
+        if (null == checkPoint) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return shopService.getSensitiveWords(checkPoint);
+    }
+
+    @ApiOperation("百科相关推荐表单")
+    @ApiImplicitParam(required = true, name = "productId", value = "百科产品id")
+    @GetMapping("/baike/recommend/form")
+    public ResponseJson<Map<String,Object>> baikeRecommendForm(Integer productId){
+        return shopService.getBaikeRecommendForm(productId);
+    }
+
+    @ApiOperation("百科相关推荐添加产品列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "productId", value = "百科产品id"),
+            @ApiImplicitParam(required = false, name = "typeId", value = "分类id"),
+            @ApiImplicitParam(required = false, name = "name", value = "名称"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @GetMapping("/baike/recommend/add/list")
+    public ResponseJson<PageInfo<BaikeProductListVo>> addRecommendList(Integer productId, Integer typeId, String name,
+                                                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                     @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        if (null == productId) {
+            return ResponseJson.error("百科产品id不能为空", null);
+        }
+        if (null == typeId) {
+            return ResponseJson.error("分类id不能为空", null);
+        }
+        return shopService.getAddRecommendList(productId, typeId, name, pageNum, pageSize);
+    }
+
+    @ApiOperation("百科相关推荐添加产品")
+    @PostMapping("/baike/recommend/add")
+    public ResponseJson<Void> addBaikeRecommend(BaikeProductDto baikeProduct){
+        if (null == baikeProduct.getProductId()) {
+            return ResponseJson.error("商品id不能为空", null);
+        }
+        return shopService.addBaikeRecommend(baikeProduct);
+    }
+
+    @ApiOperation("百科相关推荐删除产品")
+    @ApiImplicitParam(required = true, name = "recommendId", value = "相关推荐id")
+    @PostMapping("/baike/recommend/delete")
+    public ResponseJson<Void> deleteBaikeRecommend(Integer recommendId){
+        if (null == recommendId) {
+            return ResponseJson.error("相关推荐id不能为空", null);
+        }
+        return shopService.deleBaikeRecommend(recommendId);
+    }
 
+    @ApiOperation("百科相关推荐更改排序")
+    @PostMapping("/baike/recommend/sort/save")
+    public ResponseJson<Void> saveRecommendSort(BaikeRecommendVo baikeRecommend){
+        if (null == baikeRecommend.getRecommendId()) {
+            return ResponseJson.error("相关推荐id不能为空", null);
+        }
+        if (null == baikeRecommend.getSort()) {
+            return ResponseJson.error("排序值不能为空", null);
+        }
+        return shopService.saveRecommendSort(baikeRecommend);
+    }
+
+    @ApiOperation("百科相关推荐更改推荐方式")
+    @PostMapping("/baike/recommend/type/save")
+    public ResponseJson<Void> saveRecommendType(BaikeProductDto baikeProduct){
+        if (null == baikeProduct.getProductId()) {
+            return ResponseJson.error("商品id不能为空", null);
+        }
+        if (null == baikeProduct.getRecommendType()) {
+            return ResponseJson.error("推荐类型不能为空", null);
+        }
+        return shopService.saveRecommendType(baikeProduct);
+    }
 }

+ 24 - 0
src/main/java/com/caimei365/user/mapper/BaikeProductMapper.java

@@ -1,12 +1,14 @@
 package com.caimei365.user.mapper;
 
 import com.caimei365.user.model.dto.BaikeProductDto;
+import com.caimei365.user.model.po.BaikeProductFilePo;
 import com.caimei365.user.model.po.BaikeProductParamPo;
 import com.caimei365.user.model.po.BaikeProductPo;
 import com.caimei365.user.model.po.BaikeProductQuestionPo;
 import com.caimei365.user.model.vo.BaikeProductFormVo;
 import com.caimei365.user.model.vo.BaikeProductListVo;
 import com.caimei365.user.model.vo.BaikeProductTypeVo;
+import com.caimei365.user.model.vo.BaikeRecommendVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -72,4 +74,26 @@ public interface BaikeProductMapper {
     List<String> getImageList(@Param("productId") Integer productId, @Param("imageType") int imageType);
 
     List<BaikeProductQuestionPo> getQuestionList(Integer productId);
+
+    void deleteFilesByProductId(Integer productId);
+
+    void insertProductFile(@Param("fileTitle") String fileTitle, @Param("fileName") String fileName, @Param("ossName") String ossName, @Param("productId") Integer productId);
+
+    List<BaikeProductFilePo> getVideoList(Integer productId);
+
+    List<BaikeRecommendVo> getManualRecommendList(Integer productId);
+
+    List<BaikeRecommendVo> getAutoRecommendList(@Param("shopId") Integer shopId, @Param("productTypeId") Integer productTypeId, @Param("productId") Integer productId);
+
+    void updateRecommendType(Integer productId, Integer recommendType);
+
+    void clearRecommendData(Integer productId);
+
+    void insertRecommend(BaikeRecommendVo recommond);
+
+    String getRecommendProductIds(Integer productId);
+
+    void deleteBaikeRecommend(Integer recommendId);
+
+    void updateRecommendSort(BaikeRecommendVo baikeRecommend);
 }

+ 5 - 0
src/main/java/com/caimei365/user/mapper/BaseMapper.java

@@ -127,4 +127,9 @@ public interface BaseMapper {
      * @param clubId   用户Id
      */
     void updateClubMobileByClubId(String mobile, Integer clubId);
+
+    /**
+     * 查询敏感词
+     */
+    String getSensitiveWords(Integer checkPoint);
 }

+ 14 - 3
src/main/java/com/caimei365/user/model/dto/BaikeProductDto.java

@@ -1,12 +1,10 @@
 package com.caimei365.user.model.dto;
 
-import com.caimei365.user.model.po.BaikeProductParamPo;
-import com.caimei365.user.model.po.BaikeProductQuestionPo;
+import com.caimei365.user.model.vo.BaikeRecommendVo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import java.util.Date;
 import java.util.List;
 
 
@@ -110,4 +108,17 @@ public class BaikeProductDto {
 
 	@ApiModelProperty("问题列表")
 	private String questionList;
+
+	@ApiModelProperty("视频文件列表")
+	private String videoList;
+
+	@ApiModelProperty("已选中的商品id,以,隔开")
+	private String productIds;
+
+	@ApiModelProperty("推荐类型:1手动推荐,2自动推荐")
+	private Integer recommendType;
+
+	@ApiModelProperty("百科相关推荐商品列表")
+    private String baikeRecommendList;
+
 }

+ 33 - 0
src/main/java/com/caimei365/user/model/po/BaikeProductFilePo.java

@@ -0,0 +1,33 @@
+package com.caimei365.user.model.po;
+
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 采美百科商品问题
+ * @author Aslee
+ * @version 2021-12-13
+ */
+@Data
+public class BaikeProductFilePo implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 标题
+	 */
+	private String fileTitle;
+	/**
+	 * 文件名
+	 */
+	private String fileName;
+	/**
+	 * oss名称
+	 */
+	private String ossName;
+	/**
+	 * 链接
+	 */
+	private String fileUrl;
+}

+ 16 - 0
src/main/java/com/caimei365/user/model/vo/BaikeProductFormVo.java

@@ -1,5 +1,6 @@
 package com.caimei365.user.model.vo;
 
+import com.caimei365.user.model.po.BaikeProductFilePo;
 import com.caimei365.user.model.po.BaikeProductParamPo;
 import com.caimei365.user.model.po.BaikeProductQuestionPo;
 import io.swagger.annotations.ApiModel;
@@ -24,6 +25,11 @@ public class BaikeProductFormVo {
 	 */
 	private Integer productId;
 
+	/**
+	 * 供应商id
+	 */
+	private Integer shopId;
+
 	/**
 	 * 分类:1产品,2仪器
 	 */
@@ -158,4 +164,14 @@ public class BaikeProductFormVo {
 	 * 问题列表
 	 */
 	private List<BaikeProductQuestionPo> questionList;
+
+	/**
+	 * 视频列表
+	 */
+	private List<BaikeProductFilePo> videoList;
+
+	/**
+	 * 推荐类型:1手动推荐,2自动推荐
+	 */
+	private Integer recommendType;
 }

+ 45 - 0
src/main/java/com/caimei365/user/model/vo/BaikeRecommendVo.java

@@ -0,0 +1,45 @@
+package com.caimei365.user.model.vo;
+
+import com.caimei365.user.model.po.BaikeProductFilePo;
+import com.caimei365.user.model.po.BaikeProductParamPo;
+import com.caimei365.user.model.po.BaikeProductQuestionPo;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * Description
+ * @author Aslee
+ * @version 2021-12-10
+ */
+@ApiModel("百科商品相关推荐")
+@Data
+public class BaikeRecommendVo {
+	/**
+	 * 相关推荐id
+	 */
+	private Integer recommendId;
+
+	/**
+	 * 百科商品id
+	 */
+	private Integer productId;
+
+	/**
+	 * 相关推荐产品/仪器id
+	 */
+	private Integer recommendProductId;
+
+	/**
+	 * 排序值
+	 */
+	private Integer sort;
+
+	/**
+	 * 相关推荐产品/仪器名称
+	 */
+	private String recommendProductName;
+}

+ 4 - 0
src/main/java/com/caimei365/user/service/BaseService.java

@@ -1,9 +1,11 @@
 package com.caimei365.user.service;
 
+import com.aliyuncs.exceptions.ClientException;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.MobileDto;
 import com.caimei365.user.model.dto.PasswordDto;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -100,4 +102,6 @@ public interface BaseService {
      * @return
      */
     ResponseJson findPackage();
+
+    ResponseJson<HashMap<String, String>> ossTokenGet() throws ClientException;
 }

+ 51 - 1
src/main/java/com/caimei365/user/service/ShopService.java

@@ -155,7 +155,7 @@ public interface ShopService {
 
     /**
      * 获取供应商百科商品表单数据
-     * @param baikeProductId     百科商品id
+     * @param productId     百科商品id
      * @return
      */
     ResponseJson<BaikeProductFormVo> getBaikeProductById(Integer productId);
@@ -187,4 +187,54 @@ public interface ShopService {
      * @return
      */
     ResponseJson<Void> deleteBaikeProduct(Integer productId);
+
+    /**
+     * 查询敏感词
+     * @param checkPoint
+     * @return
+     */
+    ResponseJson<String> getSensitiveWords(Integer checkPoint);
+
+    /**
+     * 获取供应商百科商品相关推荐表单数据
+     * @param productId  百科商品id
+     * @return
+     */
+    ResponseJson<Map<String, Object>> getBaikeRecommendForm(Integer productId);
+
+    /**
+     * 保存百科相关推荐推荐类型
+     * @param baikeProductDto
+     * @return
+     */
+    ResponseJson<Void> saveRecommendType(BaikeProductDto baikeProductDto);
+
+    /**
+     * 百科相关推荐添加产品列表
+     *
+     * @param productId
+     * @return
+     */
+    ResponseJson<PageInfo<BaikeProductListVo>> getAddRecommendList(Integer productId, Integer typeId, String name, int pageNum, int pageSize);
+
+    /**
+     * 添加百科相关推荐
+     * @param baikeRecommend
+     * @return
+     */
+    ResponseJson<Void> addBaikeRecommend(BaikeProductDto baikeProduct);
+
+    /**
+     * 删除百科相关推荐
+     * @param recommendId
+     * @return
+     */
+    ResponseJson<Void> deleBaikeRecommend(Integer recommendId);
+
+    /**
+     * 保存百科相关推荐排序
+     * @param baikeRecommend
+     * @return
+     */
+    ResponseJson<Void> saveRecommendSort(BaikeRecommendVo baikeRecommend);
 }

+ 7 - 0
src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java

@@ -1,5 +1,7 @@
 package com.caimei365.user.service.impl;
 
+import com.aliyun.oss.internal.OSSUtils;
+import com.aliyuncs.exceptions.ClientException;
 import com.caimei365.user.components.CommonService;
 import com.caimei365.user.components.RedisService;
 import com.caimei365.user.mapper.BaseMapper;
@@ -516,6 +518,11 @@ public class BaseServiceImpl implements BaseService {
         return ResponseJson.success(pac);
     }
 
+    @Override
+    public ResponseJson<HashMap<String, String>> ossTokenGet() throws ClientException {
+        return ResponseJson.success(OssUtil.getToken());
+    }
+
     /**
      * 根据userId查是否过期,返回dto对象,flag=0未买过,-1过期,1有效,endTime过期时间
      */

+ 93 - 2
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -15,6 +15,7 @@ import com.caimei365.user.service.ShopService;
 import com.caimei365.user.utils.DateUtil;
 import com.caimei365.user.utils.GenerateUtils;
 import com.caimei365.user.utils.ImageUtils;
+import com.caimei365.user.utils.OssUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -583,11 +584,12 @@ public class ShopServiceImpl implements ShopService {
             baikeProductMapper.updateBaikeProduct(baikeProductPo);
         }
         Integer productId = baikeProductPo.getProductId();
-        // 删除原先的图片/参数/问题数据
+        // 删除原先的图片/参数/问题/视频文件数据
         if (!newProductFlag) {
             baikeProductMapper.deleteParamsByProductId(productId);
             baikeProductMapper.deleteImagesByProductId(productId);
             baikeProductMapper.deleteQuestionsByProductId(productId);
+            baikeProductMapper.deleteFilesByProductId(productId);
         }
         // 保存参数
         JSONArray paramArray = JSONArray.parseArray(baikeProductDto.getParamList());
@@ -609,7 +611,7 @@ public class ShopServiceImpl implements ShopService {
         // 保存展示图片
         List<String> displayImageList = baikeProductDto.getDisplayImageList();
         if (null != displayImageList) {
-            displayImageList.forEach(diplayImage-> baikeProductMapper.insertProductImage(diplayImage, productId, 2));
+            displayImageList.forEach(displayImage-> baikeProductMapper.insertProductImage(displayImage, productId, 2));
         }
         // 保存问题
         JSONArray questionArray = JSONArray.parseArray(baikeProductDto.getQuestionList());
@@ -623,6 +625,19 @@ public class ShopServiceImpl implements ShopService {
                 }
             });
         }
+        // 保存视频文件
+        JSONArray videoArray = JSONArray.parseArray(baikeProductDto.getVideoList());
+        if (null != videoArray) {
+            videoArray.forEach(videoObject->{
+                Map<String,String> videoMap = (Map<String,String>) videoObject;
+                String fileTitle = videoMap.get("fileTitle");
+                String fileName = videoMap.get("fileName");
+                String ossName = videoMap.get("ossName");
+                if (StringUtils.isNotEmpty(ossName)) {
+                    baikeProductMapper.insertProductFile(fileTitle, fileName, ossName, productId);
+                }
+            });
+        }
         return ResponseJson.success(null);
     }
 
@@ -648,6 +663,10 @@ public class ShopServiceImpl implements ShopService {
         // 问题列表
         List<BaikeProductQuestionPo> questionList = baikeProductMapper.getQuestionList(productId);
         baikeProduct.setQuestionList(questionList);
+        // 视频列表
+        List<BaikeProductFilePo> videoList = baikeProductMapper.getVideoList(productId);
+        videoList.forEach(video -> video.setFileUrl(OssUtil.getOssUrl(video.getOssName())));
+        baikeProduct.setVideoList(videoList);
         return ResponseJson.success(baikeProduct);
     }
 
@@ -686,4 +705,76 @@ public class ShopServiceImpl implements ShopService {
         return ResponseJson.success(null);
     }
 
+    @Override
+    public ResponseJson<String> getSensitiveWords(Integer checkPoint) {
+        String sensitiveWords = baseMapper.getSensitiveWords(checkPoint);
+        return ResponseJson.success(sensitiveWords);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> getBaikeRecommendForm(Integer productId) {
+        HashMap<String, Object> map = new HashMap<>();
+        BaikeProductFormVo baikeProduct = baikeProductMapper.getBaikeProductById(productId);
+        Integer productTypeId = baikeProduct.getTypeId();
+        Integer recommendType = baikeProduct.getRecommendType();
+        Integer shopId = baikeProduct.getShopId();
+        // 手动推荐列表
+        List<BaikeRecommendVo> manualRecommendList = baikeProductMapper.getManualRecommendList(productId);
+        // 自动推荐列表
+        List<BaikeRecommendVo> autoRecommendList = baikeProductMapper.getAutoRecommendList(shopId, productTypeId, productId);
+        autoRecommendList.forEach(authRecommend->{
+            authRecommend.setProductId(productId);
+        });
+        map.put("manualRecommendList", manualRecommendList);
+        map.put("autoRecommendList", autoRecommendList);
+        map.put("recommendType", recommendType);
+        return ResponseJson.success(map);
+    }
+
+    @Override
+    public ResponseJson<Void> saveRecommendType(BaikeProductDto baikeProductDto) {
+        baikeProductMapper.updateRecommendType(baikeProductDto.getProductId(), baikeProductDto.getRecommendType());
+        return ResponseJson.success(null);
+    }
+
+    @Override
+    public ResponseJson<PageInfo<BaikeProductListVo>> getAddRecommendList(Integer productId, Integer typeId, String name, int pageNum, int pageSize) {
+        BaikeProductDto baikeProductDto = new BaikeProductDto();
+        baikeProductDto.setTypeId(typeId);
+        baikeProductDto.setName(name);
+        BaikeProductFormVo baikeProduct = baikeProductMapper.getBaikeProductById(productId);
+        baikeProductDto.setShopId(baikeProduct.getShopId());
+        // 已推荐产品id,以,隔开
+        String productIds = baikeProductMapper.getRecommendProductIds(productId);
+        productIds += "".equals(productIds) ? productId : "," + productId;
+        baikeProductDto.setProductIds(productIds);
+        PageHelper.startPage(pageNum, pageSize);
+        List<BaikeProductListVo> addRecommendList = baikeProductMapper.getBaikeProductList(baikeProductDto);
+        PageInfo<BaikeProductListVo> pageInfo = new PageInfo<>(addRecommendList);
+        return ResponseJson.success(pageInfo);
+    }
+
+    @Override
+    public ResponseJson<Void> addBaikeRecommend(BaikeProductDto baikeProduct) {
+        String baikeRecommendList = baikeProduct.getBaikeRecommendList();
+        List<BaikeRecommendVo> recommendList = JSONObject.parseArray(baikeRecommendList, BaikeRecommendVo.class);
+        recommendList.forEach(baikeRecommend -> {
+            baikeRecommend.setProductId(baikeProduct.getProductId());
+            baikeProductMapper.insertRecommend(baikeRecommend);
+        });
+        return ResponseJson.success(null);
+    }
+
+    @Override
+    public ResponseJson<Void> deleBaikeRecommend(Integer recommendId) {
+        baikeProductMapper.deleteBaikeRecommend(recommendId);
+        return ResponseJson.success(null);
+    }
+
+    @Override
+    public ResponseJson<Void> saveRecommendSort(BaikeRecommendVo baikeRecommend) {
+        baikeProductMapper.updateRecommendSort(baikeRecommend);
+        return ResponseJson.success(null);
+    }
+
 }

+ 1 - 1
src/main/java/com/caimei365/user/utils/AliyunSmsUtil.java

@@ -110,7 +110,7 @@ public class AliyunSmsUtil {
             //请求成功
             return sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode());
         } catch (ClientException e) {
-            log.error(e.getErrCode(), e.getErrMsg(), e.getErrorDescription());
+            log.error(e.getErrCode(), e.getErrMsg(), e.getMessage());
             return false;
         }
     }

+ 81 - 0
src/main/java/com/caimei365/user/utils/OssUtil.java

@@ -5,6 +5,14 @@ import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.model.GetObjectRequest;
 import com.aliyun.oss.model.ObjectMetadata;
 import com.aliyun.oss.model.UploadFileRequest;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.auth.sts.AssumeRoleRequest;
+import com.aliyuncs.auth.sts.AssumeRoleResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+import com.aliyuncs.profile.IClientProfile;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -12,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.IOException;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.UUID;
 
 
@@ -35,6 +44,78 @@ public class OssUtil {
     }
 
 
+    public static HashMap<String, String> getToken() {
+        //构建一个阿里云客户端,用于发起请求。
+        //设置调用者(RAM用户或RAM角色)的AccessKey ID和AccessKey Secret。
+//        DefaultProfile.addEndpoint("oss-cn-shenzhen", "Sts", endpoint.replace("https://",""));
+        DefaultProfile profile = DefaultProfile.getProfile("oss-cn-shenzhen", accessKeyId, accessKeySecret);
+        IAcsClient client = new DefaultAcsClient(profile);
+
+        //构造请求,设置参数。
+        AssumeRoleRequest request = new AssumeRoleRequest();
+        request.setRegionId(endpoint);
+        request.setRoleArn("acs:ram::1565565840178476:role/caimeitst");
+        request.setRoleSessionName("TSTtest");
+        AssumeRoleResponse response = null;
+        try {
+            response = client.getAcsResponse(request);
+        } catch (ClientException e) {
+            e.printStackTrace();
+        }
+        String requestId = response.getRequestId();
+        String securityToken = response.getCredentials().getSecurityToken();
+        String accessKeySecret = response.getCredentials().getAccessKeySecret();
+        String accessKeyId = response.getCredentials().getAccessKeyId();
+        HashMap<String, String> tokenMap = new HashMap<>(5);
+        tokenMap.put("requestId", requestId);
+        tokenMap.put("accessKeyId", accessKeyId);
+        tokenMap.put("accessKeySecret", accessKeySecret);
+        tokenMap.put("securityToken", securityToken);
+        tokenMap.put("bucket", privateBucket);
+        return tokenMap;
+    }
+
+
+    /*public static HashMap<String, String> getToken() throws ClientException {
+        // regionId表示RAM的地域ID。以华东1(杭州)地域为例,regionID填写为cn-hangzhou。也可以保留默认值,默认值为空字符串("")。
+        String regionId = "";
+        // 添加endpoint。适用于Java SDK 3.12.0及以上版本。
+        DefaultProfile.addEndpoint(regionId, "Sts", endpoint.replace("https://",""));
+        // 添加endpoint。适用于Java SDK 3.12.0以下版本。
+        // DefaultProfile.addEndpoint("",regionId, "Sts", endpoint);
+        // 构造default profile。
+        IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
+        // 构造client。
+        DefaultAcsClient client = new DefaultAcsClient(profile);
+        final AssumeRoleRequest request = new AssumeRoleRequest();
+        // 适用于Java SDK 3.12.0及以上版本。
+        request.setSysMethod(MethodType.POST);
+        // 适用于Java SDK 3.12.0以下版本。
+        //request.setMethod(MethodType.POST);
+        request.setRoleArn("acs:ram::1565565840178476:role/caimeitst");
+        request.setRoleSessionName("TSTtest");
+        request.setPolicy();
+//        request.setPolicy(null); // 如果policy为空,则用户将获得该角色下所有权限。
+        request.setDurationSeconds(3600L); // 设置临时访问凭证的有效时间为3600秒。
+        final AssumeRoleResponse response = client.getAcsResponse(request);
+        System.out.println("Expiration: " + response.getCredentials().getExpiration());
+        System.out.println("Access Key Id: " + response.getCredentials().getAccessKeyId());
+        System.out.println("Access Key Secret: " + response.getCredentials().getAccessKeySecret());
+        System.out.println("Security Token: " + response.getCredentials().getSecurityToken());
+        System.out.println("RequestId: " + response.getRequestId());
+
+        String requestId = response.getRequestId();
+        String securityToken = response.getCredentials().getSecurityToken();
+        String accessKeySecret = response.getCredentials().getAccessKeySecret();
+        String accessKeyId = response.getCredentials().getAccessKeyId();
+        HashMap<String, String> tokenMap = new HashMap<>(5);
+        tokenMap.put("requestId", requestId);
+        tokenMap.put("accessKeyId", accessKeyId);
+        tokenMap.put("accessKeySecret", accessKeySecret);
+        tokenMap.put("securityToken", securityToken);
+        tokenMap.put("bucket", privateBucket);
+        return tokenMap;
+    }*/
 
     public static String ossUpload(String fileName, File file, String contentType) {
         String url = null;

+ 80 - 1
src/main/resources/mapper/BaikeProductMapper.xml

@@ -26,6 +26,18 @@
         insert into cm_baike_product_question (productId, question, answer)
         values (#{productId}, #{question}, #{answer})
     </insert>
+    <insert id="insertProductFile">
+        insert into cm_baike_product_file (productId, fileTitle, fileName, ossName)
+        values (#{productId}, #{fileTitle}, #{fileName}, #{ossName})
+    </insert>
+    <insert id="insertRecommend">
+        INSERT INTO cm_baike_product_recommend(productId,
+                                               recommendProductId,
+                                               sort)
+        VALUES (#{productId},
+                #{recommendProductId},
+                #{sort})
+    </insert>
     <update id="updateBaikeProduct">
         update cm_baike_product
         set name            = #{name},
@@ -60,6 +72,14 @@
     <update id="deleteBaikeProduct">
         update cm_baike_product set delFlag = 1 where id = #{productId}
     </update>
+    <update id="updateRecommendType">
+        update cm_baike_product
+        set recommendType = #{recommendType}
+        where id = #{productId}
+    </update>
+    <update id="updateRecommendSort">
+        update cm_baike_product_recommend set sort = #{sort} where id = #{recommendId}
+    </update>
     <delete id="deleteParamsByProductId">
         delete from cm_baike_product_param where productId = #{productId}
     </delete>
@@ -69,8 +89,22 @@
     <delete id="deleteQuestionsByProductId">
         delete from cm_baike_product_question where productId = #{productId}
     </delete>
+    <delete id="deleteFilesByProductId">
+        delete from cm_baike_product_file where productId = #{productId}
+    </delete>
+    <delete id="clearRecommendData">
+        delete
+        from cm_baike_product_recommend
+        where productId = #{productId}
+    </delete>
+    <delete id="deleteBaikeRecommend">
+        delete
+        from cm_baike_product_recommend
+        where id = #{recommendId}
+    </delete>
     <select id="getBaikeProductById" resultType="com.caimei365.user.model.vo.BaikeProductFormVo">
         select id as productId,
+               shopId,
                commodityType,
                name,
                alias,
@@ -92,6 +126,7 @@
                unAdaptiveMan,
                aroundOperation,
                typeId,
+               recommendType,
                status
         from cm_baike_product
         where id = #{productId} and delFlag = 0
@@ -113,7 +148,10 @@
                p.status
         from cm_baike_product p
                  left join cm_baike_type cbt on p.typeId = cbt.id
-        where shopId = #{shopId} and publishSource = 2 and commodityType = #{commodityType} and delFlag = 0
+        where shopId = #{shopId} and publishSource = 2 and delFlag = 0
+        <if test="commodityType != null">
+            and p.commodityType = #{commodityType}
+        </if>
         <if test="productId != null">
             and p.id = #{productId}
         </if>
@@ -132,6 +170,12 @@
         <if test="onlineStatus != null">
             and onlineStatus = #{onlineStatus}
         </if>
+        <if test="productIds != null and productIds != ''">
+            and p.id not in
+            <foreach item="productId" collection="productIds.split(',')" open="(" separator="," close=")">
+                #{productId}
+            </foreach>
+        </if>
         order by p.addTime desc
     </select>
     <select id="getParamList" resultType="com.caimei365.user.model.po.BaikeProductParamPo">
@@ -145,4 +189,39 @@
         from cm_baike_product_question
         where productId = #{productId}
     </select>
+    <select id="getVideoList" resultType="com.caimei365.user.model.po.BaikeProductFilePo">
+        select fileTitle, fileName, ossName
+        from cm_baike_product_file
+        where productId = #{productId}
+    </select>
+    <select id="getManualRecommendList" resultType="com.caimei365.user.model.vo.BaikeRecommendVo">
+        select cbpr.id as recommendId, productId, recommendProductId, p.name as recommendProductName, sort
+        from cm_baike_product_recommend cbpr
+                 left join cm_baike_product p on cbpr.recommendProductId = p.id
+        where productId = #{productId}
+          and p.delFlag = 0
+        order by -cbpr.sort desc
+    </select>
+    <select id="getAutoRecommendList" resultType="com.caimei365.user.model.vo.BaikeRecommendVo">
+        select p.id as recommendProductId, p.name as recommendProductName
+        from cm_baike_product p
+        where typeId = #{productTypeId}
+          <if test="shopId != null">
+              and shopId = #{shopId}
+          </if>
+          <if test="productId != null">
+              and id != #{productId}
+          </if>
+          and p.delFlag = 0
+          and p.status = 1
+          and p.onlineStatus = 2
+        order by p.addTime desc
+        limit 15
+    </select>
+    <select id="getRecommendProductIds" resultType="java.lang.String">
+        select group_concat(recommendProductId)
+        from cm_baike_product_recommend
+        where productId = #{productId}
+        group by productId;
+    </select>
 </mapper>

+ 8 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -104,4 +104,12 @@
     <select id="getAfterSalesPhone" resultType="java.lang.String">
         select contactNumber from cm_mall_organize where id = 0 and delFlag = '0'
     </select>
+    <select id="getSensitiveWords" resultType="java.lang.String">
+        select words
+        from cm_sensitive_words
+        where id = 1 and status = 1
+        <if test="checkPoint != null">
+            and checkPoints like concat('%',#{checkPoint},'%')
+        </if>
+    </select>
 </mapper>