wxz 2 years ago
parent
commit
7d1272c54e
  1. 21
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java
  2. 10
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java
  3. 16
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateArticleFormDTO.java
  4. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftPcListResultDTO.java
  5. 10
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/PublishedListResultDTO.java
  6. 95
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  7. 13
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/DraftServiceImpl.java
  8. 1
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleContentDao.xml
  9. 17
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml

21
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java

@ -1,13 +1,12 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
@ -18,7 +17,7 @@ import java.util.List;
@Data
public class AddOrSaveDraftFormDTO implements Serializable {
public interface AddArticleForm{}
public interface AddArticleForm extends CustomerClientShowGroup {}
public interface AddDraftForm{}
/**
@ -31,7 +30,7 @@ public class AddOrSaveDraftFormDTO implements Serializable {
@Length(max = 50, message = "标题最长为50个字")
private String title;
@NotBlank(message = "栏目分类不能为空",groups = {AddArticleForm.class})
// @NotBlank(message = "所属栏目不能为空",groups = {AddArticleForm.class})
private String category;
/**
@ -84,4 +83,18 @@ public class AddOrSaveDraftFormDTO implements Serializable {
* 封面图地址
*/
private String imgUrl;
/**
* 内容列表
*/
private List<AddOrSaveDraftFormDTO.ContentDTO> fileList;
@Data
public static class ContentDTO {
public ContentDTO() {
}
private String fileId;
private String content;
private String fileName;
}
}

10
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/ArticleListFormDTO.java

