三审相关代码
This commit is contained in:
parent
0330592c7c
commit
0df4a277dd
|
|
@ -123,7 +123,7 @@ public class NewsController {
|
|||
return ResultObject.failed("该资讯正在审核中,请勿重复操作!");
|
||||
}
|
||||
log.info("path: /news/revoke, method: POST, request user id: {}, news id: {}", adminUserId, id);
|
||||
return newsService.revoke(id, adminUserId, adminUser.isReviewer());
|
||||
return newsService.revoke(id, adminUserId, adminUser.isReviewer(), adminUser.isSecondReviewer());
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
|
|
@ -152,6 +152,9 @@ public class NewsController {
|
|||
log.warn("当前用户已被封禁! id = {}", adminUserId);
|
||||
return ResultObject.failed("当前用户已被封禁!请联系系统管理员!");
|
||||
}
|
||||
if (!adminUser.isReviewer()) {
|
||||
return ResultObject.failed("无此权限,非法操作!");
|
||||
}
|
||||
|
||||
Long id = publishNewsDTO.getId();
|
||||
if (id == null) {
|
||||
|
|
@ -280,6 +283,7 @@ public class NewsController {
|
|||
log.warn("当前用户已被封禁! id = {}", adminUserId);
|
||||
return ResultObject.failed("当前用户已被封禁!请联系系统管理员!");
|
||||
}
|
||||
|
||||
log.info("path: /news/create/publish, method: POST, request user id: {}, param: {}",
|
||||
adminUserId, objectMapper.writeValueAsString(saveNewsDTO));
|
||||
boolean isSuccessed = setEditingFlag(saveNewsDTO.getId());
|
||||
|
|
@ -366,13 +370,19 @@ public class NewsController {
|
|||
adminUser.getId(), keyword, columnList, status, page, size, last, current, orderBy, tag, industry);
|
||||
|
||||
boolean isReviewRange = false;
|
||||
boolean isSecondReviewRange = false;
|
||||
if ("review".equals(range)) {
|
||||
if (!adminUser.isReviewer()) {
|
||||
return PageObject.failedPage(500, "非审核员用户查看范围权限!");
|
||||
}
|
||||
isReviewRange = true;
|
||||
} else if ("secondReview".equals(range)) {
|
||||
if (!adminUser.isSecondReviewer()) {
|
||||
return PageObject.failedPage(500, "非二审用户无查看此范围权限!");
|
||||
}
|
||||
isSecondReviewRange = true;
|
||||
}
|
||||
return newsService.queryNews(keyword, columnList, status, page, size, last, current, orderBy, minScore, maxScore, tag, industry, mediaId, datelineFrom, datelineTo, deleted, rating, isReviewRange);
|
||||
return newsService.queryNews(keyword, columnList, status, page, size, last, current, orderBy, minScore, maxScore, tag, industry, mediaId, datelineFrom, datelineTo, deleted, rating, isReviewRange, isSecondReviewRange);
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
|
||||
|
|
@ -466,6 +476,91 @@ public class NewsController {
|
|||
}
|
||||
}
|
||||
|
||||
@PostMapping("/check")
|
||||
@OperationInfo(behavior = "复审", type = "news")
|
||||
public ResultObject<Void> check(@RequestHeader("auth-token") String token,
|
||||
@RequestBody PublishNewsDTO publishNewsDTO) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
try {
|
||||
AdminUser adminUser = AdminJwtService.parseToken(token);
|
||||
if (adminUser == null) {
|
||||
log.warn("解析token {}拿不到AdminUser对象!", token);
|
||||
return ResultObject.failed("登陆Token有误,请联系系统管理员!");
|
||||
}
|
||||
|
||||
Long adminUserId = adminUser.getId();
|
||||
if (!adminUser.isActive()) {
|
||||
log.warn("当前用户已被封禁! id = {}", adminUserId);
|
||||
return ResultObject.failed("当前用户已被封禁!请联系系统管理员!");
|
||||
}
|
||||
|
||||
if (!adminUser.isSecondReviewer()) {
|
||||
return ResultObject.failed("无相关权限,非法操作!");
|
||||
}
|
||||
|
||||
Long id = publishNewsDTO.getId();
|
||||
if (id == null) {
|
||||
return ResultObject.failed("要复审的新闻ID不可为空!");
|
||||
}
|
||||
boolean isSuccessed = setEditingFlag(id);
|
||||
if (!isSuccessed) {
|
||||
return ResultObject.failed("该资讯正在复审中,请勿重复操作!");
|
||||
}
|
||||
log.info("path: /news/check, method: POST, request user id: {}, news id: {}", adminUserId, id);
|
||||
return newsService.check(id, adminUserId);
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
} finally {
|
||||
unsetEditingFlag(publishNewsDTO.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/return")
|
||||
@OperationInfo(behavior = "退改", type = "news")
|
||||
public ResultObject<Void> sendback(@RequestHeader("auth-token") String token,
|
||||
@RequestBody PublishNewsDTO publishNewsDTO) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
try {
|
||||
AdminUser adminUser = AdminJwtService.parseToken(token);
|
||||
if (adminUser == null) {
|
||||
log.warn("解析token {}拿不到AdminUser对象!", token);
|
||||
return ResultObject.failed("登陆Token有误,请联系系统管理员!");
|
||||
}
|
||||
|
||||
Long adminUserId = adminUser.getId();
|
||||
if (!adminUser.isActive()) {
|
||||
log.warn("当前用户已被封禁! id = {}", adminUserId);
|
||||
return ResultObject.failed("当前用户已被封禁!请联系系统管理员!");
|
||||
}
|
||||
|
||||
Long id = publishNewsDTO.getId();
|
||||
if (id == null) {
|
||||
return ResultObject.failed("要送审的新闻ID不可为空!");
|
||||
}
|
||||
if (!(adminUser.isReviewer()||adminUser.isSecondReviewer())) {
|
||||
return ResultObject.failed("无相关权限,非法操作");
|
||||
}
|
||||
boolean isSuccessed = setEditingFlag(id);
|
||||
if (!isSuccessed) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作!");
|
||||
}
|
||||
log.info("path: /news/sendback, method: POST, request user id: {}, news id: {}", adminUserId, id);
|
||||
return newsService.sendback(id, adminUserId, adminUser.isReviewer(), adminUser.isSecondReviewer());
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
} finally {
|
||||
unsetEditingFlag(publishNewsDTO.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param newsId
|
||||
|
|
|
|||
|
|
@ -154,4 +154,8 @@ public class AdminUser {
|
|||
public boolean isReviewer() {
|
||||
return Objects.equals(userType, "01");
|
||||
}
|
||||
|
||||
public boolean isSecondReviewer() {
|
||||
return Objects.equals(userType, "02");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
server:
|
||||
port: 13579
|
||||
compression:
|
||||
|
|
@ -22,21 +25,21 @@ spring:
|
|||
# url: jdbc:mysql://192.168.0.142:3306/reference?autoReconnect=true&useUnicode=true&useSSL=false&allowMultiQueries=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
# username: financial_prod
|
||||
# password: mmTFncqmDal5HLRGY0BV
|
||||
url: jdbc:mysql://10.127.2.207:3306/reference?autoReconnect=true&useUnicode=true&useSSL=false&allowMultiQueries=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
username: financial_prod
|
||||
password: mmTFncqmDal5HLRGY0BV
|
||||
url: jdbc:mysql://121.37.185.246:3306/reference?autoReconnect=true&useUnicode=true&useSSL=false&allowMultiQueries=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: Xgf_8000
|
||||
redis:
|
||||
# host: 192.168.0.172
|
||||
# port: 6379
|
||||
# password: Xgf_redis
|
||||
host: 10.127.2.209
|
||||
host: 123.60.153.169
|
||||
port: 6379
|
||||
password: dMrt4kmwiW6LDJXy
|
||||
password: Xgf_redis
|
||||
elasticsearch:
|
||||
scheme: http
|
||||
# 111.13.176.3 部署地址
|
||||
# 10.127.2.194 本地测试地址
|
||||
host: 10.127.2.194
|
||||
host: 111.13.176.3
|
||||
port: 9200
|
||||
enable: true
|
||||
username: elastic
|
||||
|
|
|
|||
|
|
@ -144,7 +144,10 @@ public interface NewsMapper {
|
|||
"and news.id > #{last}" +
|
||||
"</if>" +
|
||||
"<if test=\"isReviewer == true\">" +
|
||||
"and news.status in (2, 3) " +
|
||||
"and news.status in (-1, 2, 4) " +
|
||||
"</if>" +
|
||||
"<if test=\"isSecondReviewRange == true\">" +
|
||||
"and news.status in (-1, 2, 3, 4) " +
|
||||
"</if>" +
|
||||
"</where>" +
|
||||
"<if test=\"orderBy != null\">" +
|
||||
|
|
@ -167,7 +170,8 @@ public interface NewsMapper {
|
|||
@Param("datelineTo") Date datelineTo,
|
||||
@Param("deleted") Integer deleted,
|
||||
@Param("rating") Byte rating,
|
||||
@Param("isReviewer") boolean isReviewer);
|
||||
@Param("isReviewer") boolean isReviewer,
|
||||
@Param("isSecondReviewRange") boolean isSecondReviewRange);
|
||||
|
||||
@Select("<script>" +
|
||||
"select count(*) from (select distinct news.* from news " +
|
||||
|
|
@ -224,7 +228,10 @@ public interface NewsMapper {
|
|||
"and news.rating = #{rating} " +
|
||||
"</if>" +
|
||||
"<if test=\"isReviewer == true\">" +
|
||||
"and news.status in (2, 3) " +
|
||||
"and news.status in (-1, 2, 4) " +
|
||||
"</if>" +
|
||||
"<if test=\"isSecondReviewRange == true\">" +
|
||||
"and news.status in (-1, 2, 3, 4) " +
|
||||
"</if>" +
|
||||
"</where>) tmp" +
|
||||
"</script>")
|
||||
|
|
@ -239,7 +246,8 @@ public interface NewsMapper {
|
|||
@Param("datelineTo") Date datelineTo,
|
||||
@Param("deleted") Integer deleted,
|
||||
@Param("rating") Byte rating,
|
||||
@Param("isReviewer") boolean isReviewer);
|
||||
@Param("isReviewer") boolean isReviewer,
|
||||
@Param("isSecondReviewRange") boolean isSecondReviewRange);
|
||||
|
||||
@Select("select id, llm_title as title, summary, picture, llm_content as content, status, " +
|
||||
"create_time as createTime, " +
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class News {
|
|||
private String contentText;
|
||||
|
||||
/**
|
||||
* 新闻状态 0-草稿 | 1-未发布 | 2-已发布 | 3-送审
|
||||
* 新闻状态 0-草稿 | 1-未发布 | 2-已发布 | 3-送审 | 4-已二审 | -1-退改中
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
|
@ -122,9 +123,8 @@ public class NewsService {
|
|||
if (oldStatus == 1) {
|
||||
return ResultObject.failed("资讯已被撤稿,请刷新列表页面!");
|
||||
}
|
||||
if (oldStatus == 2) {
|
||||
newsMapper.changeFrom(id, oldStatus, 3, editorId);
|
||||
return ResultObject.success();
|
||||
if (oldStatus != 4) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作!");
|
||||
}
|
||||
|
||||
Long draftId = news.getDraftId();
|
||||
|
|
@ -376,8 +376,8 @@ public class NewsService {
|
|||
public ResultObject<Void> createPublish(Long editorId, SaveNewsDTO saveNewsDTO, boolean isReviewer) {
|
||||
Long id = saveNewsDTO.getId();
|
||||
Long newsId = saveNewsDTO.getId();
|
||||
Integer newStatus = (isReviewer ? 2: 3);
|
||||
Integer oldStatus = (isReviewer ? 3: 1);
|
||||
Integer newStatus = (isReviewer ? 2: 4);
|
||||
Integer oldStatus = (isReviewer ? 4: 1);
|
||||
News news;
|
||||
Long draftId = null;
|
||||
String newsInfoId = null;
|
||||
|
|
@ -803,7 +803,9 @@ public class NewsService {
|
|||
public PageObject<NewsVO> queryNews(String keyword, String columnParam, Integer status, int page, int size,
|
||||
Integer last, Integer current, String orderBy, Double minScore, Double maxScore,
|
||||
String tag, String industry, Long mediaId,
|
||||
Date datelineFrom, Date datelineTo, Integer deleted, Byte rating,boolean isReviewer) {
|
||||
Date datelineFrom, Date datelineTo, Integer deleted, Byte rating,
|
||||
boolean isReviewer,
|
||||
boolean isSecondReviewRange) {
|
||||
String orderByClause = null;
|
||||
if (StringUtils.hasText(orderBy)) {
|
||||
String orderByStr = orderBy;
|
||||
|
|
@ -868,7 +870,7 @@ public class NewsService {
|
|||
|
||||
List<News> newsList;
|
||||
try {
|
||||
newsList = newsMapper.queryNews(keywords, minScore, maxScore, columnParam, status, last, orderByClause, size, offset, tags, industries, datelineFrom, datelineTo, deleted, rating, isReviewer);
|
||||
newsList = newsMapper.queryNews(keywords, minScore, maxScore, columnParam, status, last, orderByClause, size, offset, tags, industries, datelineFrom, datelineTo, deleted, rating, isReviewer, isSecondReviewRange);
|
||||
} catch (Exception e) {
|
||||
log.error("搜索新闻异常!", e);
|
||||
return PageObject.failedPage(500, "服务器错误,请联系系统管理员!");
|
||||
|
|
@ -877,7 +879,7 @@ public class NewsService {
|
|||
PageObject<NewsVO> pageObject = new PageObject<>();
|
||||
if (page == 1) {
|
||||
try {
|
||||
int total = newsMapper.queryTotal(keywords,minScore, maxScore, columnParam, status, tags, industries, datelineFrom, datelineTo, deleted, rating, isReviewer);
|
||||
int total = newsMapper.queryTotal(keywords,minScore, maxScore, columnParam, status, tags, industries, datelineFrom, datelineTo, deleted, rating, isReviewer, isSecondReviewRange);
|
||||
pageObject.setTotal(total);
|
||||
} catch (Exception e) {
|
||||
log.error("获取新闻总数异常!", e);
|
||||
|
|
@ -1107,7 +1109,7 @@ public class NewsService {
|
|||
return ResultObject.failed("找不到ID为" + id + "的新闻!");
|
||||
}
|
||||
Integer oldStatus = news.getStatus();
|
||||
if (oldStatus != 1||news.getDeleted()) {
|
||||
if (!Objects.equals(oldStatus, 1)||news.getDeleted()||Objects.equals(oldStatus, -1)) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作");
|
||||
}
|
||||
|
||||
|
|
@ -1115,7 +1117,22 @@ public class NewsService {
|
|||
return ResultObject.success();
|
||||
}
|
||||
|
||||
public ResultObject<Void> revoke(Long id, Long editorId, boolean isReviewer) {
|
||||
public ResultObject<Void> check(long id, long editorId) {
|
||||
News news = newsMapper.getById(id);
|
||||
if (news == null) {
|
||||
log.warn("找不到ID为{}的新闻!", id);
|
||||
return ResultObject.failed("找不到ID为" + id + "的新闻!");
|
||||
}
|
||||
Integer oldStatus = news.getStatus();
|
||||
if (oldStatus != 3||news.getDeleted()) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作");
|
||||
}
|
||||
|
||||
newsMapper.changeFrom(id, oldStatus, 4, editorId);
|
||||
return ResultObject.success();
|
||||
}
|
||||
|
||||
public ResultObject<Void> revoke(Long id, Long editorId, boolean isReviewer, boolean isSecondReviewer) {
|
||||
News news = newsMapper.getById(id);
|
||||
if (news == null) {
|
||||
log.warn("找不到ID为{}的新闻!", id);
|
||||
|
|
@ -1126,6 +1143,13 @@ public class NewsService {
|
|||
if (oldStatus != 2||news.getDeleted()) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作");
|
||||
}
|
||||
newsMapper.changeFrom(id, oldStatus, 4, editorId);
|
||||
return ResultObject.success();
|
||||
}
|
||||
if (isSecondReviewer) {
|
||||
if (oldStatus != 4||news.getDeleted()) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作");
|
||||
}
|
||||
newsMapper.changeFrom(id, oldStatus, 3, editorId);
|
||||
return ResultObject.success();
|
||||
}
|
||||
|
|
@ -1138,6 +1162,30 @@ public class NewsService {
|
|||
return ResultObject.success();
|
||||
}
|
||||
|
||||
public ResultObject<Void> sendback(Long id, Long editorId, boolean isReviewer, boolean isSecondReviewer) {
|
||||
News news = newsMapper.getById(id);
|
||||
if (news == null) {
|
||||
log.warn("找不到ID为{}的新闻!", id);
|
||||
return ResultObject.failed("找不到ID为" + id + "的新闻!");
|
||||
}
|
||||
Integer oldStatus = news.getStatus();
|
||||
if (isReviewer) {
|
||||
if (oldStatus != 4||news.getDeleted()) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作");
|
||||
}
|
||||
newsMapper.changeFrom(id, oldStatus, -1, editorId);
|
||||
return ResultObject.success();
|
||||
}
|
||||
if (isSecondReviewer) {
|
||||
if (oldStatus != 3||news.getDeleted()) {
|
||||
return ResultObject.failed("该资讯正在审核中,请勿重复操作");
|
||||
}
|
||||
newsMapper.changeFrom(id, oldStatus, -1, editorId);
|
||||
return ResultObject.success();
|
||||
}
|
||||
return ResultObject.failed("无相关权限,非法操作");
|
||||
}
|
||||
|
||||
public PageObject<NewsLogVO> getLog(Long id, int page, int size, Integer current) {
|
||||
int offset = 0;
|
||||
if (current != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue