Browse Source

Merge remote-tracking branch 'origin/dev_voice' into dev_voice

master
sunyuchao 5 years ago
parent
commit
13a7f431c2
  1. 23
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftContentSaveResultDTO.java
  2. 5
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/DraftConstant.java
  3. 5
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  4. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftController.java
  5. 6
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java
  6. 43
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  7. 5
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java
  8. 16
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml

23
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftContentSaveResultDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 政府端保存文章内容 返回结果
*/
@Data
public class DraftContentSaveResultDTO implements Serializable {
public DraftContentSaveResultDTO() {
super();
}
public DraftContentSaveResultDTO(String draftId) {
this.draftId = draftId;
}
/**
*草稿Id
*/
private String draftId;
}

5
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/DraftConstant.java

@ -61,4 +61,9 @@ public interface DraftConstant {
* 内容类型-文字
*/
String TEXT = "text";
/**
* 草稿预览内容大小长度
*/
Integer PREVIEW_CONTENT_MAX_LENGTH = 50;
}

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

@ -77,9 +77,10 @@ public class ArticleController {
*/
@PostMapping("savecontent")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH)
public Result<String> saveOrUpdateContent(@LoginUser TokenDto tokenDto,@RequestBody DraftContentFromDTO fromDTO) throws Exception {
public Result<DraftContentSaveResultDTO> saveOrUpdateContent(@LoginUser TokenDto tokenDto,@RequestBody DraftContentFromDTO fromDTO) throws Exception {
String draftId = articleService.saveOrUpdateContent(tokenDto, fromDTO);
return new Result<String>().ok(draftId);
DraftContentSaveResultDTO resultDTO = new DraftContentSaveResultDTO(draftId);
return new Result<DraftContentSaveResultDTO>().ok(resultDTO);
}
/**

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

@ -115,7 +115,7 @@ public class DraftController {
@PostMapping("draftlist")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_DRAFT_LIST)
public Result<List<DraftListResultDTO>> draftList(@LoginUser TokenDto tokenDto, DraftListFormDTO formDTO) {
public Result<List<DraftListResultDTO>> draftList(@LoginUser TokenDto tokenDto, @RequestBody DraftListFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return new Result<List<DraftListResultDTO>>().ok(draftService.draftList(tokenDto, formDTO).getList());
}

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

@ -83,9 +83,9 @@ public interface ArticleDao extends BaseDao<ArticleEntity> {
* @param gridList
* @return java.util.List<com.epmet.dto.result.PublishedListResultDTO>
*/
@DataFilter(tableAliases = {"a", "apr"}, gridIdsArgName = "gridList")
List<PublishedListResultDTO> selectArticleListForGrid(@Param("customerId") String customerId,
@Param("tagIdList") List<String> tagIdList, Set<String> gridList);
@Param("tagIdList") List<String> tagIdList,
@Param("gridList")Set<String> gridList);
/**
* 已下线文章列表
@ -94,7 +94,7 @@ public interface ArticleDao extends BaseDao<ArticleEntity> {
* @param gridList
* @return java.util.List<com.epmet.dto.result.OfflineListResultDTO>
*/
@DataFilter(tableAliases = "apr", gridIdsArgName = "gridList")
@DataFilter(tableAliases = "a", gridIdsArgName = "gridList")
List<OfflineListResultDTO> selectOfflineList(Set<String> gridList);

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