@ -14,6 +14,16 @@ import java.util.List;
public class ArticleListFormDTO implements Serializable {
private static final long serialVersionUID = 6397877545890473794L;
/**
* 栏目
*/
private String category;
/**
* 子栏目列表
*/
private List<String> subCategories;
/**
* 文章标题
*/

16
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateArticleFormDTO.java

@ -28,7 +28,7 @@ public class UpdateArticleFormDTO {
@NotBlank(message = "articleId不能为空", groups = {AddUserInternalGroup.class})
private String articleId;
@NotBlank(message = "栏目不能为空", groups = {AddUserInternalGroup.class})
// @NotBlank(message = "所属栏目不能为空", groups = {AddUserShowGroup.class})
private String category;
@NotBlank(message = "文章标题不能为空", groups = {AddUserShowGroup.class})
@ -91,5 +91,19 @@ public class UpdateArticleFormDTO {
*/
@NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class)
private String customerId;
/**
* 内容列表
*/
private List<UpdateArticleFormDTO.ContentDTO> fileList;
@Data
public static class ContentDTO {
public ContentDTO() {
}
private String fileId;
private String content;
private String fileName;
}
}

5
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/DraftPcListResultDTO.java

@ -110,6 +110,11 @@ public class DraftPcListResultDTO implements Serializable {
*/
private List<Content> contentList;
/**
* 文章内容
*/
private List<Content> fileList;
@Data
public static class Content {
/**

10
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/PublishedListResultDTO.java

@ -26,6 +26,11 @@ public class PublishedListResultDTO implements Serializable {
* 分类
*/
private String category;
/**
* 栏目名称
*/
private String categoryName;
/**
* 组织Id
*/
@ -112,6 +117,11 @@ public class PublishedListResultDTO implements Serializable {
*/
private List<Content> contentList;
/**
* 附件列表
*/
private List<Content> fileList;
@Data
public static class Content {
/**

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

@ -131,6 +131,9 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
@Autowired
private DraftPublishRangeService draftPublishRangeService;
@Autowired
private CategoryDictDao categoryDictDao;
@Value("${openapi.scan.server.url}")
private String scanApiUrl;
@Value("${openapi.scan.method.imgSyncScan}")
@ -1558,6 +1561,21 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
articleContent.setContentType("rich_text");
articleContent.setOrderNum(NumConstant.ONE);
articleContentDao.insert(articleContent);
// 2.1 附件
if(!CollectionUtils.isEmpty(formDTO.getFileList())){
int orderNum=2;
for(AddOrSaveDraftFormDTO.ContentDTO file:formDTO.getFileList()){
ArticleContentEntity fileDto=new ArticleContentEntity();
fileDto.setCustomerId(formDTO.getCustomerId());
fileDto.setArticleId(article.getId());
fileDto.setContent(file.getContent());
fileDto.setFileName(file.getFileName());
fileDto.setContentType("file");
fileDto.setOrderNum(orderNum);
articleContentDao.insert(fileDto);
orderNum++;
}
}
// 3.操作记录
ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity();
articleOperateRecord.setCustomerId(customerId);
@ -1644,6 +1662,22 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
draftContent.setOrderNum(NumConstant.ZERO);
draftContentDao.insert(draftContent);
}
// 2.1 附件
if(!CollectionUtils.isEmpty(formDTO.getFileList())){
int orderNum=2;
for(AddOrSaveDraftFormDTO.ContentDTO file:formDTO.getFileList()){
DraftContentEntity fileDto=new DraftContentEntity();
fileDto.setCustomerId(formDTO.getCustomerId());
fileDto.setDraftId(draft.getId());
fileDto.setContent(file.getContent());
fileDto.setFileName(file.getFileName());
fileDto.setContentType("file");
fileDto.setOrderNum(orderNum);
draftContentDao.insert(fileDto);
orderNum++;
}
}
// 3.发布范围
if (!CollectionUtils.isEmpty(formDTO.getGridIdList())){
List<DraftPublishRangeEntity> rangeList = new ArrayList<>();
@ -1728,6 +1762,20 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
formDTO.setAgencyId(staffInfo.getAgencyId());
//列表查询
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage());
// 查询子栏目
String categoryId;
List<String> subCategories;
if (StringUtils.isNotBlank(categoryId = formDTO.getCategory())) {
LambdaQueryWrapper<CategoryDictEntity> cq = new LambdaQueryWrapper<>();
cq.eq(CategoryDictEntity::getPid, categoryId);
List<CategoryDictEntity> subCtgs = categoryDictDao.selectList(cq);
if (! CollectionUtils.isEmpty(subCtgs)) {
subCategories = subCtgs.stream().map(CategoryDictEntity::getId).collect(Collectors.toList());
formDTO.setSubCategories(subCategories);
}
}
List<PublishedListResultDTO> list = baseDao.selectAllArticle(formDTO);
PageInfo<PublishedListResultDTO> pageInfo = new PageInfo<>(list);
@ -1773,12 +1821,23 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
LambdaQueryWrapper<ArticleContentEntity> tWrapper1 = new LambdaQueryWrapper<>();
tWrapper1.eq(ArticleContentEntity::getArticleId, formDTO.getArticleId());
tWrapper1.eq(ArticleContentEntity::getDelFlag, NumConstant.ZERO_STR);
tWrapper1.ne(ArticleContentEntity::getContentType,"file");
tWrapper1.orderByDesc(ArticleContentEntity::getOrderNum);
List<ArticleContentEntity> contentEntityList = articleContentDao.selectList(tWrapper1);
if (!CollectionUtils.isEmpty(contentEntityList)) {
List<PublishedListResultDTO.Content> contentList = ConvertUtils.sourceToTarget(contentEntityList, PublishedListResultDTO.Content.class);
resultDTO.setContentList(contentList);
}
LambdaQueryWrapper<ArticleContentEntity> fileWrapper = new LambdaQueryWrapper<>();
fileWrapper.eq(ArticleContentEntity::getArticleId, formDTO.getArticleId());
fileWrapper.eq(ArticleContentEntity::getDelFlag, NumConstant.ZERO_STR);
fileWrapper.eq(ArticleContentEntity::getContentType,"file");
fileWrapper.orderByDesc(ArticleContentEntity::getOrderNum);
List<ArticleContentEntity> fileContentEntityList = articleContentDao.selectList(fileWrapper);
if (!CollectionUtils.isEmpty(fileContentEntityList)) {
List<PublishedListResultDTO.Content> fileList = ConvertUtils.sourceToTarget(fileContentEntityList, PublishedListResultDTO.Content.class);
resultDTO.setFileList(fileList);
}
//标签列表
LambdaQueryWrapper<ArticleTagsEntity> tWrapper2 = new LambdaQueryWrapper<>();
@ -1790,6 +1849,12 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
resultDTO.setTagIdList(contentList);
}
// 栏目
CategoryDictEntity categoryDict = categoryDictDao.selectById(resultDTO.getCategory());
if (categoryDict != null) {
resultDTO.setCategoryName(categoryDict.getCategoryName());
}
return resultDTO;
}
@ -1871,6 +1936,36 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
articleContent1.setOrderNum(NumConstant.ONE);
articleContentDao.insert(articleContent1);
}
// 2.1 附件
if(!CollectionUtils.isEmpty(formDTO.getFileList())){
//
LambdaQueryWrapper<ArticleContentEntity> del=new LambdaQueryWrapper<>();
del.eq(ArticleContentEntity::getArticleId,formDTO.getArticleId())
.ne(ArticleContentEntity::getContent,"rich_text");
articleContentDao.delete(del);
int orderNum=2;
for(UpdateArticleFormDTO.ContentDTO file:formDTO.getFileList()){
ArticleContentEntity fileDto=new ArticleContentEntity();
fileDto.setCustomerId(formDTO.getCustomerId());
fileDto.setArticleId(formDTO.getArticleId());
fileDto.setContent(file.getContent());
fileDto.setFileName(file.getFileName());
fileDto.setContentType("file");
fileDto.setOrderNum(orderNum);
articleContentDao.insert(fileDto);
orderNum++;
}
}
//内容类型 图片:img;文字:text;文件:file 富文本:rich_text 如果是工作端小程序发布的文章,在pc编辑后,img和text删除。
LambdaUpdateWrapper<ArticleContentEntity> updateWrapper=new LambdaUpdateWrapper<>();
updateWrapper.eq(ArticleContentEntity::getArticleId,formDTO.getArticleId())
.ne(ArticleContentEntity::getContentType,"rich_text")
.ne(ArticleContentEntity::getContentType,"file")
.set(ArticleContentEntity::getDelFlag,NumConstant.ONE_STR)
.set(ArticleContentEntity::getUpdatedBy,EpmetRequestHolder.getLoginUserId())
.set(ArticleContentEntity::getUpdatedTime,new Date());
articleContentDao.update(null,updateWrapper);
// 3.操作记录
ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity();
articleOperateRecord.setCustomerId(formDTO.getCustomerId());

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

@ -266,7 +266,8 @@ public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> imp
//查询文章内容
LambdaQueryWrapper<DraftContentEntity> tWrapper1 = new LambdaQueryWrapper<>();
tWrapper1.eq(DraftContentEntity::getDraftId, formDTO.getDraftId());
tWrapper1.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR);
tWrapper1.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR)
.ne(DraftContentEntity::getContentType,"file");
tWrapper1.orderByDesc(DraftContentEntity::getOrderNum);
List<DraftContentEntity> contentEntityList = draftContentDao.selectList(tWrapper1);
if (!CollectionUtils.isEmpty(contentEntityList)) {
@ -274,6 +275,16 @@ public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> imp
resultDTO.setContentList(contentList);
}
LambdaQueryWrapper<DraftContentEntity> fileWrapper = new LambdaQueryWrapper<>();
fileWrapper.eq(DraftContentEntity::getDraftId, formDTO.getDraftId());
fileWrapper.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR)
.eq(DraftContentEntity::getContentType,"file");
fileWrapper.orderByDesc(DraftContentEntity::getOrderNum);
List<DraftContentEntity> fileContentEntityList = draftContentDao.selectList(fileWrapper);
if (!CollectionUtils.isEmpty(fileContentEntityList)) {
List<DraftPcListResultDTO.Content> fileContentList = ConvertUtils.sourceToTarget(fileContentEntityList, DraftPcListResultDTO.Content.class);
resultDTO.setFileList(fileContentList);
}
//标签列表
if(!CollectionUtils.isEmpty(resultDTO.getTagNameList())){
LambdaQueryWrapper<TagCustomerEntity> tWrapper2 = new LambdaQueryWrapper<>();

1
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleContentDao.xml

@ -12,6 +12,7 @@
WHERE
ac.DEL_FLAG = '0'
AND ac.ID = #{articleId}
and ac.CONTENT_TYPE ='rich_text'
</select>
</mapper>

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

@ -437,6 +437,7 @@
a.org_id AS "agencyId",
a.title AS "title",
a.category AS "category",
cd.CATEGORY_NAME,
IFNULL(a.preview_content, "") AS "previewContent",
a.publish_range_desc AS "publishRangeDesc",
a.publisher_id AS "publisher",
@ -453,9 +454,25 @@
ac.img_url AS "imgUrl"
FROM
article a
inner join category_dict cd on (cd.DEL_FLAG = 0 and a.CATEGORY = cd.ID)
LEFT JOIN article_cover ac ON a.id = ac.article_id AND ac.del_flag = '0'
WHERE
a.del_flag = '0'
<!-- 栏目 -->
<if test="(subCategories != null and subCategories.size() > 0) or (category != null and category != '')">
and (
<if test="subCategories != null and subCategories.size() > 0">
a.CATEGORY in (
<foreach collection="subCategories" item="ctg" separator=",">
#{ctg}
</foreach>
) or
</if>
<if test="category != null and category != ''">
a.CATEGORY = #{category}
</if>
)
</if>
<if test="articleId != null and articleId != '' ">
AND a.id = #{articleId}
</if>

Loading…
Cancel
Save