Browse Source

【功能优化】通过标签分类获取文章列表

1.修改文章标签tag_customer表
1.1 tag_customer表格增加字段 TAG_CATEGORY 标签分类(党建声音:VOICE;社区通知:NOTICE;默认DEFAULTD
1.2 给对应的标签的分类字段分类赋值
2.通过标签分类获取改分类下的所有标签ID(子查询),获取对应的文章列表
national_dev
Bill 2 years ago
parent
commit
661b04c428
  1. 5
      code/smart-community/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java
  2. 5
      code/smart-community/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java
  3. 7
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  4. 2
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java
  5. 2
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java
  6. 2
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
  7. 39
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  8. 2
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java
  9. 2
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.13__tag_category.sql
  10. 74
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml
  11. 3
      code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml

5
code/smart-community/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java

@ -57,4 +57,9 @@ public class ArticleListFormDTO implements Serializable {
private String agencyId;
private String staffId;
/**
* 文章标签分类
*/
private String tagCategory;
}

5
code/smart-community/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java

@ -34,6 +34,11 @@ public class TagCustomerPageFormDTO implements Serializable {
*/
private String tagName;
/**
* 标签分类
*/
private String tagCategory;
@NotNull(message = "页码不能为空", groups = PageUserInternalGroup.class)
private Integer pageNo;

7
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java

@ -441,6 +441,13 @@ public class ArticleController {
return new Result<PageData<PublishedListResultDTO>>().ok(articleService.articleListV2(formDTO));
}
@PostMapping("articleList")
public Result<PageData<PublishedListResultDTO>> articleList(@LoginUser TokenDto tokenDTO, @RequestBody ArticleListFormDTO formDTO) {
formDTO.setCustomerId(tokenDTO.getCustomerId());
// formDTO.setStaffId(tokenDTO.getUserId());
return new Result<PageData<PublishedListResultDTO>>().ok(articleService.articleList(formDTO));
}
/**
* 文章置顶取消置顶
* @param formDTO

2
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java

@ -168,6 +168,8 @@ public interface ArticleDao extends BaseDao<ArticleEntity> {
List<PublishedListResultDTO> selectAllArticle(ArticleListFormDTO formDTO);
List<PublishedListResultDTO> selectAllArticle2(ArticleListFormDTO formDTO);
/**
* 根据标签名查询文章列表
* @param gridId

2
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java

@ -63,7 +63,7 @@ public interface TagCustomerDao extends BaseDao<TagCustomerEntity> {
* @param tagName
* @return
*/
List<TagCustomerDTO> pageList(@Param("customerId") String customerId, @Param("tagName")String tagName);
List<TagCustomerDTO> pageList(@Param("customerId") String customerId, @Param("tagName")String tagName, @Param("tagCategory") String tagCategory);
/**
* 钉钉实时动态获取网格所属社区下 的标签列表

2
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java

@ -254,6 +254,8 @@ public interface ArticleService extends BaseService<ArticleEntity> {
PageData<PublishedListResultDTO> articleListV2(ArticleListFormDTO formDTO);
PageData<PublishedListResultDTO> articleList(ArticleListFormDTO formDTO);
PublishedListResultDTO detailV2(ArticleListFormDTO formDTO);
void topArticle(String articleId, String type,String imgUrl);

39
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

@ -1737,6 +1737,45 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
return new PageData<>(list, pageInfo.getTotal());
}
@Override
public PageData<PublishedListResultDTO> articleList(ArticleListFormDTO formDTO) {
// TagCustomerPageFormDTO tagFormDTO = new TagCustomerPageFormDTO();
// tagFormDTO.setCustomerId(formDTO.getCustomerId());
// tagFormDTO.setTagCategory(formDTO.getTagCategory());
// tagFormDTO.setPageNo(1);
// tagFormDTO.setPageSize(Integer.MAX_VALUE);
//
// PageData<TagCustomerDTO> pageData = tagCustomerService.page(tagFormDTO);
// if(pageData != null) {
// List<TagCustomerDTO> tagCustomerDTOS = pageData.getList();
//
// if(tagCustomerDTOS != null && tagCustomerDTOS.size() != 0) {
// List<String> tagIds = new ArrayList<>();
// for (TagCustomerDTO tag: tagCustomerDTOS) {
// tagIds.add(tag.getId());
// }
//
// formDTO.setTagIds(tagIds);
// }
// }
//列表查询
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage());
List<PublishedListResultDTO> list = baseDao.selectAllArticle2(formDTO);
PageInfo<PublishedListResultDTO> pageInfo = new PageInfo<>(list);
//封装数据
if (!CollectionUtils.isEmpty(list)) {
list.forEach(l->{
l.setTagNameList(StringUtils.isNotBlank(l.getTags())?Arrays.asList(l.getTags().split("[|]")):new ArrayList<>());
l.setIsMePublished(l.getCreatedBy().equals(formDTO.getStaffId())?true:false);
});
}
return new PageData<>(list, pageInfo.getTotal());
}
@Override
public PublishedListResultDTO detailV2(ArticleListFormDTO formDTO) {
PublishedListResultDTO resultDTO = new PublishedListResultDTO();

2
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java

@ -86,7 +86,7 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC
@Override
public PageData<TagCustomerDTO> page(TagCustomerPageFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize());
List<TagCustomerDTO> list=baseDao.pageList(formDTO.getCustomerId(),formDTO.getTagName());
List<TagCustomerDTO> list=baseDao.pageList(formDTO.getCustomerId(),formDTO.getTagName(), formDTO.getTagCategory());
PageInfo<TagCustomerDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());
}

2
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.13__tag_category.sql

@ -0,0 +1,2 @@
ALTER TABLE `epmet_gov_voice`.`tag_customer`
MODIFY COLUMN `TAG_CATEGORY` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标签分类(党建声音:VOICE;社区通知:NOTICE;默认DEFAULTD)' AFTER `TAG_NAME`;

74
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml

@ -508,6 +508,80 @@
ORDER BY a.publish_date DESC, a.updated_time DESC
</select>
<select id="selectAllArticle2" resultType="com.epmet.dto.result.PublishedListResultDTO">
SELECT
a.id AS "articleId",
a.org_id AS "agencyId",
a.title AS "title",
IFNULL(a.preview_content, "") AS "previewContent",
a.publish_range_desc AS "publishRangeDesc",
a.publisher_id AS "publisher",
a.publisher_name AS "publisherName",
a.publisher_type AS "publisherType",
a.publish_date AS "publishDate",
IFNULL(a.tags, "") AS "tags",
a.status_flag AS "statusFlag",
IF (a.status_flag = 'published', '已发布', '已下线') "statusFlagName",
a.rich_text_flag AS "richTextFlag",
a.created_by AS "createdBy",
a.is_top AS "isTop",
IF (a.is_top = '0', '否', '是') "isTopName",
ac.img_url AS "imgUrl"
FROM
article a
LEFT JOIN article_cover ac ON a.id = ac.article_id AND ac.del_flag = '0'
LEFT JOIN article_tags art ON a.id = art.ARTICLE_ID AND art.del_flag = '0'
WHERE
a.del_flag = '0'
<if test="articleId != null and articleId != '' ">
AND a.id = #{articleId}
</if>
<if test="customerId != null and customerId != '' ">
AND a.customer_id = #{customerId}
</if>
<if test="agencyId != null and agencyId != '' ">
AND a.org_id_path like concat('%',#{agencyId},'%')
</if>
<if test="title != null and title.trim() != ''">
AND a.title like concat('%', #{title}, '%')
</if>
<if test="statusFlag != null and statusFlag.trim() != ''">
AND a.status_flag = #{statusFlag}
</if>
<if test="startDate != null and startDate.trim() != ''">
AND a.publish_date >= #{startDate}
</if>
<if test="endDate != null and endDate.trim() != ''">
<![CDATA[AND a.publish_date <= #{endDate}]]>
</if>
<if test="publishRangeType != null and publishRangeType.trim() != '' and publishRangeId != null and publishRangeId.trim() != ''">
<choose>
<when test='publishRangeType == "agency"'>
AND EXISTS(
SELECT 1 FROM article_publish_range
WHERE del_flag = '0'
AND article_id = a.id
AND agency_id = #{publishRangeId}
and PUBLISH_STATUS='published'
)
</when>
<otherwise>
AND EXISTS(
SELECT 1 FROM article_publish_range
WHERE del_flag = '0'
AND article_id = a.id
AND grid_id = #{publishRangeId}
and PUBLISH_STATUS='published'
)
</otherwise>
</choose>
</if>
<if test="tagCategory !=null and tagCategory !=''">
AND art.TAG_ID IN(SELECT id FROM tag_customer WHERE TAG_CATEGORY = #{tagCategory})
</if>
ORDER BY a.publish_date DESC, a.updated_time DESC
</select>
<!-- 根据标签名,查询文章列表 -->
<select id="pageArticleListByTagName" parameterType="map" resultType="com.epmet.dto.result.ArticleLatestResultDTO">
SELECT

3
code/smart-community/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml

@ -74,6 +74,9 @@
<if test='null != tagName and "" != tagName'>
and tc.TAG_NAME like concat('%',#{tagName},'%')
</if>
<if test='null != tagCategory and "" != tagCategory'>
and tc.TAG_CATEGORY = #{tagCategory}
</if>
</select>
<!-- 钉钉实时动态,获取网格所属社区下, 的标签列表 -->

Loading…
Cancel
Save