Browse Source

公告 只能编辑自己的 超管除外

master
PoffyZhang 1 year ago
parent
commit
cc4b7a0c64
3 changed files with 39 additions and 4 deletions
  1. +11
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java
  2. +24
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java
  3. +4
    -3
      pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java

+ 11
- 1
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java View File

@@ -137,7 +137,7 @@ public class NoticeManage {
.eq(req.getType() != null, Notice::getType, req.getType())
.orderByDesc(Notice::getToppedTime, Notice::getUpdateOn);
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
permissionsWrapper(wrapper,user);
permissionsWrapperByEdit(wrapper,user);
Page<Notice> page = noticeService.page(req.page(), wrapper);
if (page.getTotal() == 0) {
return PageVo.empty();
@@ -331,4 +331,14 @@ public class NoticeManage {
.or(q2 -> q2.eq(Notice::getPermissions,NoticePermissionsEnum.ORG.getCode())
.eq(Notice::getPermissionsValue,user.getEmpPosUnitCode())));
}

private void permissionsWrapperByEdit(LambdaQueryWrapper<Notice> wrapper,UserFullInfoDTO user) {
UserInfoDetails userInfoDetails = LoginUserUtil.loginUserDetail();
//如果是超管 就能看所有
if(user.getSuperAdmin()){
log.info(user.getUsername() + ",超管可以看所有");
}else{
wrapper.eq(Notice::getCreateOn,user.getUserId());
}
}
}

+ 24
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java View File

@@ -104,4 +104,28 @@ public class UserFullInfoDTO {
}
return Boolean.FALSE;
}

public Boolean getSuperAdmin() {
if (CollUtil.isNotEmpty(this.userRoleList)) {
for (Role role : this.userRoleList) {
RoleEnum roleEnum = RoleEnum.mathByName(role.getCode());
if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.SUPER_ADMIN.name())) {
return Boolean.TRUE;
}
}
}
return Boolean.FALSE;
}

public Boolean getRegionAdmin() {
if (CollUtil.isNotEmpty(this.userRoleList)) {
for (Role role : this.userRoleList) {
RoleEnum roleEnum = RoleEnum.mathByName(role.getCode());
if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.REGION_MANAGER.name())) {
return Boolean.TRUE;
}
}
}
return Boolean.FALSE;
}
}

+ 4
- 3
pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java View File

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO;
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO;
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO;
@@ -52,14 +53,14 @@ public class ProjectCollectionTest extends AppTests {

@Test
public void test(){
List<String> baseProjIds = Lists.newArrayList("33112700020210100191");
List<String> baseProjIds = Lists.newArrayList("33110000020230100061");
for(String baseProjId : baseProjIds){
GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class)
.eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId)
.eq(GovBizProjectBaseinfo::getId,457));
.last(BizConst.LIMIT_1));
GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class)
.eq(GovBizProjectApply::getBaseProjId, baseProjId)
.eq(GovBizProjectApply::getId,451));
.last(BizConst.LIMIT_1));

GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO();
saveDTO.setApply(BeanUtil.copyProperties(apply, GovBizProjectApplyDTO.class));


Loading…
Cancel
Save