@ -179,16 +179,8 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
throw new RenException("参数错误");
}
draftEntity.setTitle(draftEntity.getTitle());
for (int i = 0; i < fromDTO.getContentList().size(); i++) {
if(DraftConstant.TEXT.equals(fromDTO.getContentList().get(i).getContentType())) {
String content = fromDTO.getContentList().get(i).getContent();
if(content.length() > 50) {
content = content.substring(0, 50);
}
draftEntity.setPreviewContent(content);
break;
}
}
draftEntity.setPreviewContent("");
buildPreviewContent(fromDTO, draftEntity);
draftDao.updateById(draftEntity);
} else {
@ -211,16 +203,8 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
draftEntity.setGridId("");
draftEntity.setDepartmentId(loginUserDetails.getData().getCustomerId());
draftEntity.setDelFlag(NumConstant.ZERO_STR);
for (int i = 0; i < fromDTO.getContentList().size(); i++) {
if(DraftConstant.TEXT.equals(fromDTO.getContentList().get(i).getContentType())) {
String content = fromDTO.getContentList().get(i).getContent();
if(content.length() > 50) {
content = content.substring(0, 50);
}
draftEntity.setPreviewContent(content);
break;
}
}
draftEntity.setPreviewContent("");
buildPreviewContent(fromDTO, draftEntity);
draftDao.insert(draftEntity);
}
@ -233,12 +217,25 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
}
Map<String, Object> draftIdMap = new HashMap<>();
draftIdMap.put("DRAFT_ID", fromDTO.getDraftId());
draftIdMap.put(ModuleConstant.FIELD_DRAFT_ID, fromDTO.getDraftId());
draftContentDao.deleteByMap(draftIdMap);
draftContentService.insertBatch(draftContentList);
return draftId;
}
private void buildPreviewContent(DraftContentFromDTO fromDTO, DraftEntity draftEntity) {
for (int i = 0; i < fromDTO.getContentList().size(); i++) {
if (DraftConstant.TEXT.equals(fromDTO.getContentList().get(i).getContentType())) {
String content = fromDTO.getContentList().get(i).getContent();
if (content.length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) {
content = content.substring(NumConstant.ZERO, DraftConstant.PREVIEW_CONTENT_MAX_LENGTH);
}
draftEntity.setPreviewContent(content);
break;
}
}
}
@Override
public GovArticleDetailResultDTO queryGovArticleDetail(String articleId) {
GovArticleDetailResultDTO articleDetail = baseDao.queryGovArticleDetail(articleId);
@ -323,7 +320,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
@Override
public Boolean previewSaveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) {
//校验参数
if (fromDTO.getIsTop() == 1 && StringUtils.isBlank(fromDTO.getCoverImg())) {
if (DraftConstant.TOP.equals(fromDTO.getIsTop()) && StringUtils.isBlank(fromDTO.getCoverImg())) {
log.warn("saveOrUpdateAttr isTop=1 but coverImg is blank");
throw new RenException("文章封面不能为空");
}
@ -354,7 +351,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
@Transactional(rollbackFor = Exception.class)
public void executeSaveDraftAttr(DraftEntity draftEntity, DraftCoverEntity coverEntity, List<DraftPublishRangeEntity> publishRangeEntityList) {
Map<String,Object> draftIdMap = new HashMap<>();
draftIdMap.put("DRAFT_ID", draftEntity.getId());
draftIdMap.put(ModuleConstant.FIELD_DRAFT_ID, draftEntity.getId());
draftCoverDao.deleteByMap(draftIdMap);
if (coverEntity != null){
draftCoverDao.insert(coverEntity);

5
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/utils/ModuleConstant.java

@ -39,6 +39,11 @@ public interface ModuleConstant {
* */
String FIELD_ARTICLE_ID = "ARTICLE_ID";
/**
* 数据库列名 - 草稿ID
* */
String FIELD_DRAFT_ID = "DRAFT_ID";
/**
* 实体属性名 - 文章ID
* */

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

@ -96,6 +96,9 @@
WHERE a.DEL_FLAG = '0'
AND a.STATUS_FLAG = 'published'
AND a.CUSTOMER_ID = #{customerId}
<foreach item="gridId" collection="gridList" open="AND (" separator="or" close=")" index="">
a.GRID_ID = #{gridId}
</foreach>
UNION
SELECT DISTINCT
aa.ID AS "articleId",
@ -109,7 +112,11 @@
INNER JOIN article_publish_range apr ON aa.ID = apr.ARTICLE_ID AND apr.DEL_FLAG = 0 AND apr.PUBLISH_STATUS = 'published'
WHERE aa.DEL_FLAG = '0'
AND aa.STATUS_FLAG = 'published'
AND aa.CUSTOMER_ID = #{customerId}) t
AND aa.CUSTOMER_ID = #{customerId}
<foreach item="gridId" collection="gridList" open="AND (" separator="or" close=")" index="">
apr.GRID_ID = #{gridId}
</foreach>
) t
<if test="tagIdList !=null and tagIdList.size() > 0">
AND EXISTS (
SELECT DISTINCT
@ -131,12 +138,11 @@
a.TITLE AS "title",
IFNULL(a.PREVIEW_CONTENT, "") AS "previewContent",
a.PUBLISHER_NAME AS "publisherName",
a.PUBLISH_DATE AS "publishDate"
a.OFF_LINE_TIME AS "publishDate"
FROM article a
INNER JOIN article_publish_range apr ON a.ID = apr.ARTICLE_ID AND apr.DEL_FLAG = '0'
WHERE a.DEL_FLAG = '0'
AND apr.PUBLISH_STATUS = 'offline'
ORDER BY apr.OFF_LINE_TIME DESC
AND a.STATUS_FLAG = 'offline'
ORDER BY a.OFF_LINE_TIME DESC
</select>

Loading…
Cancel
Save