zero 11 mesiacov pred
rodič
commit
f2f1ca1502

+ 9 - 0
src/main/java/cn/cslg/pas/common/dto/QueryNoveltyProjectDTO.java

@@ -10,4 +10,13 @@ public class QueryNoveltyProjectDTO {
     private Long current;
 
     private Long size;
+
+    //创建人id
+    private String createId;
+
+    //租户id
+    private Integer tenantId;
+
+    //角色
+    private Integer roleType;
 }

+ 14 - 2
src/main/java/cn/cslg/pas/service/business/NoveltyProjectService.java

@@ -79,6 +79,8 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
     private NoveltyCompareLiteratureService noveltyCompareLiteratureService;
 
     public Records queryNoveltyProject(QueryNoveltyProjectDTO vo) throws IOException {
+        //封装权限
+        loadPermissions(vo);
         //查询数据库
         List<QueryNoveltyProjectVO> noveltyProjectVOS = noveltyProjectMapper.queryNoveltyProject(vo);
         this.loadNoveltyProjectVOS(noveltyProjectVOS);
@@ -92,6 +94,16 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
         return records;
     }
 
+    public void loadPermissions(QueryNoveltyProjectDTO vo) {
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        String id = personnelVO.getId();
+        Integer tenantId = personnelVO.getTenantId();
+        Integer roleType = personnelVO.getRoleType();
+        vo.setCreateId(id);
+        vo.setTenantId(tenantId);
+        vo.setRoleType(roleType);
+    }
+
     private void loadNoveltyProjectVOS(List<QueryNoveltyProjectVO> noveltyProjectVOS) throws IOException {
         if (!CollectionUtils.isEmpty(noveltyProjectVOS)) {
             List<String> createIds = new ArrayList<>();
@@ -225,7 +237,7 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
                 project.setEntrustType(1);
 
                 //当委托方id不为空时
-                if (vo.getEntrustId() != null) {
+                if (StringUtils.isNotEmpty(vo.getEntrustId()) && !StringUtils.equals(vo.getEntrustId(), "-1")) {
                     project.setEntrustId(vo.getEntrustId());
                 }
 
@@ -280,7 +292,7 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
                 project.setEntrustType(1);
 
                 //当委托方id不为空时
-                if (vo.getEntrustId() != null) {
+                if (StringUtils.isNotEmpty(vo.getEntrustId()) && !StringUtils.equals(vo.getEntrustId(), "-1")) {
                     project.setEntrustId(vo.getEntrustId());
                 }
                 //若且租户类型为代理机构,并且委托方id为空,委托方名称不为空时,新增委托方

+ 3 - 2
src/main/java/cn/cslg/pas/service/business/PatentDigProjectService.java

@@ -31,6 +31,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -206,7 +207,7 @@ public class PatentDigProjectService extends ServiceImpl<PatentDigProjectMapper,
                 project.setEntrustType(1);
 
                 //当委托方id不为空时
-                if (patentDigProjectDTO.getEntrustId() != null) {
+                if (StringUtils.isNotEmpty(patentDigProjectDTO.getEntrustId()) && !StringUtils.equals(patentDigProjectDTO.getEntrustId(), "-1")) {
                     project.setEntrustId(patentDigProjectDTO.getEntrustId());
                 }
                 //若且租户类型为代理机构,并且委托方id为空,委托方名称不为空时,新增委托方
@@ -345,7 +346,7 @@ public class PatentDigProjectService extends ServiceImpl<PatentDigProjectMapper,
         project.setDescription(projectUpdateDTO.getDescription());
 
         //当委托方id不为空时
-        if (projectUpdateDTO.getEntrustId() != null) {
+        if (StringUtils.isNotEmpty(projectUpdateDTO.getEntrustId()) && !StringUtils.equals(projectUpdateDTO.getEntrustId(), "-1")) {
             project.setEntrustId(projectUpdateDTO.getEntrustId());
         }
         else {//若且租户类型为代理机构,并且委托方id为空,委托方名称不为空时,新增委托方

+ 3 - 2
src/main/java/cn/cslg/pas/service/business/PatentProjectService.java

@@ -37,6 +37,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -288,7 +289,7 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
                 project.setEntrustType(1);
 
                 //当委托方id不为空时
-                if (patentProjectDTO.getEntrustId() != null) {
+                if (StringUtils.isNotEmpty(patentProjectDTO.getEntrustId()) && !StringUtils.equals(patentProjectDTO.getEntrustId(), "-1")) {
                     project.setEntrustId(patentProjectDTO.getEntrustId());
                 }
                 //若且租户类型为代理机构,并且委托方id为空,委托方名称不为空时,新增委托方
@@ -463,7 +464,7 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
                 project.setEntrustType(1);
 
                 //当委托方id不为空时
-                if (updatePatentProjectDTO.getEntrustId() != null) {
+                if (StringUtils.isNotEmpty(updatePatentProjectDTO.getEntrustId()) && !StringUtils.equals(updatePatentProjectDTO.getEntrustId(), "-1")) {
                     project.setEntrustId(updatePatentProjectDTO.getEntrustId());
                 }
                 //若且租户类型为代理机构,并且委托方id为空,委托方名称不为空时,新增委托方

+ 3 - 2
src/main/java/cn/cslg/pas/service/business/ReportProjectService.java

@@ -38,6 +38,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.validation.constraints.AssertFalse;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -287,7 +288,7 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
                 project.setEntrustType(1);
 
                 //当委托方id不为空时
-                if (reportProjectDTO.getEntrustId() != null) {
+                if (StringUtils.isNotEmpty(reportProjectDTO.getEntrustId()) && !StringUtils.equals(reportProjectDTO.getEntrustId(), "-1")) {
                     project.setEntrustId(reportProjectDTO.getEntrustId());
                 }
 
@@ -473,7 +474,7 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
                 project.setEntrustType(1);
 
                 //当委托方id不为空时
-                if (updateReportProjectDTO.getEntrustId() != null) {
+                if (StringUtils.isNotEmpty(updateReportProjectDTO.getEntrustId()) && !StringUtils.equals(updateReportProjectDTO.getEntrustId(), "-1")) {
                     project.setEntrustId(updateReportProjectDTO.getEntrustId());
                 }
                 //若且租户类型为代理机构,并且委托方id为空,委托方名称不为空时,新增委托方

+ 6 - 0
src/main/resources/mapper/NoveltyProjectMapper.xml

@@ -41,6 +41,12 @@
             <if test="vo.projectId != null">
                 np.project_id = #{vo.projectId}
             </if>
+            <if test="vo.roleType == null or vo.roleType == 0">
+                and (p.create_id = #{vo.createId} or p.head_id = #{vo.createId} or p.id in (select project_id from asso_project_person where person_id = #{vo.createId}))
+            </if>
+            <if test="vo.roleType == 2">
+                and (p.tenant_id = #{vo.tenantId} or p.id in (select project_id from asso_project_person where person_id = #{vo.createId}))
+            </if>
         </where>
         order by p.create_time desc
         <if test="vo.current != null and vo.size != null">