Browse Source

草稿列表、详情

dev
sunyuchao 3 years ago
parent
commit
104ef63a59
  1. 1
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  2. 1
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java
  3. 3
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftDao.java
  4. 82
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java
  5. 8
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml
  6. 44
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml

1
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java

@ -428,6 +428,7 @@ public class ArticleController {
@PostMapping("detailV2") @PostMapping("detailV2")
public Result<PublishedListResultDTO> detailV2(@LoginUser TokenDto tokenDTO, @RequestBody ArticleListFormDTO formDTO) { public Result<PublishedListResultDTO> detailV2(@LoginUser TokenDto tokenDTO, @RequestBody ArticleListFormDTO formDTO) {
formDTO.setCustomerId(tokenDTO.getCustomerId()); formDTO.setCustomerId(tokenDTO.getCustomerId());
formDTO.setStaffId(tokenDTO.getUserId());
return new Result<PublishedListResultDTO>().ok(articleService.detailV2(formDTO)); return new Result<PublishedListResultDTO>().ok(articleService.detailV2(formDTO));
} }

1
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java

@ -109,6 +109,7 @@ public class DraftController {
@PostMapping("detailV2") @PostMapping("detailV2")
public Result<DraftPcListResultDTO> detailV2(@LoginUser TokenDto tokenDTO, @RequestBody DraftListFormDTO formDTO) { public Result<DraftPcListResultDTO> detailV2(@LoginUser TokenDto tokenDTO, @RequestBody DraftListFormDTO formDTO) {
formDTO.setCustomerId(tokenDTO.getCustomerId()); formDTO.setCustomerId(tokenDTO.getCustomerId());
formDTO.setStaffId(tokenDTO.getUserId());
return new Result<DraftPcListResultDTO>().ok(draftService.detailV2(formDTO)); return new Result<DraftPcListResultDTO>().ok(draftService.detailV2(formDTO));
} }

3
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/DraftDao.java

@ -18,6 +18,7 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.DraftListFormDTO;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.entity.DraftEntity; import com.epmet.entity.DraftEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -112,4 +113,6 @@ public interface DraftDao extends BaseDao<DraftEntity> {
* @return * @return
*/ */
int updateAuditStatusById(@Param("draftId") String draftId, @Param("statusFlag") String statusFlag, @Param("titleAuditStatus") String titleAuditStatus); int updateAuditStatusById(@Param("draftId") String draftId, @Param("statusFlag") String statusFlag, @Param("titleAuditStatus") String titleAuditStatus);
List<DraftPcListResultDTO> selectAllDraft(DraftListFormDTO formDTO);
} }

82
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java

@ -17,24 +17,30 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DraftConstant; import com.epmet.constant.DraftConstant;
import com.epmet.dao.DraftContentDao;
import com.epmet.dao.DraftCoverDao; import com.epmet.dao.DraftCoverDao;
import com.epmet.dao.DraftDao; import com.epmet.dao.DraftDao;
import com.epmet.dao.DraftPublishRangeDao;
import com.epmet.dto.DraftDTO; import com.epmet.dto.DraftDTO;
import com.epmet.dto.form.DeleteDraftFormDTO; import com.epmet.dto.form.DeleteDraftFormDTO;
import com.epmet.dto.form.DraftDetailFormDTO; import com.epmet.dto.form.DraftDetailFormDTO;
import com.epmet.dto.form.DraftListFormDTO; import com.epmet.dto.form.DraftListFormDTO;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.entity.DraftCoverEntity; import com.epmet.entity.*;
import com.epmet.entity.DraftEntity;
import com.epmet.service.DraftService; import com.epmet.service.DraftService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -44,11 +50,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
/** /**
* 草稿表 * 草稿表
@ -62,6 +67,13 @@ public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> imp
@Autowired @Autowired
private DraftCoverDao draftCoverDao; private DraftCoverDao draftCoverDao;
@Autowired
private LoginUserUtil loginUserUtil;
@Autowired
private DraftPublishRangeDao draftPublishRangeDao;
@Autowired
private DraftContentDao draftContentDao;
@Override @Override
public PageData<DraftDTO> page(Map<String, Object> params) { public PageData<DraftDTO> page(Map<String, Object> params) {
IPage<DraftEntity> page = baseDao.selectPage( IPage<DraftEntity> page = baseDao.selectPage(
@ -203,12 +215,66 @@ public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> imp
@Override @Override
public PageData<DraftPcListResultDTO> draftListV2(DraftListFormDTO formDTO) { public PageData<DraftPcListResultDTO> draftListV2(DraftListFormDTO formDTO) {
return null; //1.获取工作人员缓存信息
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
if (null == staffInfo) {
throw new EpmetException("获取工作人员信息失败");
}
//查询当前组织及下级数据
formDTO.setAgencyId(staffInfo.getAgencyId());
//列表查询
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage());
List<DraftPcListResultDTO> list = baseDao.selectAllDraft(formDTO);
PageInfo<DraftPcListResultDTO> 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(loginUserUtil.getLoginUserId())?true:false);
});
}
return new PageData<>(list, pageInfo.getTotal());
} }
@Override @Override
public DraftPcListResultDTO detailV2(DraftListFormDTO formDTO) { public DraftPcListResultDTO detailV2(DraftListFormDTO formDTO) {
return null; DraftPcListResultDTO resultDTO = new DraftPcListResultDTO();
//1.查询文章主表信息
List<DraftPcListResultDTO> list = baseDao.selectAllDraft(formDTO);
if (!CollectionUtils.isEmpty(list)) {
resultDTO = list.get(NumConstant.ZERO);
//查询文章涉及的发布范围网络Id列表
LambdaQueryWrapper<DraftPublishRangeEntity> tWrapper = new LambdaQueryWrapper<>();
tWrapper.eq(DraftPublishRangeEntity::getDraftId, formDTO.getDraftId());
tWrapper.eq(DraftPublishRangeEntity::getDelFlag, NumConstant.ZERO_STR);
//【文章下线的查所有发布范围,文章没下线的只查还没下线的发布范围】
if("unpublish".equals(resultDTO.getStatusFlag())){
tWrapper.eq(DraftPublishRangeEntity::getPublishStatus, "unpublish");
}else {
tWrapper.eq(DraftPublishRangeEntity::getPublishStatus, "published");
}
List<DraftPublishRangeEntity> entityList = draftPublishRangeDao.selectList(tWrapper);
if (!CollectionUtils.isEmpty(entityList)) {
List<String> contentList = entityList.stream().map(DraftPublishRangeEntity::getGridId).collect(Collectors.toList());
resultDTO.setGridIdList(contentList);
}
//查询文章内容
LambdaQueryWrapper<DraftContentEntity> tWrapper1 = new LambdaQueryWrapper<>();
tWrapper1.eq(DraftContentEntity::getDraftId, formDTO.getDraftId());
tWrapper1.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR);
tWrapper1.orderByDesc(DraftContentEntity::getOrderNum);
List<DraftContentEntity> contentEntityList = draftContentDao.selectList(tWrapper1);
if (!CollectionUtils.isEmpty(entityList)) {
LinkedList<String> contentList = (LinkedList)contentEntityList.stream().map(DraftContentEntity::getContent).collect(Collectors.toList());
resultDTO.setContentList(contentList);
}
}
return resultDTO;
} }
} }

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

@ -449,7 +449,7 @@
WHERE WHERE
a.del_flag = '0' a.del_flag = '0'
<if test="articleId != null and articleId != '' "> <if test="articleId != null and articleId != '' ">
AND id = #{articleId} AND a.id = #{articleId}
</if> </if>
<if test="customerId != null and customerId != '' "> <if test="customerId != null and customerId != '' ">
AND a.customer_id = #{customerId} AND a.customer_id = #{customerId}
@ -464,10 +464,10 @@
AND a.status_flag = #{statusFlag} AND a.status_flag = #{statusFlag}
</if> </if>
<if test="startDate != null and startDate.trim() != ''"> <if test="startDate != null and startDate.trim() != ''">
and publish_date >= #{startDate} AND a.publish_date >= #{startDate}
</if> </if>
<if test="endDate != null and endDate.trim() != ''"> <if test="endDate != null and endDate.trim() != ''">
<![CDATA[and publish_date <= #{endDate}]]> <![CDATA[AND a.publish_date <= #{endDate}]]>
</if> </if>
<choose> <choose>
<when test='publishRangeType == "agency"'> <when test='publishRangeType == "agency"'>
@ -487,7 +487,7 @@
) )
</foreach> </foreach>
</if> </if>
ORDER BY publish_date DESC, updated_time DESC ORDER BY a.publish_date DESC, a.updated_time DESC
</select> </select>
</mapper> </mapper>

44
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml

@ -177,6 +177,50 @@
ORDER BY ORDER BY
dc.ORDER_NUM ASC dc.ORDER_NUM ASC
</select> </select>
<select id="selectAllDraft" resultType="com.epmet.dto.result.DraftPcListResultDTO">
SELECT
a.id AS "draftId",
a.title AS "title",
IFNULL(a.preview_content, "") AS "previewContent",
a.publish_range_desc AS "publishRangeDesc",
a.publisher_id AS "publisherId",
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",
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
draft a
LEFT JOIN draft_cover ac ON a.id = ac.draft_id AND ac.del_flag = '0'
WHERE
a.del_flag = '0'
<if test="draftId != null and draftId != '' ">
AND a.id = #{draftId}
</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="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>
ORDER BY a.publish_date DESC, a.updated_time DESC
</select>
<update id="deleteDraft" parameterType="java.lang.String"> <update id="deleteDraft" parameterType="java.lang.String">
update draft set DEL_FLAG='1' where id=#{draftId} update draft set DEL_FLAG='1' where id=#{draftId}
</update> </update>

Loading…
Cancel
Save