Ver Fonte

供应商文章part2

Aslee há 3 anos atrás
pai
commit
be272ac92f

+ 18 - 8
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -4,6 +4,7 @@ import com.caimei365.user.model.ResponseJson;
 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.vo.ArticleTypeVo;
 import com.caimei365.user.model.vo.ShopArticleVo;
 import com.caimei365.user.model.vo.ShopBannerVo;
 import com.caimei365.user.model.vo.ShopHomeVo;
@@ -172,7 +173,7 @@ public class ShopApi {
 
     @ApiOperation("供应商文章表单")
     @ApiImplicitParam(required = true, name = "articleId",value = "文章id")
-    @PostMapping("/article/form")
+    @GetMapping("/article/form")
     public ResponseJson<Map<String,Object>> shopArticleForm(Integer articleId) {
         return shopService.getShopArticleById(articleId);
     }
@@ -184,16 +185,11 @@ public class ShopApi {
     }
 
     @ApiOperation("供应商文章列表")
-    @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "shopId",value = "供应商id"),
-        @ApiImplicitParam(name = "pageNum", required = true, value = "页码"),
-        @ApiImplicitParam(name = "pageSize", required = true, value = "每页数量")
-    })
     @GetMapping("/article/list")
-    public ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(Integer shopId,
+    public ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(ShopArticleDto shopArticleDto,
                                                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                     @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
-        return shopService.getShopArticleList(shopId, pageNum, pageSize);
+        return shopService.getShopArticleList(shopArticleDto, pageNum, pageSize);
     }
 
     @ApiOperation("更新供应商文章状态")
@@ -201,4 +197,18 @@ public class ShopApi {
     public ResponseJson<Void> updateArticleStatus(ShopArticleDto shopArticleDto) {
         return shopService.updateArticleStatus(shopArticleDto);
     }
+
+    @ApiOperation("文章分类列表")
+    @GetMapping("/article/type/list")
+    public ResponseJson<List<ArticleTypeVo>> getArticleTypeList(){
+        return shopService.getArticleTypeList();
+    }
+
+    @ApiOperation("删除文章")
+    @PostMapping("/article/delete")
+    public ResponseJson<Void> deleteArticle(Integer articleId){
+        return shopService.deleteArticle(articleId);
+    }
+
+
 }

+ 15 - 2
src/main/java/com/caimei365/user/mapper/ArticleMapper.java

@@ -1,5 +1,6 @@
 package com.caimei365.user.mapper;
 
+import com.caimei365.user.model.dto.ShopArticleDto;
 import com.caimei365.user.model.po.ArticlePo;
 import com.caimei365.user.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
@@ -46,11 +47,23 @@ public interface ArticleMapper {
     void insertArticlePraise(Integer articleId);
     /**
      * 查询供应商文章列表
+     * @param shopArticleDto
      */
-    List<ShopArticleVo> getShopArticleList(Integer shopId);
+    List<ShopArticleVo> getShopArticleList(ShopArticleDto shopArticleDto);
 
     /**
      * 更新供应商文章状态
      */
-    void updateArticleStatus(@Param("articleId") Integer articleId, @Param("status") String status);
+    void updateArticleStatus(@Param("articleId") Integer articleId, @Param("status") Integer status);
+
+    /**
+     * 查询文章标签
+     */
+    String getArticleLabelList();
+
+    /**
+     * 删除文章
+     * @param articleId
+     */
+    void deleteArticle(Integer articleId);
 }

+ 7 - 1
src/main/java/com/caimei365/user/model/dto/ShopArticleDto.java

@@ -47,5 +47,11 @@ public class ShopArticleDto{
 	private String guidanceImage;
 
 	@ApiModelProperty("状态:0停用,1启用")
-	private String status;
+	private Integer status;
+
+    @ApiModelProperty("供应商名称")
+    private String shopName;
+
+    @ApiModelProperty("审核状态:1待审核,2审核通过,3审核失败")
+	private Integer auditStatus;
 }

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

@@ -70,7 +70,7 @@ public class ArticlePo {
 	/**
 	 * 状态:0停用,1启用
 	 */
-	private String status;
+	private Integer status;
 
 	/**
 	 * 文章发布来源:1采美,2供应商

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

@@ -80,7 +80,7 @@ public class ShopArticleVo {
 	/**
 	 * 状态:0停用,1启用
 	 */
-	private String status;
+	private Integer status;
 
 	/**
 	 * 审核状态:1待审核,2审核通过,3审核失败

+ 16 - 2
src/main/java/com/caimei365/user/service/ShopService.java

@@ -5,6 +5,7 @@ import com.caimei365.user.model.ResponseJson;
 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.vo.ArticleTypeVo;
 import com.caimei365.user.model.vo.ShopArticleVo;
 import com.caimei365.user.model.vo.ShopBannerVo;
 import com.caimei365.user.model.vo.ShopHomeVo;
@@ -122,15 +123,28 @@ public interface ShopService {
 
     /**
      * 根据供应商id查询供应商文章列表
-     * @param shopId    供应商id
+     * @param shopArticleDto    供应商id
      * @param pageNum
      * @param pageSize
      * @return
      */
-    ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(Integer shopId, int pageNum, int pageSize);
+    ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(ShopArticleDto shopArticleDto, int pageNum, int pageSize);
 
     /**
      * 更改供应商文章状态
      */
     ResponseJson<Void> updateArticleStatus(ShopArticleDto shopArticleDto);
+
+    /**
+     * 获取文章分类列表
+     * @return
+     */
+    ResponseJson<List<ArticleTypeVo>> getArticleTypeList();
+
+    /**
+     * 删除文章
+     * @param articleId 文章id
+     * @return
+     */
+    ResponseJson<Void> deleteArticle(Integer articleId);
 }

+ 31 - 5
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -49,6 +49,8 @@ public class ShopServiceImpl implements ShopService {
     private ArticleMapper articleMapper;
     @Resource
     private PersonalCenterMapper personalCenterMapper;
+    @Value("${spring.cloud.config.profile}")
+    private String active;
 
 
     /**
@@ -415,14 +417,20 @@ public class ShopServiceImpl implements ShopService {
         ShopArticleVo shopArticle = articleMapper.getShopArticleById(articleId);
         // 文章分类列表
         List<ArticleTypeVo> articleTypeList = articleMapper.getArticleTypeList();
+        // 文章标签列表
+        String articleLabels = articleMapper.getArticleLabelList();
         map.put("shopArticle", shopArticle);
         map.put("articleTypeList", articleTypeList);
+        map.put("articleLabels", articleLabels);
         return ResponseJson.success(map);
     }
 
     @Override
     public ResponseJson<Void> saveShopArticle(ShopArticleDto shopArticleDto) {
         // 参数校验
+        if (null == shopArticleDto.getShopId()) {
+            return ResponseJson.error("参数异常,供应商id不能为空", null);
+        }
         if (StringUtils.isEmpty(shopArticleDto.getTitle())) {
             return ResponseJson.error("参数异常,文章标题不能为空", null);
         }
@@ -481,18 +489,20 @@ public class ShopServiceImpl implements ShopService {
             // 新增文章浏览/点赞记录
             articleMapper.insertArticlePraise(articlePo.getArticleId());
             // 新增文章 百度链接实时推送
-            GenerateUtils.pushBaiduLink("https://www.caimei365.com/info/detail-"+articlePo.getArticleId()+"-1.html");
+            if ("prod".equals(active)) {
+                GenerateUtils.pushBaiduLink("https://www.caimei365.com/info/detail-"+articlePo.getArticleId()+"-1.html");
+            }
         }
         return ResponseJson.success(null);
     }
 
     @Override
-    public ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(Integer shopId, int pageNum, int pageSize) {
-        if (null == shopId) {
+    public ResponseJson<PageInfo<ShopArticleVo>> getShopArticleList(ShopArticleDto shopArticleDto, int pageNum, int pageSize) {
+        if (null == shopArticleDto) {
             return ResponseJson.error("参数异常", null);
         }
         PageHelper.startPage(pageNum, pageSize);
-        List<ShopArticleVo> articleList = articleMapper.getShopArticleList(shopId);
+        List<ShopArticleVo> articleList = articleMapper.getShopArticleList(shopArticleDto);
         PageInfo<ShopArticleVo> pageInfo = new PageInfo<>(articleList);
         return ResponseJson.success(pageInfo);
     }
@@ -500,11 +510,27 @@ public class ShopServiceImpl implements ShopService {
     @Override
     public ResponseJson<Void> updateArticleStatus(ShopArticleDto shopArticleDto) {
         Integer articleId = shopArticleDto.getArticleId();
-        String status = shopArticleDto.getStatus();
+        Integer status = shopArticleDto.getStatus();
         if (null == articleId || null == status) {
             return ResponseJson.error("参数异常", null);
         }
         articleMapper.updateArticleStatus(articleId, status);
+        // 更新文章索引
+        commodityFeign.updateArticleIndex(articleId);
+        return ResponseJson.success(null);
+    }
+
+    @Override
+    public ResponseJson<List<ArticleTypeVo>> getArticleTypeList() {
+        List<ArticleTypeVo> articleTypeList = articleMapper.getArticleTypeList();
+        return ResponseJson.success(articleTypeList);
+    }
+
+    @Override
+    public ResponseJson<Void> deleteArticle(Integer articleId) {
+        articleMapper.deleteArticle(articleId);
+        // 更新文章索引
+        commodityFeign.updateArticleIndex(articleId);
         return ResponseJson.success(null);
     }
 }

+ 21 - 0
src/main/resources/mapper/ArticleMapper.xml

@@ -1,6 +1,9 @@
 <?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.user.mapper.ArticleMapper">
+    <delete id="deleteArticle">
+        delete from info where id = #{articleId}
+    </delete>
     <select id="getShopArticleById" resultType="com.caimei365.user.model.vo.ShopArticleVo">
         select id            as articleId,
                title,
@@ -39,8 +42,26 @@
         left join info_type it on i.typeId = it.id
         left join info_praise ip on i.id = ip.infoId
         where shopId = #{shopId} and publishSource = 2
+        <if test="articleId != null">
+            and i.id = #{articleId}
+        </if>
+        <if test="title != null and title != ''">
+            and title like concat('%',#{title},'%')
+        </if>
+        <if test="publisher != null and publisher != ''">
+            and publisher like concat('%',#{publisher},'%')
+        </if>
+        <if test="typeId != null">
+            and typeId = #{typeId}
+        </if>
+        <if test="auditStatus != null">
+            and auditStatus = #{auditStatus}
+        </if>
         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>
     <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,