Browse Source

Merge branch 'dev_voice' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_voice

# Conflicts:
#	epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
#	epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
#	epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
master
sunyuchao 5 years ago
parent
commit
a662e8107d
  1. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/ArticleDTO.java
  2. 8
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/ArticlePublishRangeDTO.java
  3. 5
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/DraftDTO.java
  4. 8
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/DraftPublishRangeDTO.java
  5. 80
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftContentFromDTO.java
  6. 15
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java
  7. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/DraftContentController.java
  8. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java
  9. 5
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticlePublishRangeEntity.java
  10. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftEntity.java
  11. 5
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftPublishRangeEntity.java
  12. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/excel/ArticleExcel.java
  13. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/excel/DraftExcel.java
  14. 10
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java
  15. 220
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  16. 277
      epmet-module/gov-voice/gov-voice-server/src/main/resources/migration/epmet_gov_voice.sql
  17. 45
      epmet-module/gov-voice/gov-voice-server/src/test/java/com/epmet/ArticleServiceTest.java

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

@ -17,9 +17,10 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -81,7 +82,7 @@ public class ArticleDTO implements Serializable {
/**
* 发布单位类型 机关:agency部门department网格grid
*/
private Integer publisherType;
private String publisherType;
/**
* 发布时间

8
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/ArticlePublishRangeDTO.java

@ -17,9 +17,10 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -53,6 +54,11 @@ public class ArticlePublishRangeDTO implements Serializable {
*/
private String gridId;
/**
* 组织-网格名称
*/
private String agencyGridName;
/**
* 下线时间
*/

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

@ -17,9 +17,10 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -76,7 +77,7 @@ public class DraftDTO implements Serializable {
/**
* 发布单位类型 机关:agency部门department网格grid
*/
private Integer publisherType;
private String publisherType;
/**
* 发布时间

8
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/DraftPublishRangeDTO.java

@ -17,9 +17,10 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -53,6 +54,11 @@ public class DraftPublishRangeDTO implements Serializable {
*/
private String gridId;
/**
* 组织-网格名称
*/
private String agencyGridName;
/**
* 下线时间
*/

80
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftContentFromDTO.java

@ -0,0 +1,80 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 保存文章内容form
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-06-02
*/
@Data
public class DraftContentFromDTO implements Serializable {
private static final long serialVersionUID = -4206020151361420221L;
/**
* 草稿ID
*/
private String draftId;
/**
* 文章标题
*/
@NotBlank(message = "文章标题不能为空")
private String title;
/**
* 内容列表
*/
private List<DraftContentDTO> contentList;
@Data
public static class DraftContentDTO {
public DraftContentDTO() {
}
/**
* 内容Id
*/
private String draftContentId;
/**
* 内容
*/
private String content;
/**
* 内容类型 图片img文字text
*/
private String contentType;
/**
* 内容顺序 从1开始
*/
private Integer orderNum;
}
}

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

@ -25,10 +25,10 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.ArticleDTO;
import com.epmet.dto.form.LatestListFormDTO;
import com.epmet.dto.form.DraftContentFromDTO;
import com.epmet.dto.result.ArticleGridResultDTO;
import com.epmet.dto.result.LatestListResultDTO;
import com.epmet.dto.result.PublishAgencyListResultDTO;
@ -108,6 +108,17 @@ public class ArticleController {
return new Result<ArticleGridResultDTO>().ok(articleService.agencyGridList(tokenDTO));
}
/**
* desc:保存或修改文章内容
* @param fromDTO
* @throws Exception
*/
@GetMapping("savecontent")
public Result<String> saveOrUpdateContent(@LoginUser TokenDto tokenDto,@RequestBody DraftContentFromDTO fromDTO) throws Exception {
String draftId = articleService.saveOrUpdateContent(tokenDto, fromDTO);
return new Result<String>().ok(draftId);
}
/**
* @param tokenDTO
* @return

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

@ -23,8 +23,8 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.DraftContentDTO;
import com.epmet.excel.DraftContentExcel;
import com.epmet.service.DraftContentService;

2
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticleEntity.java

@ -81,7 +81,7 @@ public class ArticleEntity extends BaseEpmetEntity {
/**
* 发布单位类型 机关:agency部门department网格grid
*/
private Integer publisherType;
private String publisherType;
/**
* 发布时间

5
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/ArticlePublishRangeEntity.java

@ -53,6 +53,11 @@ public class ArticlePublishRangeEntity extends BaseEpmetEntity {
*/
private String gridId;
/**
* 组织-网格名称
*/
private String agencyGridName;
/**
* 下线时间
*/

2
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftEntity.java

@ -76,7 +76,7 @@ public class DraftEntity extends BaseEpmetEntity {
/**
* 发布单位类型 机关:agency部门department网格grid
*/
private Integer publisherType;
private String publisherType;
/**
* 发布时间

5
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/DraftPublishRangeEntity.java

@ -53,6 +53,11 @@ public class DraftPublishRangeEntity extends BaseEpmetEntity {
*/
private String gridId;
/**
* 组织-网格名称
*/
private String agencyGridName;
/**
* 下线时间
*/

2
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/excel/ArticleExcel.java

@ -59,7 +59,7 @@ public class ArticleExcel {
private String publisherName;
@Excel(name = "发布单位类型 机关:agency;部门:department;网格:grid")
private Integer publisherType;
private String publisherType;
@Excel(name = "发布时间")
private Date publishDate;

2
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/excel/DraftExcel.java

@ -56,7 +56,7 @@ public class DraftExcel {
private String publisherName;
@Excel(name = "发布单位类型 机关:agency;部门:department;网格:grid")
private Integer publisherType;
private String publisherType;
@Excel(name = "发布时间")
private Date publishDate;

10
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/ArticleService.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.ArticleDTO;
import com.epmet.dto.result.ArticleGridResultDTO;
import com.epmet.dto.form.DraftContentFromDTO;
import com.epmet.dto.result.PublishAgencyListResultDTO;
import com.epmet.entity.ArticleEntity;
@ -104,6 +105,15 @@ public interface ArticleService extends BaseService<ArticleEntity> {
**/
ArticleGridResultDTO agencyGridList(TokenDto tokenDTO);
/**
* desc:保存或修改文章内容
*
* @param tokenDto
* @param fromDTO
* @return
*/
String saveOrUpdateContent(TokenDto tokenDto, DraftContentFromDTO fromDTO);
/**
* @param tokenDTO
* @return

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

@ -16,32 +16,42 @@
*/
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dao.ArticleDao;
import com.epmet.dao.DraftContentDao;
import com.epmet.dao.DraftDao;
import com.epmet.dto.ArticleDTO;
import com.epmet.dto.feign.GovOrgSelfFeignClient;
import com.epmet.dto.form.DraftContentFromDTO;
import com.epmet.dto.result.ArticleGridResultDTO;
import com.epmet.dto.result.PublishAgencyListResultDTO;
import com.epmet.entity.ArticleEntity;
import com.epmet.entity.DraftContentEntity;
import com.epmet.entity.DraftEntity;
import com.epmet.redis.ArticleRedis;
import com.epmet.service.ArticleService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 文章表
@ -51,63 +61,71 @@ import java.util.Map;
*/
@Service
public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntity> implements ArticleService {
private final Log logger = LogFactory.getLog(getClass());
@Autowired
private ArticleRedis articleRedis;
@Autowired
private GovOrgSelfFeignClient govOrgSelfFeignClient;
@Override
public PageData<ArticleDTO> page(Map<String, Object> params) {
IPage<ArticleEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ArticleDTO.class);
}
@Override
public List<ArticleDTO> list(Map<String, Object> params) {
List<ArticleEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ArticleDTO.class);
}
private QueryWrapper<ArticleEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<ArticleEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public ArticleDTO get(String id) {
ArticleEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ArticleDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ArticleDTO dto) {
ArticleEntity entity = ConvertUtils.sourceToTarget(dto, ArticleEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ArticleDTO dto) {
ArticleEntity entity = ConvertUtils.sourceToTarget(dto, ArticleEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Autowired
private DraftDao draftDao;
@Autowired
private DraftContentDao draftContentDao;
@Autowired
private ArticleDao articleDao;
@Override
public PageData<ArticleDTO> page(Map<String, Object> params) {
IPage<ArticleEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ArticleDTO.class);
}
@Override
public List<ArticleDTO> list(Map<String, Object> params) {
List<ArticleEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ArticleDTO.class);
}
private QueryWrapper<ArticleEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<ArticleEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public ArticleDTO get(String id) {
ArticleEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ArticleDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ArticleDTO dto) {
ArticleEntity entity = ConvertUtils.sourceToTarget(dto, ArticleEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ArticleDTO dto) {
ArticleEntity entity = ConvertUtils.sourceToTarget(dto, ArticleEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* @param tokenDTO
@ -133,4 +151,92 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
return result.getData();
}
@Override
@Transactional(rollbackFor = Exception.class)
public String saveOrUpdateContent(TokenDto tokenDto, DraftContentFromDTO fromDTO) {
logger.debug("saveOrUpdateContent param:" + JSON.toJSONString(fromDTO));
ValidatorUtils.validateEntity(fromDTO, AddGroup.class, DefaultGroup.class);
DraftEntity draftEntity = null;
List<DraftContentEntity> draftContentList = null;
if (StringUtils.isNotBlank(fromDTO.getDraftId())) {
draftEntity = draftDao.selectById(fromDTO.getDraftId());
if (draftEntity == null) {
logger.warn("saveOrUpdateContent draftId is not exist in db");
throw new RenException("参数错误");
}
draftEntity.setTitle(draftEntity.getTitle());
draftEntity.setUpdatedTime(new Date());
draftDao.updateById(draftEntity);
} else {
draftEntity = new DraftEntity();
draftEntity.setTitle(fromDTO.getTitle());
draftEntity.setCustomerId(tokenDto.getCustomerId());
draftEntity.setPreviewContent("");
draftEntity.setIsTop(0);
draftEntity.setPublishRangeDesc("");
draftEntity.setPublisherId("");
draftEntity.setPublisherName("");
draftEntity.setPublisherType("");
draftEntity.setPublishDate(new Date());
draftEntity.setStatusFlag("");
draftEntity.setTags("");
draftEntity.setOrgId("");
draftEntity.setOrgIdPath("");
draftEntity.setGridId("");
draftEntity.setDepartmentId("");
draftEntity.setRevision(0);
draftEntity.setDelFlag(NumConstant.ZERO_STR);
draftDao.insert(draftEntity);
}
String draftId = draftEntity.getId();
fromDTO.setDraftId(draftId);
draftContentList = buildDraftContent(tokenDto,fromDTO);
if (CollectionUtils.isEmpty(draftContentList)) {
logger.warn("saveOrUpdateContent contentList is empty");
throw new RenException("参数错误");
}
Map<String, Object> draftIdMap = new HashMap<>();
draftIdMap.put("DRAFT_ID", fromDTO.getDraftId());
draftContentDao.deleteByMap(draftIdMap);
//TODO 改为批量插入
draftContentList.forEach(content -> draftContentDao.insert(content));
return draftId;
}
/**
* desc构建 内容对象
*
*
* @param tokenDto
* @param fromDTO
* @return
*/
private List<DraftContentEntity> buildDraftContent(TokenDto tokenDto, DraftContentFromDTO fromDTO) {
//如果已发布 则需要校验内容是否更改过 没有更改则 不对审核状态进行重置
List<DraftContentEntity> newContentList = new ArrayList<>();
List<DraftContentFromDTO.DraftContentDTO> contentList = fromDTO.getContentList();
Set<Integer> orderNumSet = new HashSet<>();
contentList.forEach(content -> {
DraftContentEntity entity = ConvertUtils.sourceToTarget(content, DraftContentEntity.class);
entity.setId(content.getDraftContentId());
entity.setCustomerId(tokenDto.getCustomerId());
entity.setDraftId(fromDTO.getDraftId());
orderNumSet.add(content.getOrderNum());
newContentList.add(entity);
});
if (orderNumSet.size() != newContentList.size()) {
logger.warn("saveOrUpdateContent contentList orderNum is repeat");
throw new RenException("参数错误");
}
return newContentList;
}
}

277
epmet-module/gov-voice/gov-voice-server/src/main/resources/migration/epmet_gov_voice.sql

@ -0,0 +1,277 @@
DROP TABLE tag_default;/*SkipError*/
CREATE TABLE tag_default(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
TAG_NAME VARCHAR(32) NOT NULL COMMENT '标签名称' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '默认标签表 默认标签表';
ALTER TABLE tag_default COMMENT '默认标签表';
DROP TABLE tag_customer;/*SkipError*/
CREATE TABLE tag_customer(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
TAG_NAME VARCHAR(32) NOT NULL COMMENT '标签名称' ,
USE_COUNT INT NOT NULL DEFAULT 0 COMMENT '使用计数' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '客户标签表 客户标签表';
ALTER TABLE tag_customer ADD INDEX INX_TAG_NAME(TAG_NAME);
ALTER TABLE tag_customer COMMENT '客户标签表';
DROP TABLE tag_grid;/*SkipError*/
CREATE TABLE tag_grid(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
GRID_ID VARCHAR(64) NOT NULL COMMENT '网格ID' ,
TAG_ID VARCHAR(64) NOT NULL COMMENT '标签ID' ,
TAG_NAME VARCHAR(32) NOT NULL COMMENT '标签名称' ,
USE_COUNT INT NOT NULL DEFAULT 0 COMMENT '使用计数' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '网格标签表 网格标签表';
ALTER TABLE tag_grid COMMENT '网格标签表';
DROP TABLE article_tags;/*SkipError*/
CREATE TABLE article_tags(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
ARTICLE_ID VARCHAR(64) NOT NULL COMMENT '文章ID' ,
TAG_ID VARCHAR(64) NOT NULL COMMENT '标签ID' ,
TAG_NAME VARCHAR(32) NOT NULL COMMENT '标签名称' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '文章标签表 文章标签表';
ALTER TABLE article_tags ADD INDEX IDX_ARTICLE_ID(ARTICLE_ID);
ALTER TABLE article_tags COMMENT '文章标签表';
DROP TABLE draft;/*SkipError*/
CREATE TABLE draft(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
TITLE VARCHAR(128) NOT NULL COMMENT '文章标题' ,
PREVIEW_CONTENT VARCHAR(512) NOT NULL COMMENT '文章内容 精简内容' ,
IS_TOP INT NOT NULL COMMENT '是否置顶 1是;0否;' ,
PUBLISH_RANGE_DESC VARCHAR(512) NOT NULL COMMENT '发布范围描述 所有发布范围集合' ,
PUBLISHER_ID VARCHAR(64) NOT NULL COMMENT '发布单位ID' ,
PUBLISHER_NAME VARCHAR(128) NOT NULL COMMENT '发布单位名称' ,
PUBLISHER_TYPE VARCHAR(32) NOT NULL COMMENT '发布单位类型 机关:agency;部门:department;网格:grid' ,
PUBLISH_DATE DATE NOT NULL COMMENT '发布时间' ,
STATUS_FLAG VARCHAR(32) NOT NULL COMMENT '发布状态 未发布:unpublish ;已发布:published,审核中:auditing;审核失败:auditfail' ,
TAGS VARCHAR(512) NOT NULL COMMENT '文章标签串 竖杠分割的标签名称' ,
ORG_ID VARCHAR(64) COMMENT '组织ID' ,
ORG_ID_PATH VARCHAR(512) COMMENT '组织ID路径 eg:字段为def:abc' ,
GRID_ID VARCHAR(64) COMMENT '网格ID 数据权限使用' ,
DEPARTMENT_ID VARCHAR(32) COMMENT '部门ID 数据权限使用' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '草稿表 草稿表';
ALTER TABLE draft COMMENT '草稿表';
DROP TABLE draft_content;/*SkipError*/
CREATE TABLE draft_content(
ID VARCHAR(64) NOT NULL COMMENT '主键ID 主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
DRAFT_ID VARCHAR(64) NOT NULL COMMENT '草稿ID' ,
CONTENT VARCHAR(1024) NOT NULL COMMENT '内容' ,
CONTENT_TYPE VARCHAR(32) NOT NULL COMMENT '内容类型 图片:img;文字:text' ,
AUDIT_STATUS VARCHAR(32) COMMENT '审核状态 通过:pass;失败:fail;审核中:auditing;' ,
AUDIT_REASON VARCHAR(128) COMMENT '审核理由' ,
ORDER_NUM INT NOT NULL COMMENT '内容顺序 从1开始' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '草稿内容表 草稿内容表';
ALTER TABLE draft_content COMMENT '草稿内容表';
DROP TABLE draft_publish_range;/*SkipError*/
CREATE TABLE draft_publish_range(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
DRAFT_ID VARCHAR(64) NOT NULL COMMENT 'ID草稿' ,
GRID_ID VARCHAR(64) NOT NULL COMMENT '网格ID' ,
AGENCY_GRID_NAME VARCHAR(64) NOT NULL COMMENT '组织-网格名称' ,
OFF_LINE_TIME DATETIME COMMENT '下线时间' ,
PUBLISH_STATUS VARCHAR(32) NOT NULL COMMENT '发布状态 未发布:unpublish ;已发布:published' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '草稿发布范围表 草稿发布范围表';
ALTER TABLE draft_publish_range COMMENT '草稿发布范围表';
DROP TABLE draft_cover;/*SkipError*/
CREATE TABLE draft_cover(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
DRAFT_ID VARCHAR(64) NOT NULL COMMENT '草稿ID' ,
IMG_URL VARCHAR(512) NOT NULL COMMENT '封面图片地址 url地址' ,
AUDIT_STATUS VARCHAR(32) COMMENT '审核状态 通过:pass;失败:fail;审核中:auditing;' ,
AUDIT_REASON VARCHAR(128) COMMENT '审核理由' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '草稿封面表 草稿封面表';
ALTER TABLE draft_cover COMMENT '草稿封面表';
DROP TABLE article;/*SkipError*/
CREATE TABLE article(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
DRAFT_ID VARCHAR(64) NOT NULL COMMENT '草稿ID' ,
TITLE VARCHAR(128) NOT NULL COMMENT '文章标题' ,
PREVIEW_CONTENT VARCHAR(512) NOT NULL COMMENT '文章内容 精简内容' ,
IS_TOP INT NOT NULL COMMENT '是否置顶 1是;0否;' ,
PUBLISH_RANGE_DESC VARCHAR(512) NOT NULL COMMENT '发布范围描述 所有发布范围集合,顿号隔开' ,
PUBLISHER_ID VARCHAR(64) NOT NULL COMMENT '发布单位ID' ,
PUBLISHER_NAME VARCHAR(128) NOT NULL COMMENT '发布单位名称' ,
PUBLISHER_TYPE VARCHAR(32) NOT NULL COMMENT '发布单位类型 机关:agency;部门:department;网格:grid' ,
PUBLISH_DATE DATE NOT NULL COMMENT '发布时间' ,
STATUS_FLAG VARCHAR(32) NOT NULL DEFAULT 0 COMMENT '发布状态 已发布:published;已下线:offline' ,
OFF_LINE_TIME DATETIME COMMENT '下线时间' ,
TAGS VARCHAR(512) COMMENT '文章标签串 竖杠分割的标签名称' ,
ORG_ID VARCHAR(64) COMMENT '组织ID' ,
ORG_ID_PATH VARCHAR(512) COMMENT '组织ID路径 eg:字段为def:abc' ,
GRID_ID VARCHAR(64) COMMENT '网格ID 数据权限使用' ,
DEPARTMENT_ID VARCHAR(32) COMMENT '部门ID 数据权限使用' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '文章表 正式文章表';
ALTER TABLE article COMMENT '文章表';
DROP TABLE article_content;/*SkipError*/
CREATE TABLE article_content(
ID VARCHAR(64) NOT NULL COMMENT '主键ID 主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
ARTICLE_ID VARCHAR(64) NOT NULL COMMENT '文章ID' ,
CONTENT VARCHAR(1024) NOT NULL COMMENT '内容' ,
CONTENT_TYPE VARCHAR(32) NOT NULL COMMENT '内容类型 图片:img;文字:text' ,
AUDIT_STATUS VARCHAR(32) COMMENT '审核状态 通过:pass;失败:fail;审核中:auditing;' ,
AUDIT_REASON VARCHAR(128) COMMENT '审核理由' ,
ORDER_NUM INT NOT NULL COMMENT '内容顺序 从1开始' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '文章内容表 文章内容表';
ALTER TABLE article_content COMMENT '文章内容表';
DROP TABLE article_cover;/*SkipError*/
CREATE TABLE article_cover(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
ARTICLE_ID VARCHAR(64) NOT NULL COMMENT '文章ID' ,
IMG_URL VARCHAR(512) NOT NULL COMMENT '封面图片地址 url地址' ,
AUDIT_STATUS VARCHAR(32) COMMENT '审核状态 通过:pass;失败:fail;审核中:auditing' ,
AUDIT_REASON VARCHAR(128) COMMENT '审核理由' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '文章封面表 文章封面表';
ALTER TABLE article_cover COMMENT '文章封面表';
DROP TABLE article_publish_range;/*SkipError*/
CREATE TABLE article_publish_range(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
ARTICLE_ID VARCHAR(64) NOT NULL COMMENT '文章ID' ,
GRID_ID VARCHAR(64) NOT NULL COMMENT '网格ID' ,
AGENCY_GRID_NAME VARCHAR(64) NOT NULL COMMENT '组织-网格名称' ,
OFF_LINE_TIME DATETIME COMMENT '下线时间' ,
PUBLISH_STATUS VARCHAR(32) NOT NULL COMMENT '发布状态 未发布:unpublish ;已发布:published' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '文章发布范围表 文章发布范围表';
ALTER TABLE article_publish_range ADD INDEX IDX_ARTICLE_ID(ARTICLE_ID);
ALTER TABLE article_publish_range COMMENT '文章发布范围表';
DROP TABLE article_operate_record;/*SkipError*/
CREATE TABLE article_operate_record(
ID VARCHAR(64) NOT NULL COMMENT '主键ID 主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
ARTICLE_ID VARCHAR(64) NOT NULL COMMENT '文章ID' ,
OP_USER VARCHAR(128) NOT NULL COMMENT '执行人 xx街道-xx中心-姓名' ,
CONTENT VARCHAR(512) NOT NULL COMMENT '操作内容 操作内容,eg:重新编辑文章;' ,
OP_TYPE VARCHAR(32) NOT NULL COMMENT '操作类型 发布文章:publish;取消文章置顶:canceltop;设置置顶:settom;下线文章:offline;修改文章发布范围:updatepublishrange' ,
OP_TIME DATETIME NOT NULL COMMENT '操作时间' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '文章操作记录表 文章操作记录表';
ALTER TABLE article_operate_record COMMENT '文章操作记录表';
DROP TABLE article_visit_record;/*SkipError*/
CREATE TABLE article_visit_record(
ID VARCHAR(64) NOT NULL COMMENT '主键ID' ,
CUSTOMER_ID VARCHAR(64) NOT NULL COMMENT '客户ID' ,
GRID_ID VARCHAR(64) NOT NULL COMMENT '网格ID' ,
ARTICLE_ID VARCHAR(64) NOT NULL COMMENT '文章ID' ,
USER_ID VARCHAR(64) NOT NULL COMMENT '用户ID' ,
DEL_FLAG INT NOT NULL DEFAULT 0 COMMENT '删除标识 0.未删除 1.已删除' ,
REVISION INT NOT NULL COMMENT '乐观锁' ,
CREATED_BY VARCHAR(32) NOT NULL COMMENT '创建人' ,
CREATED_TIME DATETIME NOT NULL COMMENT '创建时间' ,
UPDATED_BY VARCHAR(32) NOT NULL COMMENT '更新人' ,
UPDATED_TIME DATETIME NOT NULL COMMENT '更新时间' ,
PRIMARY KEY (ID)
) COMMENT = '文章访问记录表 文章访问记录表';
ALTER TABLE article_visit_record ADD UNIQUE UNX_INDEX(ARTICLE_ID,GRID_ID,USER_ID);
ALTER TABLE article_visit_record COMMENT '文章访问记录表';

45
epmet-module/gov-voice/gov-voice-server/src/test/java/com/epmet/ArticleServiceTest.java

@ -0,0 +1,45 @@
package com.epmet;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.form.DraftContentFromDTO;
import com.epmet.service.ArticleService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ArticleServiceTest {
@Autowired
private ArticleService articleService;
@Test
public void genToken() {
TokenDto tokenDto = new TokenDto();
tokenDto.setCustomerId("1");
tokenDto.setUserId("1");
DraftContentFromDTO draftContentFromDTO = new DraftContentFromDTO();
//draftContentFromDTO.setDraftId("1");
draftContentFromDTO.setTitle("testTitle");
List<DraftContentFromDTO.DraftContentDTO> list = new ArrayList<>();
for (int i = 0; i <2 ; i++) {
DraftContentFromDTO.DraftContentDTO contentDTO = new DraftContentFromDTO.DraftContentDTO();
contentDTO.setDraftContentId("");
contentDTO.setContent("内容"+i);
contentDTO.setContentType("text");
contentDTO.setOrderNum(1+i);
list.add(contentDTO);
}
draftContentFromDTO.setContentList(list);
String s = articleService.saveOrUpdateContent(tokenDto, draftContentFromDTO);
System.out.println(s);
}
}
Loading…
Cancel
Save