zhijiezhao vor 2 Jahren
Ursprung
Commit
0d15aa8523

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

@@ -4,6 +4,8 @@ import com.caimei365.user.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * Description
  *
@@ -132,4 +134,6 @@ public interface BaseMapper {
      * 查询敏感词
      */
     String getSensitiveWords(Integer checkPoint);
+
+    List<String> findLabelsByLableIds(String labelIds);
 }

+ 3 - 0
src/main/java/com/caimei365/user/model/dto/ShopArticleDto.java

@@ -57,4 +57,7 @@ public class ShopArticleDto{
 
     @ApiModelProperty("文章上线状态:1待上线,2已上线,3已下线")
 	private Integer onlineStatus;
+
+	@ApiModelProperty("关联标签库Ids")
+	private String labelIds;
 }

+ 4 - 0
src/main/java/com/caimei365/user/model/po/ArticlePo.java

@@ -12,6 +12,10 @@ import lombok.Data;
  */
 @Data
 public class ArticlePo {
+	/**
+	 * 关联标签库ids
+	 */
+	private String labelIds;
 	/**
 	 * 文章id
 	 */

+ 9 - 0
src/main/java/com/caimei365/user/model/vo/ShopArticleVo.java

@@ -3,6 +3,7 @@ package com.caimei365.user.model.vo;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 
 /**
@@ -12,6 +13,14 @@ import java.util.Date;
  */
 @Data
 public class ShopArticleVo {
+	/**
+	 * 关联标签库标签
+	 */
+	private List<String> labels;
+	/**
+	 * 关联标签库id
+	 */
+	private String labelIds;
 	/**
 	 * 文章id
 	 */

+ 57 - 52
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -61,8 +61,7 @@ public class ShopServiceImpl implements ShopService {
      * 根据用户Id查询供应商资料
      *
      * @param userId 用户Id
-     *
-     * @return Map(userPo,clubPo)
+     * @return Map(userPo, clubPo)
      */
     @Override
     public ResponseJson<Map<String, Object>> getShopUserInfo(Integer userId) {
@@ -126,39 +125,39 @@ public class ShopServiceImpl implements ShopService {
     /**
      * 修改供应商资料
      *
-     * @param shopUpdateDto ShopUpdateDto{
-     *                        shopId                    供应商Id
-     *                        userId                    用户Id
-     *                        name                      组织名称
-     *                        shortName                     供应商公司简称(shortName)
-     *                        email                     邮箱
-     *                        contractPhone             固定电话
-     *                        linkMan                   联系人
-     *                        provinceId                省(provinceID)
-     *                        cityId                    市(cityID)
-     *                        townId                    所在县区Id(townID)
-     *                        address                   地址
-     *                        socialCreditCode          统一社会信用代码(营业执照编号)
-     *                        businessLicense           营业执照(businessLicenseImage)
-     *                        firstShopType             医疗=1和非医疗=2
-     *                        secondShopType            医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
-     *                        mainProduct               主打项目(mainpro)
-     *                        mainProductDesc           主打商品说明(productDesc)
-     *                        legalPerson               法人代表
-     *                        registeredCapital         注册资本
-     *                        faxNumber                 传真号(fax)
-     *                        companyNature             传真号(nature)
-     *                        turnover                  年营业额
-     *                        medicalPracticeLicenseImg 医疗执业许可证(medicalPracticeLicenseImg1)
-     *                        shopDesc                  公司介绍(info)
-     *                        businessScope             经营范围
-     *                        logo                      公司LOGO
-     *                    }
-     * @param operationLicence          生产经营证书(productionLicence)
-     * @param hygienicLicense           卫生许可证
-     * @param taxLicense                税务登记证
-     * @param honorCertification        荣誉证书(certificateHonor)
-     * @param productCertification      产品证书
+     * @param shopUpdateDto        ShopUpdateDto{
+     *                             shopId                    供应商Id
+     *                             userId                    用户Id
+     *                             name                      组织名称
+     *                             shortName                     供应商公司简称(shortName)
+     *                             email                     邮箱
+     *                             contractPhone             固定电话
+     *                             linkMan                   联系人
+     *                             provinceId                省(provinceID)
+     *                             cityId                    市(cityID)
+     *                             townId                    所在县区Id(townID)
+     *                             address                   地址
+     *                             socialCreditCode          统一社会信用代码(营业执照编号)
+     *                             businessLicense           营业执照(businessLicenseImage)
+     *                             firstShopType             医疗=1和非医疗=2
+     *                             secondShopType            医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
+     *                             mainProduct               主打项目(mainpro)
+     *                             mainProductDesc           主打商品说明(productDesc)
+     *                             legalPerson               法人代表
+     *                             registeredCapital         注册资本
+     *                             faxNumber                 传真号(fax)
+     *                             companyNature             传真号(nature)
+     *                             turnover                  年营业额
+     *                             medicalPracticeLicenseImg 医疗执业许可证(medicalPracticeLicenseImg1)
+     *                             shopDesc                  公司介绍(info)
+     *                             businessScope             经营范围
+     *                             logo                      公司LOGO
+     *                             }
+     * @param operationLicence     生产经营证书(productionLicence)
+     * @param hygienicLicense      卫生许可证
+     * @param taxLicense           税务登记证
+     * @param honorCertification   荣誉证书(certificateHonor)
+     * @param productCertification 产品证书
      * @return ClubUpdateDto
      */
     @Override
@@ -293,7 +292,7 @@ public class ShopServiceImpl implements ShopService {
     public ResponseJson<Void> saveShopHomeImages(ShopBannerDto shopBannerDto) {
         ShopBannerVo shopBanner = new ShopBannerVo();
         BeanUtils.copyProperties(shopBannerDto, shopBanner);
-        if (null != shopBannerDto.getId()){
+        if (null != shopBannerDto.getId()) {
             // 更新
             shopBanner.setId(shopBannerDto.getId());
             shopMapper.updateShopHomeImage(shopBanner);
@@ -311,7 +310,7 @@ public class ShopServiceImpl implements ShopService {
     /**
      * 供应商-删除轮播图片
      *
-     * @param id  图片id
+     * @param id 图片id
      */
     @Override
     public ResponseJson<Void> deleteShopHomeImages(Integer id) {
@@ -375,9 +374,9 @@ public class ShopServiceImpl implements ShopService {
         // 9.已下架数量
         Integer downNum = shopMapper.getShopProductCount(user.getShopId(), 3);
         result.put("downNum", downNum);
-        Jedis jedis=new Jedis("172.31.165.27", 6379);
+        Jedis jedis = new Jedis("172.31.165.27", 6379);
         jedis.auth("6#xsI%b4o@5c3RoE");
-        jedis.lpush("constraint","1");
+        jedis.lpush("constraint", "1");
         result.put("constraint", jedis.rpop("constraint"));
 
         // 10.单品销售排名
@@ -421,13 +420,13 @@ public class ShopServiceImpl implements ShopService {
     }
 
     /**
-     *constraint加入缓存
+     * constraint加入缓存
      */
     @Scheduled(cron = "0 0 23 * * ?")
     public void Open() {
-        Jedis jedis=new Jedis("172.31.165.27", 6379);
+        Jedis jedis = new Jedis("172.31.165.27", 6379);
         jedis.auth("6#xsI%b4o@5c3RoE");
-        jedis.lpush("constraint","0");
+        jedis.lpush("constraint", "0");
     }
 
     @Override
@@ -439,6 +438,12 @@ public class ShopServiceImpl implements ShopService {
         List<ArticleTypeVo> articleTypeList = articleMapper.getArticleTypeList();
         // 文章标签列表
         String articleLabels = articleMapper.getArticleLabelList();
+        // 文章关联的标签库
+        if (StringUtils.isNotBlank(shopArticle.getLabelIds())) {
+            String labelIds = shopArticle.getLabelIds();
+            List<String> labels = baseMapper.findLabelsByLableIds(labelIds);
+            shopArticle.setLabels(labels);
+        }
         map.put("shopArticle", shopArticle);
         map.put("articleTypeList", articleTypeList);
         map.put("articleLabels", articleLabels);
@@ -513,7 +518,7 @@ public class ShopServiceImpl implements ShopService {
             articleMapper.insertArticlePraise(articlePo.getArticleId());
             // 新增文章 百度链接实时推送
             if ("prod".equals(active)) {
-                GenerateUtils.pushBaiduLink("https://www.caimei365.com/info/detail-"+articlePo.getArticleId()+"-1.html");
+                GenerateUtils.pushBaiduLink("https://www.caimei365.com/info/detail-" + articlePo.getArticleId() + "-1.html");
             }
         }
         return ResponseJson.success(null);
@@ -594,8 +599,8 @@ public class ShopServiceImpl implements ShopService {
         // 保存参数
         JSONArray paramArray = JSONArray.parseArray(baikeProductDto.getParamList());
         if (null != paramArray) {
-            paramArray.forEach(paramObject->{
-                Map<String,String> paramMap = (Map<String,String>) paramObject;
+            paramArray.forEach(paramObject -> {
+                Map<String, String> paramMap = (Map<String, String>) paramObject;
                 String name = paramMap.get("name");
                 String content = paramMap.get("content");
                 if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(content)) {
@@ -606,18 +611,18 @@ public class ShopServiceImpl implements ShopService {
         // 保存认证图片
         List<String> authImageList = baikeProductDto.getAuthImageList();
         if (null != authImageList) {
-            authImageList.forEach(authImage-> baikeProductMapper.insertProductImage(authImage, productId, 1));
+            authImageList.forEach(authImage -> baikeProductMapper.insertProductImage(authImage, productId, 1));
         }
         // 保存展示图片
         List<String> displayImageList = baikeProductDto.getDisplayImageList();
         if (null != displayImageList) {
-            displayImageList.forEach(displayImage-> baikeProductMapper.insertProductImage(displayImage, productId, 2));
+            displayImageList.forEach(displayImage -> baikeProductMapper.insertProductImage(displayImage, productId, 2));
         }
         // 保存问题
         JSONArray questionArray = JSONArray.parseArray(baikeProductDto.getQuestionList());
         if (null != questionArray) {
-            questionArray.forEach(questionObject->{
-                Map<String,String> questionMap = (Map<String,String>) questionObject;
+            questionArray.forEach(questionObject -> {
+                Map<String, String> questionMap = (Map<String, String>) questionObject;
                 String question = questionMap.get("question");
                 String answer = questionMap.get("answer");
                 if (StringUtils.isNotEmpty(question) && StringUtils.isNotEmpty(answer)) {
@@ -628,8 +633,8 @@ 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;
+            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");
@@ -722,7 +727,7 @@ public class ShopServiceImpl implements ShopService {
         List<BaikeRecommendVo> manualRecommendList = baikeProductMapper.getManualRecommendList(productId);
         // 自动推荐列表
         List<BaikeRecommendVo> autoRecommendList = baikeProductMapper.getAutoRecommendList(shopId, productTypeId, productId);
-        autoRecommendList.forEach(authRecommend->{
+        autoRecommendList.forEach(authRecommend -> {
             authRecommend.setProductId(productId);
         });
         map.put("manualRecommendList", manualRecommendList);

+ 41 - 24
src/main/resources/mapper/ArticleMapper.xml

@@ -2,7 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.user.mapper.ArticleMapper">
     <delete id="deleteArticle">
-        delete from info where id = #{articleId}
+        delete
+        from info
+        where id = #{articleId}
     </delete>
     <select id="getShopArticleById" resultType="com.caimei365.user.model.vo.ShopArticleVo">
         select id            as articleId,
@@ -15,31 +17,38 @@
                infoContent   as articleContent,
                typeId,
                guidanceImage,
-               enabledStatus as status
+               enabledStatus as status,
+               labelIds
         from info
         where id = #{articleId}
     </select>
     <select id="getArticleTypeList" resultType="com.caimei365.user.model.vo.ArticleTypeVo">
-        select id as typeId, name as typeName from info_type where enabledStatus = '1' and shopUseFlag = 1 order by sort desc,createDate desc
+        select id as typeId, name as typeName
+        from info_type
+        where enabledStatus = '1'
+          and shopUseFlag = 1
+        order by sort desc, createDate desc
     </select>
     <select id="getArticleLabelId" resultType="java.lang.Integer">
-        select id from info_label where name = #{label}
+        select id
+        from info_label
+        where name = #{label}
     </select>
     <select id="getShopArticleList" resultType="com.caimei365.user.model.vo.ShopArticleVo">
-        select i.id            as articleId,
-               title,
-               ip.num as praiseNum,
-               ip.pv as pvNum,
-               publisher,
-               source,
-               it.name as typeName,
-               guidanceImage,
-               i.pubdate as publishDate,
-               i.createDate,
-               i.auditStatus,
-               i.onlineStatus,
-               i.failReason,
-               i.enabledStatus as status
+        select i.id as articleId,
+        title,
+        ip.num as praiseNum,
+        ip.pv as pvNum,
+        publisher,
+        source,
+        it.name as typeName,
+        guidanceImage,
+        i.pubdate as publishDate,
+        i.createDate,
+        i.auditStatus,
+        i.onlineStatus,
+        i.failReason,
+        i.enabledStatus as status
         from info i
         left join info_type it on i.typeId = it.id
         left join info_praise ip on i.id = ip.infoId
@@ -68,16 +77,21 @@
         order by i.createDate desc
     </select>
     <select id="getArticleLabelList" resultType="java.lang.String">
-        select value from sys_dict where type = 'sys_config' limit 1
+        select value
+        from sys_dict
+        where type = 'sys_config'
+        limit 1
     </select>
-    <insert id="insertShopArticle"  parameterType="com.caimei365.user.model.po.ArticlePo" keyProperty="articleId" useGeneratedKeys="true">
+    <insert id="insertShopArticle" parameterType="com.caimei365.user.model.po.ArticlePo" keyProperty="articleId"
+            useGeneratedKeys="true">
         insert into info (typeId, title, label, publisher, source, publishSource, shopId, keyword,
                           recommendContent, infoContent, guidanceImage,
                           recommendStatus, enabledStatus, basePraise, basePv, priorityIndex,
-                          auditStatus, onlineStatus, createDate)
+                          auditStatus, onlineStatus, createDate, labelIds)
         values (#{typeId}, #{title}, #{label}, #{publisher}, #{source}, #{publishSource}, #{shopId},
                 #{keyword}, #{recommendContent}, #{articleContent}, #{guidanceImage}, #{recommendStatus},
-                #{status}, #{basePraise}, #{basePv}, #{priorityIndex}, #{auditStatus}, #{onlineStatus}, NOW())
+                #{status}, #{basePraise}, #{basePv}, #{priorityIndex}, #{auditStatus}, #{onlineStatus}, NOW(),
+                #{labelIds})
     </insert>
     <insert id="insertArticleLabel">
         insert into info_label (name, createDate)
@@ -100,10 +114,13 @@
             guidanceImage    = #{guidanceImage},
             enabledStatus    = #{status},
             auditStatus      = #{auditStatus},
-            onlineStatus     = #{onlineStatus}
+            onlineStatus     = #{onlineStatus},
+            labelIds         = #{labelIds}
         where id = #{articleId}
     </update>
     <update id="updateArticleStatus">
-        update info set enabledStatus = #{status} where id = #{articleId}
+        update info
+        set enabledStatus = #{status}
+        where id = #{articleId}
     </update>
 </mapper>

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

@@ -115,4 +115,12 @@
             and checkPoints like concat('%',#{checkPoint},'%')
         </if>
     </select>
+
+    <select id="findLabelsByLableIds" resultType="java.lang.String">
+        select keyword
+        from cm_user_search_frequency
+        where trueStatus=1
+        and delStatus=1
+        and id in (#{labelIds})
+    </select>
 </mapper>