mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
通知公告区分首页和管理查询范围、操作权限问题修复
This commit is contained in:
+1
-3
@@ -72,9 +72,7 @@ public class NoticeController {
|
|||||||
@GetMapping("/homepage")
|
@GetMapping("/homepage")
|
||||||
@Operation(summary = "获取首页通知公告列表")
|
@Operation(summary = "获取首页通知公告列表")
|
||||||
public CommonResult<PageResult<NoticeRespVO>> getHomePageNoticePage(@Validated NoticePageReqVO pageReqVO) {
|
public CommonResult<PageResult<NoticeRespVO>> getHomePageNoticePage(@Validated NoticePageReqVO pageReqVO) {
|
||||||
// 首页只看生效的公告
|
PageResult<NoticeDO> pageResult = noticeService.getHomePageNoticePage(pageReqVO);
|
||||||
pageReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
||||||
PageResult<NoticeDO> pageResult = noticeService.getNoticePage(pageReqVO);
|
|
||||||
return success(BeanUtils.toBean(pageResult, NoticeRespVO.class));
|
return success(BeanUtils.toBean(pageResult, NoticeRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-5
@@ -1,9 +1,11 @@
|
|||||||
package com.cf.imes.module.system.dal.mysql.notice;
|
package com.cf.imes.module.system.dal.mysql.notice;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import com.cf.imes.module.system.controller.admin.notice.vo.NoticePageReqVO;
|
import com.cf.imes.module.system.controller.admin.notice.vo.NoticePageReqVO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.notice.NoticeDO;
|
import com.cf.imes.module.system.dal.dataobject.notice.NoticeDO;
|
||||||
import com.cf.imes.module.system.enums.notice.NoticeSourceEnum;
|
import com.cf.imes.module.system.enums.notice.NoticeSourceEnum;
|
||||||
@@ -12,13 +14,13 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface NoticeMapper extends BaseMapperX<NoticeDO> {
|
public interface NoticeMapper extends BaseMapperX<NoticeDO> {
|
||||||
|
|
||||||
default PageResult<NoticeDO> selectPage(NoticePageReqVO reqVO) {
|
default PageResult<NoticeDO> selectHomePageNoticePage(NoticePageReqVO reqVO) {
|
||||||
if (NoticeSourceEnum.SYSTEM.getSource().equals(reqVO.getSource())) {
|
if (SecurityFrameworkUtils.isSuperAdmin()) {
|
||||||
// 超管只看内置的
|
// 超管只看内置的
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<NoticeDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<NoticeDO>()
|
||||||
.likeIfPresent(NoticeDO::getTitle, reqVO.getTitle())
|
.likeIfPresent(NoticeDO::getTitle, reqVO.getTitle())
|
||||||
.eqIfPresent(NoticeDO::getStatus, reqVO.getStatus())
|
.eq(NoticeDO::getSource, NoticeSourceEnum.SYSTEM)
|
||||||
.eqIfPresent(NoticeDO::getSource, NoticeSourceEnum.SYSTEM)
|
.eq(NoticeDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||||
.orderByDesc(NoticeDO::getId));
|
.orderByDesc(NoticeDO::getId));
|
||||||
}
|
}
|
||||||
// 普通用户查机构下的和内置的
|
// 普通用户查机构下的和内置的
|
||||||
@@ -29,7 +31,8 @@ public interface NoticeMapper extends BaseMapperX<NoticeDO> {
|
|||||||
.eq(NoticeDO::getOrganId, OrganContextHolder.getOrganId())
|
.eq(NoticeDO::getOrganId, OrganContextHolder.getOrganId())
|
||||||
.eq(NoticeDO::getSource, NoticeSourceEnum.CUSTOM))
|
.eq(NoticeDO::getSource, NoticeSourceEnum.CUSTOM))
|
||||||
.or(wrapper -> wrapper.eq(NoticeDO::getSource, NoticeSourceEnum.SYSTEM)))
|
.or(wrapper -> wrapper.eq(NoticeDO::getSource, NoticeSourceEnum.SYSTEM)))
|
||||||
.orderByDesc(NoticeDO::getId));
|
.orderByDesc(NoticeDO::getId)
|
||||||
|
.eq(NoticeDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -40,6 +40,14 @@ public interface NoticeService {
|
|||||||
*/
|
*/
|
||||||
PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO);
|
PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取首页工作台-通知公告分页列表
|
||||||
|
*
|
||||||
|
* @param reqVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PageResult<NoticeDO> getHomePageNoticePage(NoticePageReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得通知公告
|
* 获得通知公告
|
||||||
*
|
*
|
||||||
|
|||||||
+16
-11
@@ -59,8 +59,6 @@ public class NoticeServiceImpl implements NoticeService {
|
|||||||
getSelf().validateNameExists(updateReqVO);
|
getSelf().validateNameExists(updateReqVO);
|
||||||
// 更新通知公告
|
// 更新通知公告
|
||||||
NoticeDO updateObj = BeanUtils.toBean(updateReqVO, NoticeDO.class);
|
NoticeDO updateObj = BeanUtils.toBean(updateReqVO, NoticeDO.class);
|
||||||
// 超管创建的都是内置公告
|
|
||||||
modifySource(updateObj);
|
|
||||||
noticeMapper.updateById(updateObj);
|
noticeMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,14 +71,17 @@ public class NoticeServiceImpl implements NoticeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OrganIgnore
|
|
||||||
public PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO) {
|
public PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO) {
|
||||||
boolean isSuperAdmin = SecurityFrameworkUtils.isSuperAdmin();
|
return noticeMapper.selectPage(reqVO, new LambdaQueryWrapperX<NoticeDO>()
|
||||||
// 超管查看内置公告
|
.likeIfPresent(NoticeDO::getTitle, reqVO.getTitle())
|
||||||
if (isSuperAdmin) {
|
.eqIfPresent(NoticeDO::getStatus, reqVO.getStatus())
|
||||||
reqVO.setSource(NoticeSourceEnum.SYSTEM.getSource());
|
.orderByDesc(NoticeDO::getId));
|
||||||
}
|
}
|
||||||
return noticeMapper.selectPage(reqVO);
|
|
||||||
|
@Override
|
||||||
|
@OrganIgnore
|
||||||
|
public PageResult<NoticeDO> getHomePageNoticePage(NoticePageReqVO reqVO) {
|
||||||
|
return noticeMapper.selectHomePageNoticePage(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -97,11 +98,15 @@ public class NoticeServiceImpl implements NoticeService {
|
|||||||
if (notice == null) {
|
if (notice == null) {
|
||||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.NOTICE_NOT_FOUND);
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.NOTICE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
if (!NoticeSourceEnum.SYSTEM.equals(notice.getSource()) && !notice.getOrganId().equals(OrganContextHolder.getOrganId())) {
|
boolean superAdmin = SecurityFrameworkUtils.isSuperAdmin();
|
||||||
|
// 公告和操作人非统一组织,只有超管可以编辑和删除
|
||||||
|
if (NoticeSourceEnum.CUSTOM.equals(notice.getSource())
|
||||||
|
&& !notice.getOrganId().equals(OrganContextHolder.getOrganId())
|
||||||
|
&& !superAdmin) {
|
||||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.NOTICE_NOT_FOUND);
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.NOTICE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
// 只有超管可以操作内置公告
|
// 只有超管可以操作内置公告
|
||||||
if (NoticeSourceEnum.SYSTEM.equals(notice.getSource()) && !SecurityFrameworkUtils.isSuperAdmin()) {
|
if (NoticeSourceEnum.SYSTEM.equals(notice.getSource()) && !superAdmin) {
|
||||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.NOTICE_BUILDIN_MODIFY_PERMISSION_ERROR);
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.NOTICE_BUILDIN_MODIFY_PERMISSION_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user