From 887a8ff7e011adea097f3e5885bf8f044be1cf99 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 12 Oct 2023 14:57:36 +0800 Subject: [PATCH] =?UTF-8?q?IRS=E6=A1=A3=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/irs/manage/IrsProjectManage.java | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/IrsProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/IrsProjectManage.java index 2e49b15..ccecf09 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/IrsProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/IrsProjectManage.java @@ -1,23 +1,24 @@ package com.ningdatech.pmapi.irs.manage; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.google.common.collect.Lists; import com.ningdatech.basic.model.PageVo; -import com.ningdatech.pmapi.dashboard.model.vo.ProtraitProjectOutputVO; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; - import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -40,25 +41,42 @@ public class IrsProjectManage { */ public PageVo list(ProjectListReq req) { Page page = req.page(); + UserInfoDetails user = LoginUserUtil.loginUserDetail(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) .eq(StringUtils.isNotBlank(req.getAreaCode()),Project::getAreaCode,req.getAreaCode()) .eq(StringUtils.isNotBlank(req.getRegionCode()),Project::getAreaCode,req.getRegionCode()) + .eq(StringUtils.isNotBlank(req.getProjectType()),Project::getProjectType,req.getProjectType()) + .eq(Objects.nonNull(req.getStatus()),Project::getStatus,req.getStatus()) + .eq(Objects.nonNull(req.getStage()),Project::getStage,req.getStage()) + .ge(Objects.nonNull(req.getApproveAmountMin()),Project::getApprovalAmount,req.getApproveAmountMin()) + .le(Objects.nonNull(req.getApproveAmountMax()),Project::getApprovalAmount,req.getApproveAmountMax()) + .eq(Objects.nonNull(req.getProjectYear()),Project::getProjectYear,req.getProjectYear()) + .ge(Objects.nonNull(req.getCreateOnMin()),Project::getCreateOn,req.getCreateOnMin()) + .le(Objects.nonNull(req.getCreateOnMax()),Project::getCreateOn,req.getCreateOnMax()) .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()) .like(StringUtils.isNotBlank(req.getBuildOrgName()),Project::getBuildOrgName,req.getBuildOrgName()) .gt(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) .orderByDesc(Project::getUpdateOn); + buildPermission(wrapper,user); projectService.page(page,wrapper); if(CollUtil.isEmpty(page.getRecords())){ return PageVo.empty(); } List res = page.getRecords().stream().map(p -> { - ProjectLibListItemVO vo = new ProjectLibListItemVO(); - vo.setId(p.getId()); - vo.setProjectName(p.getProjectName()); - vo.setProjectCode(p.getProjectCode()); + ProjectLibListItemVO vo = BeanUtil.copyProperties(p,ProjectLibListItemVO.class); return vo; }).collect(Collectors.toList()); return PageVo.of(res,page.getTotal()); } + + private void buildPermission(LambdaQueryWrapper wrapper, UserInfoDetails user) { + if(user.getSuperAdmin()){ + log.info("超管 都可看 项目档案列表"); + }else if(user.getRegionAdmin()){ + wrapper.eq(Project::getAreaCode,user.getRegionCode()); + }else{ + wrapper.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); + } + } }