Browse Source

发布文章挂标签

dev
zxc 5 years ago
parent
commit
7603f01efb
  1. 60
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddArticleTagsFormDTO.java
  2. 7
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java
  3. 11
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleTagsDao.java
  4. 28
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  5. 15
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml
  6. 9
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleTagsDao.xml

60
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddArticleTagsFormDTO.java

@ -0,0 +1,60 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @CreateTime 2020/6/5 17:36
*/
@Data
public class AddArticleTagsFormDTO implements Serializable {
private static final long serialVersionUID = -6009661699565102279L;
/**
* 主键ID
*/
private String id;
/**
* 客户ID
*/
private String customerId;
/**
* 文章ID
*/
private String articleId;
/**
* 标签ID
*/
private String tagId;
/**
* 标签名称
*/
private String tagName;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag = 0;
/**
* 乐观锁
*/
private Integer revision = 0;
/**
* 创建人
*/
private String createdBy;
/**
* 更新人
*/
private String updatedBy;
}

7
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java

@ -137,4 +137,11 @@ public interface ArticleDao extends BaseDao<ArticleEntity> {
* @date 2020.06.03 18:28
**/
ArticleDetailResultDTO selectArticleDetail(@Param("gridId")String gridId,@Param("articleId")String articleId);
/**
* @Description 根据draftId获取文章id
* @param draftId
* @author zxc
*/
String getArticleIdByDraftId(@Param("draftId")String draftId);
}

11
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleTagsDao.java

@ -18,8 +18,12 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.AddArticleTagsFormDTO;
import com.epmet.entity.ArticleTagsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 文章标签表
@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface ArticleTagsDao extends BaseDao<ArticleTagsEntity> {
/**
* @Description 插入文章标签
* @param addArticleTags
* @author zxc
*/
void addArticleTags(@Param("addArticleTags")List<AddArticleTagsFormDTO> addArticleTags);
}

28
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

@ -107,6 +107,10 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
private TagRedis tagRedis;
@Autowired
private TagGridDao tagGridDao;
@Autowired
private ArticleDao articleDao;
@Autowired
private ArticleTagsDao articleTagsDao;
private static final String AGENCY = "agency";
private static final String GRID = "grid";
@ -998,4 +1002,28 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
}
}
/**
* @Description 给文章挂标签 article_tags
* @param formDto
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void addArticleTags(UpdateCustomerTagCacheDTO formDto,String draftId,TokenDto tokenDto){
List<AddArticleTagsFormDTO> addArticleTags = new ArrayList<>();
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo();
DraftDTO draft = draftService.get(draftId);
String customerId = draft.getCustomerId();
String userId = tokenDto.getUserId();
String articleId = articleDao.getArticleIdByDraftId(draftId);
for (UpdateTagUseCountsResultDTO resultDTO : tagsInfo) {
AddArticleTagsFormDTO addArticleTag = new AddArticleTagsFormDTO();
addArticleTag.setCreatedBy(userId);
addArticleTag.setUpdatedBy(userId);
addArticleTag.setCustomerId(customerId);
addArticleTag.setArticleId(articleId);
BeanUtils.copyProperties(resultDTO,addArticleTag);
addArticleTags.add(addArticleTag);
}
articleTagsDao.addArticleTags(addArticleTags);
}
}

15
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml

@ -313,4 +313,19 @@
AND art.ID = #{articleId}
ORDER BY content2.ORDER_NUM ASC
</select>
<!-- 根据draftId获取文章id -->
<select id="getArticleIdByDraftId" resultType="java.lang.String">
SELECT
a.id AS id
FROM
article a
LEFT JOIN draft d ON d.id = a.draft_id
WHERE
a.del_flag = 0
AND d.del_flag =0
AND d.status_flag = 'published'
AND a.draft_id = #{draftId}
</select>
</mapper>

9
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleTagsDao.xml

@ -3,5 +3,14 @@
<mapper namespace="com.epmet.dao.ArticleTagsDao">
<!-- 插入文章标签 -->
<select id="addArticleTags">
INSERT INTO article_tags ( ID, CUSTOMER_ID, ARTICLE_ID, TAG_ID, TAG_NAME, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="addArticleTags" item="tag" separator=",">
( REPLACE ( UUID(), '-', '' ),#{tag.customerId}, #{tag.articleId}, #{tag.tagId}, #{tag.tagName}, #{tag.delFlag},
#{tag.revision}, #{tag.createdBy}, NOW(),#{tag.updatedBy}, NOW())
</foreach>
</select>
</mapper>
Loading…
Cancel
Save