Browse Source

党建声音发布支持上传文件

master
yinzuomei 2 years ago
parent
commit
09e20f709d
  1. 21
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddOrSaveDraftFormDTO.java
  2. 16
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateArticleFormDTO.java
  3. 57
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  4. 1
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleContentDao.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;
}
}

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;
}
}

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

@ -1558,6 +1558,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 +1659,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<>();
@ -1871,6 +1902,32 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
articleContent1.setOrderNum(NumConstant.ONE);
articleContentDao.insert(articleContent1);
}
// 2.1 附件
if(!CollectionUtils.isEmpty(formDTO.getFileList())){
int orderNum=2;
for(UpdateArticleFormDTO.ContentDTO file:formDTO.getFileList()){
if(StringUtils.isNotBlank(file.getFileId())){
LambdaUpdateWrapper<ArticleContentEntity> updateWrapper=new LambdaUpdateWrapper<>();
updateWrapper.set(ArticleContentEntity::getContent,file.getContent())
.set(ArticleContentEntity::getFileName,file.getFileName())
.set(ArticleContentEntity::getUpdatedBy,EpmetRequestHolder.getLoginUserId())
.set(ArticleContentEntity::getUpdatedTime,new Date())
.set(ArticleContentEntity::getOrderNum,orderNum)
.eq(ArticleContentEntity::getId,file.getFileId());
articleContentDao.update(null,updateWrapper);
}else{
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++;
}
}
// 3.操作记录
ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity();
articleOperateRecord.setCustomerId(formDTO.getCustomerId());

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>
Loading…
Cancel
Save