forked from Gitlink/microservices
feat(【专区管理】需要支持 栏目名称 更改): 重命名栏目操作调整为异步
1、新增sql:专区新增资讯锁定状态字段 2、新增远程接口:通过组织id锁定/解锁专区资讯 3、异步修改文章栏目时锁定专区资讯 4、操作专区资讯及资讯栏目时检查专区资讯是否处于锁定1状态,若处于锁定状态则抛出异常
This commit is contained in:
parent
fb494d0d55
commit
426ea624ef
|
|
@ -80,4 +80,17 @@ public interface RemoteZoneService {
|
|||
@DeleteMapping("/zoneDetail/{deptName}")
|
||||
public R<Boolean> deleteByDeptName(@PathVariable(value = "deptName") String deptName
|
||||
, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过组织id锁定/解锁专区资讯(0:未锁定,1:锁定)
|
||||
*
|
||||
* @param deptId 组织Id
|
||||
* @param lockStatus 锁定状态(0:未锁定,1:锁定)
|
||||
* @param source 来源
|
||||
* @return 结果
|
||||
*/
|
||||
@PutMapping("/zoneDetail/{deptId}/lockCms/{lockStatus}")
|
||||
public R<Boolean> lockCmsByDeptId(@PathVariable(value = "deptId") Long deptId
|
||||
, @PathVariable(value = "lockStatus") Integer lockStatus
|
||||
, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ public class RemoteZoneFallbackFactory implements FallbackFactory<RemoteZoneServ
|
|||
public R<Boolean> deleteByDeptName(String deptName, String source) {
|
||||
return R.fail("通过组织名称删除特色专区失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> lockCmsByDeptId(Long deptId, Integer lockStatus, String source) {
|
||||
return R.fail("通过组织id锁定/解锁专区资讯失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.ruoyi.common.httpClient.util.GitLinkRequestHelper;
|
|||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.system.api.RemoteDeptService;
|
||||
import com.ruoyi.system.api.RemoteZoneService;
|
||||
import com.ruoyi.system.api.utils.FeginUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -103,6 +104,10 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RemoteZoneService remoteZoneService;
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void asyncUpdateDoc(EntryDto entryDto, CmsDoc cmsDoc) {
|
||||
|
|
@ -851,6 +856,7 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
@Async
|
||||
public void asyncMoveFileToNewDir(CmsProject cmsProject, CmsDoc oldCmsDir, CmsDoc newCmsDir) {
|
||||
try {
|
||||
remoteZoneService.lockCmsByDeptId(cmsProject.getDeptId(), 1, SecurityConstants.INNER);
|
||||
//创建新栏目
|
||||
String message = String.format("重命名栏目:由[%s]重命名为[%s]", oldCmsDir.getName(), newCmsDir.getName());
|
||||
cmsDocService.createFileByGitLink(newCmsDir, message, "");
|
||||
|
|
@ -861,7 +867,10 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
//删除旧栏目
|
||||
deleteCmsDocByGitLink(cmsProject, oldCmsDir);
|
||||
} catch (Exception e) {
|
||||
logger.error("重命名栏目失败(原栏目名称[" + oldCmsDir.getName() + "],新栏目名称[" + newCmsDir.getName() + "]):{}", e.getMessage());
|
||||
throw new ServiceException("重命名栏目失败(原栏目名称[" + oldCmsDir.getName() + "],新栏目名称[" + newCmsDir.getName() + "])");
|
||||
} finally {
|
||||
remoteZoneService.lockCmsByDeptId(cmsProject.getDeptId(), 0, SecurityConstants.INNER);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Override
|
||||
public void updateCmsDir(Long id, CmsDirUpdateVo cmsDirUpdateVo) {
|
||||
CmsDoc oldCmsDir = selectCmsDir(id);
|
||||
checkCmsLockStatus(oldCmsDir.getDeptId());
|
||||
//设置栏目排序
|
||||
setCmsSort(cmsDirUpdateVo.getOrder(), oldCmsDir, false, null);
|
||||
updateCmsCommonDatabase(oldCmsDir, CmsConstants.BRANCH_MASTER);
|
||||
|
|
@ -259,6 +260,20 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
return cmsDocList.stream().map(x -> x.copyToCmsDocBaseDto()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查专区资讯是否处于锁定状态,若处于则抛出异常
|
||||
*
|
||||
* @param deptId
|
||||
*/
|
||||
private void checkCmsLockStatus(Long deptId) {
|
||||
JSONObject zoneJson = this.getZoneJSONByDeptId(deptId);
|
||||
String isLock = zoneJson.getString("isLockCms");
|
||||
if (CmsConstants.TRUE.equals(isLock)) {
|
||||
String name = zoneJson.getString("name");
|
||||
throw new ServiceException("当前专区资讯处于锁定状态,不允许修改(专区名称[%s])", name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文章信息
|
||||
*
|
||||
|
|
@ -271,16 +286,19 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
public boolean insertCmsDoc(Long dirId, CmsDocInputDto cmsDocInputDto) {
|
||||
//通过SHA获取栏目
|
||||
CmsDoc dirDoc = selectCmsDir(dirId);
|
||||
checkCmsLockStatus(dirDoc.getDeptId());
|
||||
CmsDoc cmsDoc = cmsDocInputDto.toCmsDoc(dirDoc);
|
||||
|
||||
if (isNoAuditRequired(dirDoc.getDeptId()) || isCurrentUserZoneAdmin(dirDoc.getDeptId())) {
|
||||
cmsDoc.setAuditStatus(DocAuditStatus.AUDIT_PASS.getAuditCode()); //文章自动置为审核通过状态值
|
||||
//文章自动置为审核通过状态值
|
||||
cmsDoc.setAuditStatus(DocAuditStatus.AUDIT_PASS.getAuditCode());
|
||||
return insertCommonCmsDoc(cmsDoc,
|
||||
"创建文章:" + StringUtils.truncateStringAndConcatenatingSpecifiedString(cmsDoc.getName(), 100, "..."),
|
||||
cmsDocInputDto.getContent());
|
||||
} else {
|
||||
//创建临时分支,创建文件,创建PR
|
||||
cmsDoc.setAuditStatus(DocAuditStatus.TO_BE_AUDIT.getAuditCode()); //文章待审核状态值
|
||||
//文章待审核状态值
|
||||
cmsDoc.setAuditStatus(DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
cmsDoc.setAuditType(DocAndZoneOperation.OPERATION_CREATE.getOperationCode());
|
||||
return insertCmsDocWithAudit(cmsDoc,
|
||||
"创建文章:" + StringUtils.truncateStringAndConcatenatingSpecifiedString(cmsDoc.getName(), 100, "..."),
|
||||
|
|
@ -331,6 +349,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Override
|
||||
public boolean auditCmsDoc(Long docId, CmsDocAuditVo cmsDocAuditVo) {
|
||||
CmsDoc cmsDoc = cmsDocMapper.selectCmsDocById(docId);
|
||||
checkCmsLockStatus(cmsDoc.getDeptId());
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(cmsDoc.getDeptId());
|
||||
if (cmsDocAuditVo.getPass() == 1) {
|
||||
//同意合并请求
|
||||
|
|
@ -422,7 +441,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleUpdatedCmsDocWithPass(CmsProject cmsProject, CmsDoc cmsDoc) {
|
||||
|
||||
Long newDocId = cmsDoc.getId();
|
||||
//同步更新人、发布人、发布人用户主页链接、发布人头像等信息
|
||||
cmsAsyncService.updateCmsPublishDataByGitLink(cmsProject, cmsDoc, CmsConstants.BRANCH_MASTER);
|
||||
|
|
@ -444,7 +462,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleCreatedCmsDocWithPass(CmsProject cmsProject, CmsDoc cmsDoc) {
|
||||
|
||||
//同步更新人、发布人、发布人用户主页链接、发布人头像等信息
|
||||
cmsAsyncService.updateCmsPublishDataByGitLink(cmsProject, cmsDoc, CmsConstants.BRANCH_MASTER);
|
||||
cmsDoc.setAuditStatus(DocAuditStatus.AUDIT_PASS.getAuditCode());
|
||||
|
|
@ -616,6 +633,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Override
|
||||
public boolean updateCmsDoc(Long id, CmsDocDto cmsDocDto) {
|
||||
CmsDoc oldCmsDoc = cmsDocMapper.selectCmsDocById(id);
|
||||
checkCmsLockStatus(oldCmsDoc.getDeptId());
|
||||
//用户为专区管理员或专区无审核机制时,直接更新文章及仓库主分支
|
||||
if (isCurrentUserZoneAdmin(oldCmsDoc.getDeptId()) || isNoAuditRequired(oldCmsDoc.getDeptId())) {
|
||||
//专区管理员重新编辑并提交审核未通过文章 或 重新编辑并提交待审核文章时专区不需审核机制
|
||||
|
|
@ -741,6 +759,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean insertCmsDocDir(Long deptId, CmsDir cmsDir) {
|
||||
checkCmsLockStatus(deptId);
|
||||
CmsDoc cmsDoc = new CmsDoc();
|
||||
cmsDoc.setIsDir(true);
|
||||
cmsDoc.setFilePath(cmsDoc.getDirPath(cmsDir.getName()));
|
||||
|
|
@ -1115,6 +1134,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
if (cmsDoc == null) {
|
||||
throw new ServiceException("该文章不存在(文章Id[" + id + "])");
|
||||
}
|
||||
checkCmsLockStatus(cmsDoc.getDeptId());
|
||||
//2、获取专区项目
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(cmsDoc.getDeptId());
|
||||
|
||||
|
|
|
|||
|
|
@ -144,4 +144,16 @@ public class ZoneDetailController extends BaseController {
|
|||
public R<Boolean> deleteByDeptId(@PathVariable(value = "deptName") String deptName) {
|
||||
return R.ok(zoneDetailService.deleteZoneDetailByDeptName(deptName) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过组织id锁定/解锁专区资讯
|
||||
*/
|
||||
@InnerAuth
|
||||
@Log(title = "锁定专区资讯", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{deptId}/lockCms/{lockStatus}")
|
||||
@ApiOperation(value = "通过组织id锁定/解锁专区资讯(0:未锁定,1:锁定)", hidden = true)
|
||||
public R<Boolean> lockCmsByDeptId(@PathVariable(value = "deptId") Long deptId
|
||||
, @PathVariable(value = "lockStatus") Integer lockStatus) {
|
||||
return R.ok(zoneDetailService.lockCmsByDeptId(deptId, lockStatus) > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,13 @@ public class ZoneDetail extends BaseEntity {
|
|||
private Integer resourceNeedAudit;
|
||||
|
||||
|
||||
/**
|
||||
* 资讯是否锁定中(0:未锁定,1:锁定)
|
||||
*/
|
||||
@ApiModelProperty(value = "资讯是否锁定中(0:未锁定,1:锁定)")
|
||||
private Integer isLockCms;
|
||||
|
||||
|
||||
public ZoneDetailDataVo toZoneDetailDataVo() {
|
||||
ZoneDetailDataVo target = new ZoneDetailDataVo();
|
||||
BeanUtils.copyProperties(this, target);
|
||||
|
|
|
|||
|
|
@ -111,6 +111,12 @@ public class ZoneDetailUpdateVo {
|
|||
@ApiModelProperty(value = "资源是否需要审核(0:不需要审核,1:需要审核)")
|
||||
private Integer resourceNeedAudit;
|
||||
|
||||
/**
|
||||
* 资讯是否锁定中(0:未锁定,1:锁定)
|
||||
*/
|
||||
@ApiModelProperty(value = "资讯是否锁定中(0:未锁定,1:锁定)", hidden = true)
|
||||
private Integer isLockCms;
|
||||
|
||||
public ZoneDetail toZoneDetail() {
|
||||
ZoneDetail target = new ZoneDetail();
|
||||
BeanUtils.copyProperties(this, target);
|
||||
|
|
|
|||
|
|
@ -161,4 +161,13 @@ public interface IZoneDetailService {
|
|||
String getZoneJSONByDeptId(Long deptId);
|
||||
|
||||
ZoneFrontRoleVo checkCurrentRoleInZone(Long zoneId);
|
||||
|
||||
/**
|
||||
* 通过组织id锁定/解锁专区资讯
|
||||
*
|
||||
* @param deptId
|
||||
* @param lockStatus
|
||||
* @return
|
||||
*/
|
||||
int lockCmsByDeptId(Long deptId, Integer lockStatus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -514,6 +514,15 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
return zoneFrontRoleVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lockCmsByDeptId(Long deptId, Integer lockStatus) {
|
||||
ZoneDetail zoneDetail = zoneDetailMapper.selectZoneDetailByDeptId(deptId);
|
||||
ZoneDetailUpdateVo zoneDetailUpdateVo = new ZoneDetailUpdateVo();
|
||||
zoneDetailUpdateVo.setId(zoneDetail.getId());
|
||||
zoneDetailUpdateVo.setIsLockCms(lockStatus);
|
||||
return updateZoneDetail(zoneDetailUpdateVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过组织Id查找特色专区,不存在时抛出异常
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
<result property="helperTitle" column="helper_title"/>
|
||||
<result property="docNeedAudit" column="doc_need_audit"/>
|
||||
<result property="resourceNeedAudit" column="resource_need_audit"/>
|
||||
<result property="isLockCms" column="is_lock_cms"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectZoneDetailVo">
|
||||
|
|
@ -76,6 +77,7 @@
|
|||
homepage_member_title,
|
||||
homepage_partners_title,
|
||||
template,
|
||||
is_lock_cms,
|
||||
resource_need_audit,
|
||||
doc_need_audit
|
||||
from zone_detail
|
||||
|
|
@ -115,6 +117,7 @@
|
|||
z.homepage_member_title,
|
||||
z.homepage_partners_title,
|
||||
z.template,
|
||||
z.is_lock_cms,
|
||||
z.resource_need_audit,
|
||||
z.doc_need_audit
|
||||
from zone_detail as z
|
||||
|
|
@ -191,6 +194,7 @@
|
|||
<if test="helperShow != null">helper_show,</if>
|
||||
<if test="docNeedAudit != null">doc_need_audit,</if>
|
||||
<if test="resourceNeedAudit != null">resource_need_audit,</if>
|
||||
<if test="isLockCms != null">is_lock_cms,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
|
|
@ -226,6 +230,7 @@
|
|||
<if test="helperShow != null">#{helperShow},</if>
|
||||
<if test="docNeedAudit != null">#{docNeedAudit},</if>
|
||||
<if test="resourceNeedAudit != null">#{resourceNeedAudit},</if>
|
||||
<if test="isLockCms != null">#{isLockCms},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -266,6 +271,7 @@
|
|||
<if test="helperTitle != null">helper_title = #{helperTitle},</if>
|
||||
<if test="docNeedAudit != null">doc_need_audit = #{docNeedAudit},</if>
|
||||
<if test="resourceNeedAudit != null">resource_need_audit = #{resourceNeedAudit},</if>
|
||||
<if test="isLockCms != null">is_lock_cms = #{isLockCms},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
-- 专区新增资讯锁定状态字段
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
ALTER TABLE `zone_detail`
|
||||
ADD COLUMN `is_lock_cms` tinyint(1) NULL DEFAULT 0 COMMENT '资讯是否锁定中(0:未锁定,1:锁定)';
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
Loading…
Reference in New Issue