TRX 1 rok temu
rodzic
commit
0df7c67099
41 zmienionych plików z 855 dodań i 179 usunięć
  1. 2 2
      FullCardClient/src/main/java/com/zhongshu/card/client/model/base/SuperParam.java
  2. 2 2
      FullCardClient/src/main/java/com/zhongshu/card/client/model/base/SuperSearch.java
  3. 6 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/DepartmentParam.java
  4. 1 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationRelationSearch.java
  5. 1 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationSearchParam.java
  6. 47 16
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationSimpleModel.java
  7. 1 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationUserModel.java
  8. 1 7
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationUserSimpleModel.java
  9. 11 5
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleAddParam.java
  10. 14 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleModel.java
  11. 21 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleQueryParam.java
  12. 5 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleSearchParam.java
  13. 26 2
      FullCardClient/src/main/java/com/zhongshu/card/client/model/orgModel/OrgSaveParam.java
  14. 31 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/orgModel/ProjectBindOrgParam.java
  15. 1 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/school/DictInfoParam.java
  16. 1 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/school/DictInfoSearch.java
  17. 1 0
      FullCardClient/src/main/java/com/zhongshu/card/client/type/OrganizationRelationType.java
  18. 3 2
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/DepartmentController.java
  19. 20 8
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/RoleController.java
  20. 87 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/AreaTypeManagerController.java
  21. 14 20
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/OrganizationManagerController.java
  22. 87 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/PositionManagerController.java
  23. 88 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/ProjectBindOrgController.java
  24. 0 17
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/school/DictInfoController.java
  25. 1 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/OrganizationDao.java
  26. 4 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/OrganizationRelationDao.java
  27. 8 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/RoleDao.java
  28. 2 2
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/extend/OrganizationRelationDaoExtend.java
  29. 1 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/extend/RoleDaoExtend.java
  30. 6 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/impl/RoleDaoImpl.java
  31. 18 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/OrganizationRelation.java
  32. 4 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/Role.java
  33. 14 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/base/SuperService.java
  34. 11 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/DepartmentServiceImpl.java
  35. 7 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/OrganizationServiceImpl.java
  36. 56 31
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/RoleServiceImpl.java
  37. 1 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/UserAccountServiceImpl.java
  38. 53 48
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/orgManager/OrganizationManagerServiceImpl.java
  39. 174 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/orgManager/ProjectBindOrgServiceImpl.java
  40. 10 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/AreaServiceImpl.java
  41. 14 3
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/DictInfoServiceImpl.java

+ 2 - 2
FullCardClient/src/main/java/com/zhongshu/card/client/model/base/SuperParam.java

@@ -26,11 +26,11 @@ public class SuperParam implements Serializable {
     @Schema(description = "所属项目oid")
     private String projectOid;
 
-    @Schema(description = "数据主题的oid")
+    @Schema(description = "数据主题的oid", hidden = true)
     @Hidden
     private String aboutOid;
 
-    @Schema(description = "数据主题管理的oid机构类型")
+    @Schema(description = "数据主题管理的oid机构类型", hidden = true)
     @Hidden
     private AuthType aboutAuthType;
 

+ 2 - 2
FullCardClient/src/main/java/com/zhongshu/card/client/model/base/SuperSearch.java

@@ -24,10 +24,10 @@ public class SuperSearch implements Serializable {
     @Schema(description = "所属项目oid")
     private String projectOid;
 
-    @Schema(description = "数据主题的oid")
+    @Schema(description = "数据主题的oid", hidden = true)
     private String aboutOid;
 
-    @Schema(description = "数据主题管理的oid机构类型")
+    @Schema(description = "数据主题管理的oid机构类型", hidden = true)
     private AuthType aboutAuthType;
 
     @Schema(description = "搜索时间范围")

+ 6 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/DepartmentParam.java

@@ -4,6 +4,7 @@ import com.zhongshu.card.client.model.base.SuperParam;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.utils.ITree;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
 import lombok.Data;
 
 /**
@@ -13,6 +14,7 @@ import lombok.Data;
 @Data
 public class DepartmentParam extends SuperParam {
     @Schema(description = "部门名称")
+    @NotEmpty
     private String name;
 
     @Schema(description = "部门编码")
@@ -23,4 +25,8 @@ public class DepartmentParam extends SuperParam {
 
     @Schema(description = "上级ID")
     private String parentId = ITree.ROOT_ID;
+
+    @Schema(description = "机构oid")
+    @NotEmpty
+    private String orgOid;
 }

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationRelationSearch.java

@@ -11,7 +11,7 @@ import lombok.Data;
 @Data
 public class OrganizationRelationSearch {
 
-    @Schema(description = "主Oid", hidden = true)
+    @Schema(description = "项目Oid")
     private String mainOid;
 
     @Schema(description = "主ID", hidden = true)

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationSearchParam.java

@@ -45,7 +45,7 @@ public class OrganizationSearchParam extends SuperSearch {
     private String mapLat;
 
     @Schema(description = "机构类型")
-    private AuthType authType = AuthType.Enterprise;
+    private AuthType authType;
 
     @Schema(description = "状态")
     private OrganizationState state;

+ 47 - 16
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationSimpleModel.java

@@ -6,6 +6,9 @@ import com.zhongshu.card.client.type.OrganizationState;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @author TRX
  * @date 2024/5/31
@@ -22,34 +25,62 @@ public class OrganizationSimpleModel extends SuperModel {
     @Schema(description = "机构类型")
     private AuthType authType = AuthType.Enterprise;
 
+    private String authTypeStr;
+
+    public String getAuthTypeStr() {
+        if (authType != null) {
+            return authType.getRemark();
+        }
+        return "";
+    }
+
     @Schema(description = "状态")
     private OrganizationState state;
 
     private String stateStr;
 
-    public String getStateStr(){
+    public String getStateStr() {
         if (state != null) {
             return state.getRemark();
         }
         return "";
     }
 
+    @Schema(description = "logo")
+    private String logo;
+
+    @Schema(description = "统一社会信用代码")
+    private String orgCode;
+
+    @Schema(description = " 行政区划编码 21,2104,210403")
+    private String adminDivisionItemCode;
+
+    @Schema(description = "地区列表")
+    private List<RegionModel> regionList;
+
+    private String regionStr;
+
+    public String getRegionStr() {
+        if (regionList != null) {
+            List<String> arr = regionList.stream().map(it -> it.getName()).collect(Collectors.toList());
+            return String.join("/", arr);
+        }
+        return "";
+    }
+
+    @Schema(description = "地址")
+    private String address;
+
+    @Schema(description = "经度")
+    private String mapLon;
+
+    @Schema(description = "纬度")
+    private String mapLat;
+
+    @Schema(description = "联系人-用来初始管理员")
+    private String contactName;
+
     @Schema(description = "联系人电话")
     private String contactPhone;
-//
-//    @Schema(description = "logo")
-//    private String logo;
-//
-//    @Schema(description = "地址")
-//    private String address;
-//
-//    @Schema(description = " 行政区划编码")
-//    private String adminDivisionItemCode;
-//
-//    @Schema(description = "经度")
-//    private String mapLon;
-//
-//    @Schema(description = "纬度")
-//    private String mapLat;
 
 }

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationUserModel.java

@@ -2,6 +2,7 @@ package com.zhongshu.card.client.model.org;
 
 import com.github.microservice.auth.security.type.AuthType;
 import com.zhongshu.card.client.model.base.SuperModel;
+import com.zhongshu.card.client.model.org.role.RoleModel;
 import com.zhongshu.card.client.model.school.DictInfoSimpleModel;
 import com.zhongshu.card.client.type.CertificateType;
 import com.zhongshu.card.client.type.OrganizationUserType;
@@ -11,7 +12,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
-import org.apache.commons.lang3.StringUtils;
 
 import java.util.ArrayList;
 import java.util.List;

+ 1 - 7
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationUserSimpleModel.java

@@ -1,12 +1,6 @@
 package com.zhongshu.card.client.model.org;
 
-import com.github.microservice.auth.security.type.AuthType;
-import com.zhongshu.card.client.model.base.SuperModel;
-import com.zhongshu.card.client.model.school.DictInfoSimpleModel;
-import com.zhongshu.card.client.type.CertificateType;
-import com.zhongshu.card.client.type.OrganizationUserType;
-import com.zhongshu.card.client.type.Sex;
-import com.zhongshu.card.client.type.UserState;
+import com.zhongshu.card.client.model.org.role.RoleModel;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;

+ 11 - 5
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/RoleAddParam.java → FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleAddParam.java

@@ -1,10 +1,12 @@
-package com.zhongshu.card.client.model.org;
+package com.zhongshu.card.client.model.org.role;
 
+import com.github.microservice.auth.security.type.AuthType;
 import com.zhongshu.card.client.model.base.SuperParam;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.RoleType;
-import com.zhongshu.card.client.type.school.RoleDefaultType;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
 /**
@@ -13,18 +15,22 @@ import lombok.Data;
  */
 @Data
 public class RoleAddParam extends SuperParam {
+
     @Schema(description = "名称")
+    @NotEmpty
     private String name;
 
     @Schema(description = "角色编码")
     private String code;
 
     @Schema(description = "角色类型", hidden = true)
-    RoleType roleType = RoleType.Custom;
+    private RoleType roleType = RoleType.Custom;
 
-    @Schema(description = "默认角色的类型")
-    RoleDefaultType roleDefaultType;
+    @Schema(description = "角色类型")
+    @NotNull
+    private AuthType authType;
 
+    @NotNull
     @Schema(description = "状态")
     private DataState state = DataState.Enable;
 }

+ 14 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/RoleModel.java → FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleModel.java

@@ -1,5 +1,6 @@
-package com.zhongshu.card.client.model.org;
+package com.zhongshu.card.client.model.org.role;
 
+import com.github.microservice.auth.security.type.AuthType;
 import com.zhongshu.card.client.model.base.SuperModel;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.RoleType;
@@ -20,6 +21,18 @@ public class RoleModel extends SuperModel {
     @Schema(description = "角色编码")
     private String code;
 
+    @Schema(description = "角色类型")
+    private AuthType authType;
+
+    private String authTypeStr;
+
+    public String getAuthTypeStr() {
+        if (authType != null) {
+            return authType.getRemark();
+        }
+        return "";
+    }
+
     @Schema(description = "角色类型")
     RoleType roleType;
 

+ 21 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleQueryParam.java

@@ -0,0 +1,21 @@
+package com.zhongshu.card.client.model.org.role;
+
+import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.card.client.type.DataState;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author TRX
+ * @date 2024/9/26
+ */
+@Data
+public class RoleQueryParam {
+
+    @Schema(description = "角色类型")
+    private AuthType authType;
+
+    @Schema(description = "状态")
+    private DataState state = DataState.Enable;
+
+}

+ 5 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/RoleSearchParam.java → FullCardClient/src/main/java/com/zhongshu/card/client/model/org/role/RoleSearchParam.java

@@ -1,5 +1,6 @@
-package com.zhongshu.card.client.model.org;
+package com.zhongshu.card.client.model.org.role;
 
+import com.github.microservice.auth.security.type.AuthType;
 import com.zhongshu.card.client.model.base.SuperSearch;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -15,4 +16,7 @@ public class RoleSearchParam extends SuperSearch {
 
     @Schema(description = "角色编码")
     private String code;
+
+    @Schema(description = "角色类型")
+    private AuthType authType;
 }

+ 26 - 2
FullCardClient/src/main/java/com/zhongshu/card/client/model/orgModel/OrgSaveParam.java

@@ -5,6 +5,7 @@ import com.zhongshu.card.client.model.base.SuperParam;
 import com.zhongshu.card.client.type.OrganizationState;
 import com.zhongshu.card.client.type.ProjectType;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.Max;
 import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
 import lombok.Data;
@@ -25,13 +26,36 @@ public class OrgSaveParam extends SuperParam {
     @NotEmpty(message = "name不能为空")
     private String name;
 
-    @NotEmpty
     @Schema(description = "编码、项目ID")
     private String code;
 
     @NotNull
     @Schema(description = "机构类型")
-    private AuthType authType = AuthType.Enterprise;
+    private AuthType authType;
+
+    @Schema(description = "logo")
+    private String logo;
+
+    @Schema(description = "统一社会信用代码")
+    private String orgCode;
+
+    @Schema(description = " 行政区划编码 21,2104,210403")
+    private String adminDivisionItemCode;
+
+    @Schema(description = "地址")
+    private String address;
+
+    @Schema(description = "经度")
+    private String mapLon;
+
+    @Schema(description = "纬度")
+    private String mapLat;
+
+    @Schema(description = "联系人-用来初始管理员")
+    private String contactName;
+
+    @Schema(description = "联系人电话")
+    private String contactPhone;
 
     @NotNull
     @Schema(description = "机构状态")

+ 31 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/orgModel/ProjectBindOrgParam.java

@@ -0,0 +1,31 @@
+package com.zhongshu.card.client.model.orgModel;
+
+import com.zhongshu.card.client.type.DataState;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/9/26
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ProjectBindOrgParam {
+
+    @Schema(description = "项目oid")
+    @NotEmpty
+    private String projectOid;
+
+    @Schema(description = "机构oid")
+    @NotEmpty
+    private String orgOid;
+
+    @Schema(description = "数据状态")
+    @NotNull
+    private DataState state = DataState.Enable;
+}

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/school/DictInfoParam.java

@@ -15,6 +15,6 @@ public class DictInfoParam extends SuperParam {
     private String name;
 
     @Schema(description = "字典类型")
-    DictInfoType dictInfoType;
+    private DictInfoType dictInfoType;
 
 }

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/school/DictInfoSearch.java

@@ -15,6 +15,6 @@ public class DictInfoSearch extends SuperSearch {
     private String name;
 
     @Schema(description = "字典类型")
-    DictInfoType dictInfoType;
+    private DictInfoType dictInfoType;
 
 }

+ 1 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/type/OrganizationRelationType.java

@@ -8,6 +8,7 @@ import lombok.Getter;
 public enum OrganizationRelationType {
     SchoolToProject("学校绑定项目"),
     ShopToSchool("商户绑定学校"),
+    ProjectBindOrg("项目绑定机构"),
     ;
 
     @Getter

+ 3 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/DepartmentController.java

@@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
+
 @RestController
 @RequestMapping("department")
 @Tag(name = "部门管理--通用")
@@ -38,11 +40,10 @@ public class DepartmentController {
         return this.departmentService.getDepartmentTree(param.getOid());
     }
 
-
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "添加-编辑部门-通用", description = "添加-编辑部门")
     @RequestMapping(value = "addDepartment", method = {RequestMethod.POST})
-    public ResultContent addDepartment(@RequestBody DepartmentParam param) {
+    public ResultContent addDepartment(@RequestBody @Valid DepartmentParam param) {
         return this.departmentService.addDepartment(param);
     }
 

+ 20 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/RoleController.java

@@ -7,6 +7,10 @@ import com.zhongshu.card.client.model.base.IDParam;
 import com.zhongshu.card.client.model.base.OidModel;
 import com.zhongshu.card.client.model.org.*;
 import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.org.role.RoleAddParam;
+import com.zhongshu.card.client.model.org.role.RoleModel;
+import com.zhongshu.card.client.model.org.role.RoleQueryParam;
+import com.zhongshu.card.client.model.org.role.RoleSearchParam;
 import com.zhongshu.card.server.core.service.org.RoleServiceImpl;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -17,6 +21,8 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.data.web.PageableDefault;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
+
 /**
  * @author TRX
  * @date 2024/6/5
@@ -38,7 +44,7 @@ public class RoleController {
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "添加-编辑角色", description = "添加-编辑角色")
     @RequestMapping(value = "addRole", method = {RequestMethod.POST})
-    public ResultContent addRole(@RequestBody RoleAddParam param) {
+    public ResultContent addRole(@RequestBody @Valid RoleAddParam param) {
         return this.roleService.addRole(param);
     }
 
@@ -66,13 +72,6 @@ public class RoleController {
         return roleService.page(param, pageable);
     }
 
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "得到机构所有角色", description = "得到机构所有角色")
-    @RequestMapping(value = "getAllRoles", method = {RequestMethod.POST})
-    public ResultContent getAllRoles(@RequestBody OidModel param) {
-        return this.roleService.getAllRoles(param.getOid());
-    }
-
     @ResourceAuth(value = "roleDelete", type = AuthType.Platform, remark = "角色管理_删除角色_3_Button")
     @ResourceAuth(value = "roleDelete", type = AuthType.Project, remark = "角色管理_删除角色_3_Button")
     @ResourceAuth(value = "roleDelete", type = AuthType.School, remark = "角色管理_删除角色_3_Button")
@@ -99,6 +98,19 @@ public class RoleController {
         return this.roleService.getRole(param.getId());
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "查询角色列表(添加用户时使用)", description = "查询角色列表")
+    @RequestMapping(value = "queryRoles", method = {RequestMethod.POST})
+    public ResultContent queryRoles(@RequestBody RoleQueryParam param) {
+        return this.roleService.queryRoles(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "得到机构所有角色(根据oid查询)", description = "得到机构所有角色(根据oid查询)")
+    @RequestMapping(value = "getAllRoles", method = {RequestMethod.POST})
+    public ResultContent getAllRoles(@RequestBody OidModel param) {
+        return this.roleService.getAllRoles(param.getOid());
+    }
 
     //---------------------------角色权限 start -----------------------
 

+ 87 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/AreaTypeManagerController.java

@@ -0,0 +1,87 @@
+package com.zhongshu.card.server.core.controller.orgManager;
+
+import com.github.microservice.auth.client.constant.AuthConstant;
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.base.IDParam;
+import com.zhongshu.card.client.model.school.DictInfoParam;
+import com.zhongshu.card.client.model.school.DictInfoSearch;
+import com.zhongshu.card.client.service.school.DictInfoService;
+import com.zhongshu.card.client.type.DictInfoType;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 区域类型 管理
+ *
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("areaTypeManager")
+@Tag(name = "区域类型管理")
+public class AreaTypeManagerController {
+
+    @Autowired
+    DictInfoService dictInfoService;
+
+    @ResourceAuth(value = "areaTypeList", type = AuthType.Platform, remark = "区域类型管理_类型列表_1_Menu")
+    @ResourceAuth(value = "areaTypeList", type = AuthType.Project, remark = "区域类型管理_类型列表_1_Menu")
+    @ResourceAuth(value = "areaTypeList", type = AuthType.School, remark = "区域类型管理_类型列表_1_Menu")
+    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
+    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.School, remark = "")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "区域类型区域类型列表-分页查询", description = "人员区域类型列表-分页查询")
+    @RequestMapping(value = {"areaTypePageManager"}, method = {RequestMethod.POST})
+    public ResultContent<Page<DictInfoParam>> areaTypePageManager(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) DictInfoSearch param) {
+        param.setDictInfoType(DictInfoType.AreaType);
+        return dictInfoService.page(param, pageable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "添加-编辑区域类型", description = "添加-编辑区域类型")
+    @RequestMapping(value = "addAreaType", method = {RequestMethod.POST})
+    public ResultContent addAreaType(@RequestBody DictInfoParam param) {
+        param.setDictInfoType(DictInfoType.AreaType);
+        return this.dictInfoService.addDict(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除区域类型", description = "删除区域类型")
+    @RequestMapping(value = "deleteAreaType", method = {RequestMethod.POST})
+    public ResultContent deleteAreaType(@RequestBody IDParam param) {
+        return this.dictInfoService.deleteDict(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "区域类型详情", description = "区域类型详情")
+    @RequestMapping(value = "getAreaType", method = {RequestMethod.POST})
+    public ResultContent<DictInfoParam> getAreaType(@RequestBody IDParam param) {
+        return this.dictInfoService.getDictInfo(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "查询区域类型所有的数据", description = "查询区域类型所有的数据")
+    @RequestMapping(value = {"findAreaTypeByOid"}, method = {RequestMethod.POST})
+    public ResultContent<List<DictInfoParam>> findAreaTypeByOid(
+            @Parameter(required = false) DictInfoSearch param) {
+        param.setDictInfoType(DictInfoType.AreaType);
+        return dictInfoService.findDictInfosByOid(param);
+    }
+
+}

+ 14 - 20
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/OrganizationManagerController.java

@@ -6,9 +6,9 @@ import com.github.microservice.auth.security.type.AuthType;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.base.OidModel;
 import com.zhongshu.card.client.model.base.ProjectOidParam;
-import com.zhongshu.card.client.model.org.*;
+import com.zhongshu.card.client.model.org.OrganizationSearchParam;
+import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
 import com.zhongshu.card.client.model.orgModel.OrgSaveParam;
-import com.zhongshu.card.client.model.project.ProjectSaveParam;
 import com.zhongshu.card.client.service.org.OrganizationService;
 import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
 import io.swagger.v3.oas.annotations.Operation;
@@ -18,33 +18,25 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.web.PageableDefault;
-import org.springframework.util.Assert;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
 import java.util.List;
 
 @RestController
 @RequestMapping("organizationManager")
-@Tag(name = "机构管理")
+@Tag(name = "机构数据管理")
 public class OrganizationManagerController {
 
-    @Autowired
-    private OrganizationService organizationService;
-
     @Autowired
     private OrganizationManagerServiceImpl organizationManagerService;
 
     //------------------------------机构管理 start----------------------
-    @ResourceAuth(value = "saveOrgInfo", type = AuthType.Platform, remark = "项目管理_保存项目_1_Button")
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform)
-    @Operation(summary = "机构信息-保存", description = "机构信息-保存")
-    @RequestMapping(value = "saveOrgInfo", method = {RequestMethod.POST})
-    public ResultContent saveOrgInfo(@RequestBody @Valid OrgSaveParam param) {
-        return this.organizationManagerService.saveOrgInfo(param);
-    }
 
+    //    @ResourceAuth(value = "orgPage", type = AuthType.Platform, remark = "机构管理_机构列表_1_Menu")
     @ResourceAuth(value = "user", type = AuthType.User)
     @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform)
     @Operation(summary = "机构列表-分页查询", description = "机构列表-分页查询")
@@ -55,11 +47,13 @@ public class OrganizationManagerController {
         return organizationManagerService.orgPage(param, pageable);
     }
 
+    @ResourceAuth(value = "saveOrgInfo", type = AuthType.Platform, remark = "项目管理_添加项目_1_Button")
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "得到项目下所有的机构列表数据", description = "得到项目下所有的机构列表数据")
-    @RequestMapping(value = "getProjectOrgList", method = {RequestMethod.POST})
-    public ResultContent<List<OrganizationSimpleModel>> getProjectOrgList(@RequestBody ProjectOidParam param) {
-        return this.organizationManagerService.getProjectOrgList(param.getProjectOid());
+    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform)
+    @Operation(summary = "机构信息-保存", description = "机构信息-保存")
+    @RequestMapping(value = "saveOrgInfo", method = {RequestMethod.POST})
+    public ResultContent saveOrgInfo(@RequestBody @Valid OrgSaveParam param) {
+        return this.organizationManagerService.saveOrgInfo(param);
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)

+ 87 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/PositionManagerController.java

@@ -0,0 +1,87 @@
+package com.zhongshu.card.server.core.controller.orgManager;
+
+import com.github.microservice.auth.client.constant.AuthConstant;
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.base.IDParam;
+import com.zhongshu.card.client.model.school.DictInfoParam;
+import com.zhongshu.card.client.model.school.DictInfoSearch;
+import com.zhongshu.card.client.service.school.DictInfoService;
+import com.zhongshu.card.client.type.DictInfoType;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 机构 职位管理
+ *
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("positionManager")
+@Tag(name = "机构职位管理")
+public class PositionManagerController {
+
+    @Autowired
+    DictInfoService dictInfoService;
+
+    @ResourceAuth(value = "positionList", type = AuthType.Platform, remark = "职位管理_职位列表_1_Menu")
+    @ResourceAuth(value = "positionList", type = AuthType.Project, remark = "职位管理_职位列表_1_Menu")
+    @ResourceAuth(value = "positionList", type = AuthType.School, remark = "职位管理_职位列表_1_Menu")
+    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
+    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.School, remark = "")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "机构职位列表-分页查询", description = "人员职位列表-分页查询")
+    @RequestMapping(value = {"positionPageManager"}, method = {RequestMethod.POST})
+    public ResultContent<Page<DictInfoParam>> positionPageManager(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) DictInfoSearch param) {
+        param.setDictInfoType(DictInfoType.Position);
+        return dictInfoService.page(param, pageable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "添加-编辑职位", description = "添加-编辑职位")
+    @RequestMapping(value = "addPosition", method = {RequestMethod.POST})
+    public ResultContent addPosition(@RequestBody DictInfoParam param) {
+        param.setDictInfoType(DictInfoType.Position);
+        return this.dictInfoService.addDict(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除职位", description = "删除职位")
+    @RequestMapping(value = "deletePosition", method = {RequestMethod.POST})
+    public ResultContent deletePosition(@RequestBody IDParam param) {
+        return this.dictInfoService.deleteDict(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "职位详情", description = "职位详情")
+    @RequestMapping(value = "getPosition", method = {RequestMethod.POST})
+    public ResultContent<DictInfoParam> getPosition(@RequestBody IDParam param) {
+        return this.dictInfoService.getDictInfo(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "查询职位所有的数据", description = "查询职位所有的数据")
+    @RequestMapping(value = {"findPositionByOid"}, method = {RequestMethod.POST})
+    public ResultContent<List<DictInfoParam>> findDictInfosByOid(
+            @Parameter(required = false) DictInfoSearch param) {
+        param.setDictInfoType(DictInfoType.Position);
+        return dictInfoService.findDictInfosByOid(param);
+    }
+
+}

+ 88 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/orgManager/ProjectBindOrgController.java

@@ -0,0 +1,88 @@
+package com.zhongshu.card.server.core.controller.orgManager;
+
+import com.github.microservice.auth.client.constant.AuthConstant;
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.base.IDParam;
+import com.zhongshu.card.client.model.base.OidModel;
+import com.zhongshu.card.client.model.base.ProjectOidParam;
+import com.zhongshu.card.client.model.org.OrganizationRelationSearch;
+import com.zhongshu.card.client.model.org.OrganizationSearchParam;
+import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
+import com.zhongshu.card.client.model.orgModel.OrgSaveParam;
+import com.zhongshu.card.client.model.orgModel.ProjectBindOrgParam;
+import com.zhongshu.card.client.service.org.OrganizationService;
+import com.zhongshu.card.client.type.OrganizationRelationType;
+import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
+import com.zhongshu.card.server.core.service.orgManager.ProjectBindOrgServiceImpl;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@RequestMapping("projectBindOrg")
+@Tag(name = "项目绑定机构管理")
+public class ProjectBindOrgController {
+
+    @Autowired
+    private OrganizationService organizationService;
+
+    @Autowired
+    private OrganizationManagerServiceImpl organizationManagerService;
+
+    @Autowired
+    private ProjectBindOrgServiceImpl projectBindOrgService;
+
+
+    //------------------------------机构管理 start----------------------
+    @ResourceAuth(value = "projectBindOrg", type = AuthType.Platform, remark = "项目机构管理_绑定项目_2_Button")
+    @ResourceAuth(value = "projectBindOrg", type = AuthType.Project, remark = "项目机构管理_绑定项目_2_Button")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform)
+    @Operation(summary = "项目绑定机构-保存", description = "项目绑定机构-保存")
+    @RequestMapping(value = "projectBindOrg", method = {RequestMethod.POST})
+    public ResultContent projectBindOrg(@RequestBody @Valid ProjectBindOrgParam param) {
+        return this.projectBindOrgService.projectBindOrg(param);
+    }
+
+    @ResourceAuth(value = "projectOrgPage", type = AuthType.Platform, remark = "项目机构管理_机构列表_1_Menu")
+    @ResourceAuth(value = "projectOrgPage", type = AuthType.Project, remark = "项目机构管理_机构列表_1_Menu")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform)
+    @Operation(summary = "项目机构列表-分页查询", description = "项目机构列表-分页查询")
+    @RequestMapping(value = {"projectOrgPage"}, method = {RequestMethod.POST})
+    public ResultContent<Page<OrganizationSimpleModel>> projectOrgPage(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) OrganizationRelationSearch param) {
+        param.setRelationType(OrganizationRelationType.ProjectBindOrg);
+        return projectBindOrgService.orgPage(param, pageable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "得到项目下所有的机构列表数据", description = "得到项目下所有的机构列表数据")
+    @RequestMapping(value = "getProjectOrgList", method = {RequestMethod.POST})
+    public ResultContent<List<OrganizationSimpleModel>> getProjectOrgList(
+            @RequestBody ProjectOidParam param) {
+        return this.projectBindOrgService.getProjectOrgList(param.getProjectOid());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除项目机构信息", description = "删除项目机构信息")
+    @RequestMapping(value = "deleteOrg", method = {RequestMethod.POST})
+    public ResultContent deleteOrg(@RequestBody IDParam param) {
+        return this.projectBindOrgService.deleteRelation(param.getId());
+    }
+
+}

+ 0 - 17
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/school/DictInfoController.java

@@ -55,23 +55,6 @@ public class DictInfoController {
         return dictInfoService.page(param, pageable);
     }
 
-    @ResourceAuth(value = "positionManager", type = AuthType.Platform, remark = "人员职位_职位列表_1_Menu")
-    @ResourceAuth(value = "positionManager", type = AuthType.Project, remark = "人员职位_职位列表_1_Menu")
-    @ResourceAuth(value = "positionManager", type = AuthType.School, remark = "人员职位_职位列表_1_Menu")
-    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
-    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.School, remark = "")
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "人员职位列表-分页查询", description = "人员职位列表-分页查询")
-    @RequestMapping(value = {"positionPageManager"}, method = {RequestMethod.POST})
-    public ResultContent<Page<DictInfoParam>> positionPageManager(
-            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
-            @Parameter(required = false) DictInfoSearch param) {
-        param.setDictInfoType(DictInfoType.Position);
-        return dictInfoService.page(param, pageable);
-    }
-
-
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "字典列表-分页查询", description = "字典列表-分页查询")
     @RequestMapping(value = {"page"}, method = {RequestMethod.POST})

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/OrganizationDao.java

@@ -20,7 +20,7 @@ public interface OrganizationDao extends MongoDao<Organization>, OrganizationDao
 
     List<Organization> findByProjectOidAndIsOrg(String projectOid, Boolean isOrg);
 
-    int countByProjectOid(String projectOid, Boolean isOrg);
+    Organization findTopByOrgCode(String orgCode);
 
     Organization findTopByNameAndAuthType(String name, AuthType authType);
 

+ 4 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/OrganizationRelationDao.java

@@ -16,6 +16,8 @@ public interface OrganizationRelationDao extends MongoDao<OrganizationRelation>,
 
     OrganizationRelation findTopById(String id);
 
+    List<OrganizationRelation> findByMainOrganizationAndRelationType(Organization mainOrganization, OrganizationRelationType relationType);
+
     void deleteByMainOrganizationAndRelationType(Organization mainOrganization, OrganizationRelationType relationType);
 
     OrganizationRelation findTopByMainOrganizationAndRelationType(Organization mainOrganization,
@@ -26,6 +28,8 @@ public interface OrganizationRelationDao extends MongoDao<OrganizationRelation>,
     // 统计项目已有的学校
     long countByRelOrganizationAndRelationType(Organization relOrganization, OrganizationRelationType relationType);
 
+    long countByMainOrganizationAndRelationType(Organization mainOrganization, OrganizationRelationType relationType);
+
     OrganizationRelation findTopByMainOrganizationAndRelOrganizationAndRelationType(
             Organization mainOrganization,
             Organization relOrganization,

+ 8 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/RoleDao.java

@@ -1,6 +1,8 @@
 package com.zhongshu.card.server.core.dao.org;
 
+import com.github.microservice.auth.security.type.AuthType;
 import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.server.core.dao.org.extend.RoleDaoExtend;
 import com.zhongshu.card.server.core.dao.org.extend.UserCountDaoExtend;
 import com.zhongshu.card.server.core.domain.org.Organization;
@@ -16,8 +18,14 @@ public interface RoleDao extends MongoDao<Role>, RoleDaoExtend {
 
     Role findTopById(String id);
 
+    List<Role> findByStateOrderBySortAsc(DataState state);
+
+    List<Role> findByAuthTypeOrderBySortAsc(AuthType authType);
+
     List<Role> findByOidOrderBySortAsc(String oid);
 
+    List<Role> findByAuthTypeAndStateOrderBySortAsc(AuthType authType, DataState state);
+
     Role findTopByNameAndOid(String name, String oid);
 
     Role findTopByCodeAndOid(String code, String oid);

+ 2 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/extend/OrganizationRelationDaoExtend.java

@@ -1,9 +1,7 @@
 package com.zhongshu.card.server.core.dao.org.extend;
 
 import com.zhongshu.card.client.model.org.OrganizationRelationSearch;
-import com.zhongshu.card.client.model.org.RoleSearchParam;
 import com.zhongshu.card.server.core.domain.org.OrganizationRelation;
-import com.zhongshu.card.server.core.domain.org.Role;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
@@ -13,5 +11,7 @@ import org.springframework.data.domain.Pageable;
  * @Version: 1.0
  */
 public interface OrganizationRelationDaoExtend {
+
     Page<OrganizationRelation> page(Pageable pageable, OrganizationRelationSearch param);
+
 }

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/extend/RoleDaoExtend.java

@@ -1,6 +1,6 @@
 package com.zhongshu.card.server.core.dao.org.extend;
 
-import com.zhongshu.card.client.model.org.RoleSearchParam;
+import com.zhongshu.card.client.model.org.role.RoleSearchParam;
 import com.zhongshu.card.server.core.domain.org.Role;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;

+ 6 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/impl/RoleDaoImpl.java

@@ -1,7 +1,7 @@
 package com.zhongshu.card.server.core.dao.org.impl;
 
 import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
-import com.zhongshu.card.client.model.org.RoleSearchParam;
+import com.zhongshu.card.client.model.org.role.RoleSearchParam;
 import com.zhongshu.card.server.core.dao.BaseImpl;
 import com.zhongshu.card.server.core.dao.org.extend.RoleDaoExtend;
 import com.zhongshu.card.server.core.domain.org.Role;
@@ -36,10 +36,15 @@ public class RoleDaoImpl extends BaseImpl implements RoleDaoExtend {
     @Override
     public Page<Role> page(Pageable pageable, RoleSearchParam param) {
         Criteria criteria = new Criteria();
+
         if (StringUtils.isNotBlank(param.getOid())) {
             criteria.and("oid").is(param.getOid());
         }
 
+        if (param.getAuthType() != null) {
+            criteria.and("authType").is(param.getAuthType());
+        }
+
         if (!CommonUtil.longIsEmpty(param.getStartTime()) && !CommonUtil.longIsEmpty(param.getEndTime())) {
             criteria.and("createTime").gte(param.getStartTime()).and("createTime").lte(param.getEndTime());
         }

+ 18 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/OrganizationRelation.java

@@ -1,8 +1,10 @@
 package com.zhongshu.card.server.core.domain.org;
 
 import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.OrganizationRelationType;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
+import com.zhongshu.card.server.core.domain.projectAbout.PayShareList;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -10,8 +12,11 @@ import lombok.NoArgsConstructor;
 import org.springframework.data.mongodb.core.mapping.DBRef;
 import org.springframework.data.mongodb.core.mapping.Document;
 
+import java.util.List;
+
 /**
  * 机构关系  比如 学校(主)关联项目  商户(主)关联 学校
+ *
  * @author TRX
  * @date 2024/6/4
  */
@@ -29,7 +34,7 @@ public class OrganizationRelation extends SuperMain {
     private String mainName;
 
     @Schema(description = "主数据的类型")
-    AuthType authType = AuthType.Project;
+    private AuthType authType = AuthType.Project;
 
     @Schema(description = "关联数据")
     @DBRef(lazy = true)
@@ -38,7 +43,19 @@ public class OrganizationRelation extends SuperMain {
     @Schema(description = "关联的名称")
     private String relName;
 
+    @Schema(description = "被绑定的数据类型")
+    private AuthType relAuthType;
+
     @Schema(description = "绑定关联类型")
     private OrganizationRelationType relationType;
 
+    @Schema(description = "分组配置")
+    @DBRef(lazy = true)
+    private PayShareList payShareList;
+
+    @Schema(description = "负责人userId")
+    private List<String> managerUserIds;
+
+    @Schema(description = "数据状态")
+    private DataState state = DataState.Enable;
 }

+ 4 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/Role.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.domain.org;
 
+import com.github.microservice.auth.security.type.AuthType;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.RoleType;
 import com.zhongshu.card.client.type.school.RoleDefaultType;
@@ -33,6 +34,9 @@ public class Role extends SuperMain {
     @Schema(description = "角色类型")
     private RoleType roleType;
 
+    @Schema(description = "角色类型")
+    private AuthType authType;
+
     @Schema(description = "默认角色的类型")
     private RoleDefaultType roleDefaultType;
 

+ 14 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/base/SuperService.java

@@ -174,6 +174,14 @@ public abstract class SuperService {
         }
     }
 
+    public void initDefaultUserAndOidCheck(SuperParam param) {
+        initDefaultUserParam(param);
+        Assert.hasText(param.getOid(), "oid不能为空");
+        if (param.getId() != null && param.getId().trim().equals("")) {
+            param.setId(null);
+        }
+    }
+
     public void initDefaultUserAndOidNoExcept(SuperParam param) {
         initDefaultUserParam(param);
         String oid = param.getOid();
@@ -223,6 +231,12 @@ public abstract class SuperService {
         initSearchParam(param);
     }
 
+    public void initSearchParamCheckOid(SuperSearch param) {
+        String oid = param.getOid();
+        Assert.hasText(oid, "oid不能为空");
+        initSearchParam(param);
+    }
+
     public void initSearchParam(SuperSearch param) {
         List<Long> times = param.getTimes();
         if (ObjectUtils.isNotEmpty(times) && times.size() == 2) {

+ 11 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/DepartmentServiceImpl.java

@@ -4,6 +4,7 @@ import com.zhongshu.card.client.model.org.DepartmentModel;
 import com.zhongshu.card.client.model.org.DepartmentParam;
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.net.ResultMessage;
+import com.zhongshu.card.client.model.org.OidAboutInfo;
 import com.zhongshu.card.client.service.org.DepartmentService;
 import com.zhongshu.card.client.utils.ITree;
 import com.zhongshu.card.client.utils.TreeUtil;
@@ -12,6 +13,7 @@ import com.zhongshu.card.server.core.dao.org.DepartmentDao;
 import com.zhongshu.card.server.core.domain.org.Department;
 import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import com.zhongshu.card.server.core.util.CommonUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -36,6 +38,9 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
     @Autowired
     DepartmentDao departmentDao;
 
+    @Autowired
+    OrganizationManagerServiceImpl organizationManagerService;
+
     /**
      * 添加部门
      *
@@ -44,7 +49,9 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
      */
     @Override
     public ResultContent<Department> addDepartment(DepartmentParam param) {
-        initDefaultUserAndOid(param);
+        initDefaultUserAndOidCheck(param);
+        param.setOid(param.getOrgOid());
+        OidAboutInfo aboutInfo = organizationManagerService.getOidAboutInfo(param.getOid());
 
         if (CommonUtil.longIsEmpty(param.getSort())) {
             param.setSort(1L);
@@ -83,6 +90,9 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
             department = new Department();
         }
         BeanUtils.copyProperties(param, department);
+        department.setProjectOid(aboutInfo.getProjectOid());
+        department.setAboutOid(aboutInfo.getOid());
+        department.setAboutAuthType(aboutInfo.getAuthType());
         departmentDao.save(department);
         return ResultContent.buildSuccess(department);
     }

+ 7 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/OrganizationServiceImpl.java

@@ -25,6 +25,7 @@ import com.zhongshu.card.server.core.dataConfig.CardSystemDefault;
 import com.zhongshu.card.server.core.domain.org.*;
 import com.zhongshu.card.server.core.service.base.SuperService;
 import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
+import com.zhongshu.card.server.core.service.orgManager.ProjectBindOrgServiceImpl;
 import com.zhongshu.card.server.core.service.projectAbout.ProjectCommonConfigService;
 import com.zhongshu.card.server.core.service.projectAbout.ProjectIotInfoService;
 import com.zhongshu.card.server.core.service.projectAbout.ProjectWeChatInfoService;
@@ -115,6 +116,8 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
 
     @Autowired
     OrganizationManagerServiceImpl organizationManagerService;
+    @Autowired
+    private ProjectBindOrgServiceImpl projectBindOrgServiceImpl;
 
 
     /**
@@ -143,6 +146,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
         Organization organization = null;
         Organization nameOrganization = organizationDao.findTopByNameAndAuthType(name, authType);
         if (StringUtils.isNotEmpty(param.getId())) {
+            // 编辑
             organization = organizationDao.findTopById(param.getId());
             if (ObjectUtils.isEmpty(organization)) {
                 return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
@@ -152,6 +156,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
             }
             BeanUtils.copyProperties(param, organization, "code");
             initUpdateEntity(organization);
+            organizationDao.save(organization);
         } else {
             if (ObjectUtils.isNotEmpty(nameOrganization)) {
                 return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getName()));
@@ -601,7 +606,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
         }
 
         // 判断项目是否可以删除
-        long count = organizationManagerService.countProjectOrgNumber(projectOid);
+        long count = projectBindOrgServiceImpl.countProjectBindNumber(projectOid);
         if (count > 0) {
             return ResultContent.buildFail(String.format("%s 项目下包含机构,不能删除", organization.getName()));
         }
@@ -1089,6 +1094,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
                 adminRole.setRoleType(RoleType.BuildIn);
                 adminRole.setIsAdmin(Boolean.TRUE);
                 adminRole.setRoleId(roleId);
+                adminRole.setAuthType(organization.getAuthType());
                 roleDao.save(adminRole);
 
                 //权限中心: 将用户添加进管理员角色组

+ 56 - 31
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/RoleServiceImpl.java

@@ -11,6 +11,10 @@ import com.google.common.collect.Lists;
 import com.zhongshu.card.client.model.org.*;
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.net.ResultMessage;
+import com.zhongshu.card.client.model.org.role.RoleAddParam;
+import com.zhongshu.card.client.model.org.role.RoleModel;
+import com.zhongshu.card.client.model.org.role.RoleQueryParam;
+import com.zhongshu.card.client.model.org.role.RoleSearchParam;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.EditType;
 import com.zhongshu.card.client.type.PermissionPointType;
@@ -99,7 +103,6 @@ public class RoleServiceImpl extends SuperService {
             if (ObjectUtils.isNotEmpty(codeRole)) {
                 return ResultContent.buildFail(String.format("角色名称已存在:%s", param.getCode()));
             }
-
             RoleGroupModel admin = new RoleGroupModel();
             admin.setName(param.getName());
             admin.setRemark("");
@@ -157,7 +160,6 @@ public class RoleServiceImpl extends SuperService {
             // 编辑本地角色
             BeanUtils.copyProperties(param, role, "roleType");
             initUpdateEntity(role);
-
             roleDao.save(role);
         }
         return ResultContent.buildSuccess();
@@ -213,6 +215,7 @@ public class RoleServiceImpl extends SuperService {
     public ResultContent<Page<RoleModel>> page(RoleSearchParam param, Pageable pageable) {
         initOidSearchParam(param);
         param.setIsSortDesc(Boolean.FALSE);
+
         Page<Role> page = roleDao.page(pageable, param);
         return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
     }
@@ -236,6 +239,26 @@ public class RoleServiceImpl extends SuperService {
         return ResultContent.buildSuccess(models);
     }
 
+    public ResultContent<List<RoleModel>> queryRoles(RoleQueryParam param) {
+        List<RoleModel> models = new ArrayList<>();
+        AuthType authType = param.getAuthType();
+        DataState state = param.getState();
+        List<Role> roles = new ArrayList<>();
+        if (authType != null && state != null) {
+            roles = roleDao.findByAuthTypeAndStateOrderBySortAsc(authType, state);
+        } else if (authType != null && state == null) {
+            roles = roleDao.findByAuthTypeOrderBySortAsc(authType);
+        } else if (authType == null && state != null) {
+            roles = roleDao.findByStateOrderBySortAsc(state);
+        } else {
+            roles = roleDao.findByStateOrderBySortAsc(DataState.Enable);
+        }
+        if (ObjectUtils.isNotEmpty(roles)) {
+            models = roles.stream().map(this::toModel).collect(Collectors.toList());
+        }
+        return ResultContent.buildSuccess(models);
+    }
+
     /**
      * 得到角色的权限数据
      *
@@ -262,7 +285,9 @@ public class RoleServiceImpl extends SuperService {
                 }
             });
         }
-        return ResultContent.buildContent(buildAuthList(organization.getAuthType(), postAuth));
+        // 角色确定
+        AuthType authType = roleObj.getAuthType();
+        return ResultContent.buildContent(buildAuthList(authType, postAuth));
     }
 
     /**
@@ -275,38 +300,38 @@ public class RoleServiceImpl extends SuperService {
     List<ModularModel> buildAuthList(AuthType organizationType, Set<String> postAuth) {
         //获取系统所有权限
         List<AuthResourcesNameModel> authResourcesNameModels = new ArrayList<>();
-        authResourcesNameModels = authResourcesNameService.list(
-                organizationType,
-                PageRequest.of(0, 9999,
-                        Sort.by(Sort.Order.desc("createTime")))).getContent().getContent();
         List<AuthModel> authModels = new ArrayList<>();
-        authResourcesNameModels.forEach(it -> {
-            String remark = it.getRemark();
-            if (StringUtils.isNotEmpty(remark)) {
-                String[] split = remark.split("_");
-                if (split.length >= 2) {
-                    AuthModel authModel = new AuthModel();
-                    authModel.setValue(it.getName());
-                    authModel.setName(split[1]);
-                    authModel.setModularName(split[0]);
-                    int index = 1;
-                    if (split.length >= 3) {
-                        index = CommonUtil.turnStr2Inter(split[2]);
-                    }
-                    authModel.setIndex(index);
-                    if (postAuth.contains(it.getName())) {
-                        authModel.setSelect(true);
-                    }
 
-                    PermissionPointType pointType = null;
-                    if (split.length >= 4) {
-                        pointType = CommonUtil.getEnumByName(PermissionPointType.class, split[3]);
+        if (organizationType != null) {
+            authResourcesNameModels = authResourcesNameService.list(organizationType, PageRequest.of(0, 9999, Sort.by(Sort.Order.desc("createTime")))).getContent().getContent();
+            authResourcesNameModels.forEach(it -> {
+                String remark = it.getRemark();
+                if (StringUtils.isNotEmpty(remark)) {
+                    String[] split = remark.split("_");
+                    if (split.length >= 2) {
+                        AuthModel authModel = new AuthModel();
+                        authModel.setValue(it.getName());
+                        authModel.setName(split[1]);
+                        authModel.setModularName(split[0]);
+                        int index = 1;
+                        if (split.length >= 3) {
+                            index = CommonUtil.turnStr2Inter(split[2]);
+                        }
+                        authModel.setIndex(index);
+                        if (postAuth.contains(it.getName())) {
+                            authModel.setSelect(true);
+                        }
+
+                        PermissionPointType pointType = null;
+                        if (split.length >= 4) {
+                            pointType = CommonUtil.getEnumByName(PermissionPointType.class, split[3]);
+                        }
+                        authModel.setPointType(pointType);
+                        authModels.add(authModel);
                     }
-                    authModel.setPointType(pointType);
-                    authModels.add(authModel);
                 }
-            }
-        });
+            });
+        }
 
         Comparator comparator = new Comparator<AuthModel>() {
             @Override

+ 1 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/UserAccountServiceImpl.java

@@ -14,6 +14,7 @@ import com.google.common.collect.Lists;
 import com.zhongshu.card.client.model.base.AuthTypeParam;
 import com.zhongshu.card.client.model.base.UserIdModel;
 import com.zhongshu.card.client.model.org.*;
+import com.zhongshu.card.client.model.org.role.RoleModel;
 import com.zhongshu.card.client.model.school.DictInfoSimpleModel;
 import com.zhongshu.card.client.service.org.OrganizationService;
 import com.zhongshu.card.client.service.org.UserAccountService;

+ 53 - 48
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/orgManager/OrganizationManagerServiceImpl.java

@@ -119,6 +119,8 @@ public class OrganizationManagerServiceImpl extends SuperService {
 
     @Autowired
     OrganizationServiceImpl organizationServiceImpl;
+    @Autowired
+    private ProjectBindOrgServiceImpl projectBindOrgServiceImpl;
 
     /**
      * 保存项目 下的机构信息
@@ -133,35 +135,25 @@ public class OrganizationManagerServiceImpl extends SuperService {
                 || authType == AuthType.Project) {
             return ResultContent.buildFail("authType 类型错误");
         }
-        // 项目信息
-        ResultContent<Organization> checkProjectContent = checkProject(param.getProjectOid());
-        if (checkProjectContent.isFailed()) {
-            return ResultContent.buildFail(checkProjectContent.getMsg());
-        }
-        Organization projectInfo = checkProjectContent.getContent();
-
-        String code = param.getCode();
-        if (StringUtils.isEmpty(code)) {
-            code = NextNoUtil.getNextNo(authType.getCode().toUpperCase());
-            param.setCode(code);
-        }
         String name = param.getName();
 
         Organization organization = null;
-        Organization nameOrganization = organizationDao.findTopByNameAndAuthType(name, authType);
+        Organization orgCodeOrganization = organizationDao.findTopByOrgCode(param.getOrgCode());
+
         if (StringUtils.isNotEmpty(param.getId())) {
             organization = organizationDao.findTopById(param.getId());
             if (ObjectUtils.isEmpty(organization)) {
                 return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
             }
-            if (ObjectUtils.isNotEmpty(nameOrganization) && !nameOrganization.getId().equals(organization.getId())) {
-                return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getName()));
+            if (ObjectUtils.isNotEmpty(orgCodeOrganization) && !orgCodeOrganization.getId().equals(organization.getId())) {
+                return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getOrgCode()));
             }
             BeanUtils.copyProperties(param, organization, "code");
             initUpdateEntity(organization);
+            organizationDao.save(organization);
         } else {
-            if (ObjectUtils.isNotEmpty(nameOrganization)) {
-                return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getName()));
+            if (ObjectUtils.isNotEmpty(orgCodeOrganization)) {
+                return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getOrgCode()));
             }
             // 初始权限中心的机构信息
             ResultContent<String> initOrgContent = organizationServiceImpl.authCenterAddOrgInfo(name, authType, param.getRemark());
@@ -169,15 +161,23 @@ public class OrganizationManagerServiceImpl extends SuperService {
                 return ResultContent.buildFail(initOrgContent.getMsg());
             }
             String oid = initOrgContent.getContent();
+            if (StringUtils.isEmpty(param.getCode())) {
+                param.setCode(NextNoUtil.getNextNo(authType.getCode().toUpperCase()));
+            }
+            String code = param.getCode();
+            if (StringUtils.isEmpty(code)) {
+                code = NextNoUtil.getNextNo(authType.getCode().toUpperCase());
+                param.setCode(code);
+            }
+
             organization = new Organization();
             BeanUtils.copyProperties(param, organization);
             initEntityNoCheckOid(organization);
             organization.setIsOrg(Boolean.TRUE);
 
+            // 机构关联的 权限中心的oid
             organization.setOid(oid);
-            organization.setProjectOid(projectInfo.getOid());
-            organization.setAboutOid(projectInfo.getOid());
-            organization.setAboutAuthType(projectInfo.getAuthType());
+
             organizationDao.save(organization);
         }
         return ResultContent.buildSuccess();
@@ -191,7 +191,6 @@ public class OrganizationManagerServiceImpl extends SuperService {
      * @return
      */
     public ResultContent<Page<OrganizationSimpleModel>> orgPage(OrganizationSearchParam param, Pageable pageable) {
-        initSearchParam(param);
         param.setIsOrg(Boolean.TRUE);
         Page<Organization> page = organizationDao.page(pageable, param);
         return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toSimpleModel));
@@ -227,7 +226,11 @@ public class OrganizationManagerServiceImpl extends SuperService {
             return ResultContent.buildFail("当前不属于结构类型,不能删除");
         }
 
-        //1. 判断是否可以删除
+        //1. 判断机构是否可以删除
+        long number = projectBindOrgServiceImpl.countOrgBindNumber(oid);
+        if (number > 0) {
+            return ResultContent.buildFail(String.format("机构已绑定项目,不能删除"));
+        }
 
         //2. 删除机构
         organizationDao.delete(organization);
@@ -239,32 +242,6 @@ public class OrganizationManagerServiceImpl extends SuperService {
 
     //---------------------------------供其他服务调用接口 start---------------------
 
-    /**
-     * 查询项目下所有的机构信息列表
-     *
-     * @param projectOid
-     * @return
-     */
-    public ResultContent<List<OrganizationSimpleModel>> getProjectOrgList(String projectOid) {
-        List<OrganizationSimpleModel> models = new ArrayList<>();
-        List<Organization> list = organizationDao.findByProjectOidAndIsOrg(projectOid, Boolean.TRUE);
-        if (ObjectUtils.isNotEmpty(list)) {
-            models = list.stream().map(this::toSimpleModel).collect(Collectors.toList());
-        }
-        return ResultContent.buildSuccess(models);
-    }
-
-
-    /**
-     * 项目关联的结构 数量
-     *
-     * @param projectOid
-     * @return
-     */
-    public long countProjectOrgNumber(String projectOid) {
-        return organizationDao.countByProjectOid(projectOid, Boolean.TRUE);
-    }
-
     /**
      * 检查项目是否存在  是否是项目类型
      *
@@ -285,10 +262,38 @@ public class OrganizationManagerServiceImpl extends SuperService {
         return ResultContent.buildSuccess(organization);
     }
 
+    public OidAboutInfo getOidAboutInfo(String oid) {
+        OidAboutInfo aboutInfo = new OidAboutInfo();
+        Organization organization = organizationDao.findTopByOid(oid);
+        if (ObjectUtils.isNotEmpty(organization)) {
+            aboutInfo.setOid(oid);
+            aboutInfo.setAuthType(organization.getAuthType());
+            AuthType authType = organization.getAuthType();
+
+        } else {
+            aboutInfo.setOid(oid);
+        }
+        return aboutInfo;
+    }
+
     public OrganizationSimpleModel toSimpleModel(Organization entity) {
         OrganizationSimpleModel model = new OrganizationSimpleModel();
         if (ObjectUtils.isNotEmpty(entity)) {
             BeanUtils.copyProperties(entity, model);
+
+            // 区域信息
+            String adminDivisionItemCode = entity.getAdminDivisionItemCode();
+            if (StringUtils.isNotEmpty(adminDivisionItemCode)) {
+                List<String> codes = List.of(adminDivisionItemCode.split(","));
+                List<Region> regions = regionDao.findByCodeInOrderByIndexAsc(codes);
+                List<RegionModel> regionList = regions.stream().map(it -> {
+                    RegionModel regionModel = new RegionModel();
+                    BeanUtils.copyProperties(it, regionModel);
+                    return regionModel;
+                }).collect(Collectors.toList());
+                model.setRegionList(regionList);
+            }
+
         }
         return model;
     }

+ 174 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/orgManager/ProjectBindOrgServiceImpl.java

@@ -0,0 +1,174 @@
+package com.zhongshu.card.server.core.service.orgManager;
+
+import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.github.microservice.net.ResultContent;
+import com.github.microservice.net.ResultMessage;
+import com.zhongshu.card.client.model.org.OrganizationRelationSearch;
+import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
+import com.zhongshu.card.client.model.orgModel.ProjectBindOrgParam;
+import com.zhongshu.card.client.type.OrganizationRelationType;
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
+import com.zhongshu.card.server.core.dao.org.OrganizationRelationDao;
+import com.zhongshu.card.server.core.domain.org.Organization;
+import com.zhongshu.card.server.core.domain.org.OrganizationRelation;
+import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 项目绑定机构管理
+ *
+ * @author TRX
+ * @date 2024/5/31
+ */
+@Slf4j
+@Service
+public class ProjectBindOrgServiceImpl extends SuperService {
+
+    @Autowired
+    private OrganizationDao organizationDao;
+
+    @Autowired
+    private OrganizationManagerServiceImpl organizationManagerService;
+
+    @Autowired
+    private OrganizationRelationDao organizationRelationDao;
+
+    /**
+     * 项目绑定机构信息
+     *
+     * @param param
+     * @return
+     */
+    @Transactional
+    public ResultContent projectBindOrg(ProjectBindOrgParam param) {
+        String projectOid = param.getProjectOid();
+        String orgOid = param.getOrgOid();
+        Organization projectInfo = organizationDao.findTopByOid(projectOid);
+        if (ObjectUtils.isEmpty(projectInfo)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, projectInfo));
+        }
+        if (projectInfo.getAuthType() != AuthType.Project) {
+            return ResultContent.buildFail(String.format("不属于项目类型:%s", projectOid));
+        }
+
+        Organization orgInfo = organizationDao.findTopByOid(orgOid);
+        if (ObjectUtils.isEmpty(projectInfo)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, orgOid));
+        }
+        if (orgInfo.getIsOrg() == null || !orgInfo.getIsOrg()) {
+            return ResultContent.buildFail(String.format("不属于机构类型:%s", orgOid));
+        }
+
+        OrganizationRelation organizationRelation = organizationRelationDao.findTopByMainOrganizationAndRelOrganizationAndRelationType(projectInfo, orgInfo, OrganizationRelationType.ProjectBindOrg);
+        if (ObjectUtils.isNotEmpty(organizationRelation)) {
+            return ResultContent.buildFail(String.format("项目已绑定机构:%s", orgInfo.getName()));
+        }
+
+        organizationRelation = new OrganizationRelation();
+        organizationRelation.setMainOrganization(projectInfo);
+        organizationRelation.setMainName(projectInfo.getName());
+        organizationRelation.setAuthType(projectInfo.getAuthType());
+
+        organizationRelation.setRelOrganization(orgInfo);
+        organizationRelation.setRelName(orgInfo.getName());
+        organizationRelation.setRelAuthType(orgInfo.getAuthType());
+        organizationRelation.setRelationType(OrganizationRelationType.ProjectBindOrg);
+        organizationRelationDao.save(organizationRelation);
+
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 项目下的 机构列表
+     *
+     * @param param
+     * @param pageable
+     * @return
+     */
+    public ResultContent<Page<OrganizationSimpleModel>> orgPage(OrganizationRelationSearch param, Pageable pageable) {
+        Assert.hasText(param.getMainOid(), "mainOid不能为空");
+        Page<OrganizationRelation> page = organizationRelationDao.page(pageable, param);
+        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, (it) -> {
+            return organizationManagerService.toSimpleModel(it.getRelOrganization());
+        }));
+    }
+
+    /**
+     * 查询项目绑定的所有机构
+     *
+     * @param projectOid
+     * @return
+     */
+    public ResultContent<List<OrganizationSimpleModel>> getProjectOrgList(String projectOid) {
+        List<OrganizationSimpleModel> models = new ArrayList<>();
+        Organization projectInfo = organizationDao.findTopByOid(projectOid);
+        if (ObjectUtils.isEmpty(projectInfo)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, projectOid));
+        }
+        // 关系
+        List<OrganizationRelation> list = organizationRelationDao.findByMainOrganizationAndRelationType(projectInfo, OrganizationRelationType.ProjectBindOrg);
+        if (ObjectUtils.isNotEmpty(list)) {
+            models = list.stream().map(it -> {
+                return organizationManagerService.toSimpleModel(it.getRelOrganization());
+            }).collect(Collectors.toList());
+        }
+        return ResultContent.buildSuccess(models);
+    }
+
+    /**
+     * 删除关系
+     *
+     * @param id
+     * @return
+     */
+    public ResultContent deleteRelation(String id) {
+        OrganizationRelation relation = organizationRelationDao.findTopById(id);
+        if (ObjectUtils.isEmpty(relation)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        organizationRelationDao.delete(relation);
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 统计结构绑定的项目数量
+     *
+     * @param orgOid
+     * @return
+     */
+    public long countOrgBindNumber(String orgOid) {
+        Organization organization = organizationDao.findTopByOid(orgOid);
+        if (ObjectUtils.isEmpty(organization)) {
+            return 0;
+        }
+        return organizationRelationDao.countByRelOrganizationAndRelationType(organization, OrganizationRelationType.ProjectBindOrg);
+    }
+
+    /**
+     * 统计项目绑定的 结构数量
+     *
+     * @param projectOid
+     * @return
+     */
+    public long countProjectBindNumber(String projectOid) {
+        Organization organization = organizationDao.findTopByOid(projectOid);
+        if (ObjectUtils.isEmpty(organization)) {
+            return 0;
+        }
+        return organizationRelationDao.countByMainOrganizationAndRelationType(organization, OrganizationRelationType.ProjectBindOrg);
+    }
+
+}

+ 10 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/AreaServiceImpl.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.server.core.service.school;
 
 import com.zhongshu.card.client.model.base.IDsParam;
+import com.zhongshu.card.client.model.org.OidAboutInfo;
 import com.zhongshu.card.client.model.school.AreaModel;
 import com.zhongshu.card.client.model.school.AreaParam;
 import com.zhongshu.card.client.model.school.DictInfoParam;
@@ -15,6 +16,7 @@ import com.zhongshu.card.server.core.dao.school.DictInfoDao;
 import com.zhongshu.card.server.core.domain.school.Area;
 import com.zhongshu.card.server.core.domain.school.DictInfo;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import com.zhongshu.card.server.core.util.CommonUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -41,6 +43,9 @@ public class AreaServiceImpl extends SuperService implements AreaService {
     @Autowired
     DictInfoDao dictInfoDao;
 
+    @Autowired
+    OrganizationManagerServiceImpl organizationManagerService;
+
     /**
      * 添加院级
      *
@@ -49,7 +54,7 @@ public class AreaServiceImpl extends SuperService implements AreaService {
      */
     @Override
     public ResultContent<Area> addArea(AreaParam param) {
-        initDefaultUserAndOid(param);
+        initDefaultUserAndOidCheck(param);
 
         if (CommonUtil.longIsEmpty(param.getSort())) {
             param.setSort(1L);
@@ -93,6 +98,10 @@ public class AreaServiceImpl extends SuperService implements AreaService {
             dictInfo = dictInfoDao.findTopById(param.getDictInfoId());
         }
         entity.setDictInfo(dictInfo);
+        OidAboutInfo oidAboutInfo = organizationManagerService.getOidAboutInfo(param.getOid());
+        entity.setProjectOid(oidAboutInfo.getProjectOid());
+        entity.setAboutOid(oidAboutInfo.getOid());
+        entity.setAboutAuthType(oidAboutInfo.getAuthType());
         areaDao.save(entity);
         return ResultContent.buildSuccess(entity);
     }

+ 14 - 3
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/DictInfoServiceImpl.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.server.core.service.school;
 
 import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.zhongshu.card.client.model.org.OidAboutInfo;
 import com.zhongshu.card.client.model.school.*;
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.net.ResultMessage;
@@ -9,6 +10,7 @@ import com.zhongshu.card.client.type.DictInfoType;
 import com.zhongshu.card.server.core.dao.school.DictInfoDao;
 import com.zhongshu.card.server.core.domain.school.DictInfo;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
@@ -35,6 +37,9 @@ public class DictInfoServiceImpl extends SuperService implements DictInfoService
     @Autowired
     DictInfoDao dictInfoDao;
 
+    @Autowired
+    OrganizationManagerServiceImpl organizationManagerService;
+
     /**
      * 添加-编辑字典
      *
@@ -47,7 +52,8 @@ public class DictInfoServiceImpl extends SuperService implements DictInfoService
         if (param.getDictInfoType() == null) {
             return ResultContent.buildFail(String.format("dictInfoType不能为空"));
         }
-        initDefaultUserAndOid(param);
+        initDefaultUserAndOidCheck(param);
+
         if (param.getSort() == null) {
             param.setSort(1L);
         }
@@ -70,6 +76,10 @@ public class DictInfoServiceImpl extends SuperService implements DictInfoService
             }
         }
         BeanUtils.copyProperties(param, dictInfo);
+        OidAboutInfo oidAboutInfo = organizationManagerService.getOidAboutInfo(param.getOid());
+        dictInfo.setProjectOid(oidAboutInfo.getProjectOid());
+        dictInfo.setAboutAuthType(oidAboutInfo.getAuthType());
+        dictInfo.setAboutOid(oidAboutInfo.getOid());
         dictInfoDao.save(dictInfo);
         return ResultContent.buildSuccess();
     }
@@ -113,7 +123,7 @@ public class DictInfoServiceImpl extends SuperService implements DictInfoService
      */
     @Override
     public ResultContent<Page<DictInfoParam>> page(DictInfoSearch param, Pageable pageable) {
-        initOidSearchParam(param);
+        initSearchParamCheckOid(param);
         Page<DictInfo> page = dictInfoDao.page(pageable, param);
         return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
     }
@@ -126,8 +136,9 @@ public class DictInfoServiceImpl extends SuperService implements DictInfoService
      */
     @Override
     public ResultContent<List<DictInfoParam>> findDictInfosByOid(DictInfoSearch param) {
-        initOidSearchParam(param);
+        initSearchParamCheckOid(param);
         Assert.isNull(param.getDictInfoType(), "dictInfoType不能为空");
+
         List<DictInfo> list = dictInfoDao.findByOidAndDictInfoTypeOrderBySortAsc(param.getOid(), param.getDictInfoType());
         List<DictInfoParam> models = list.stream().map(this::toModel).collect(Collectors.toList());
         return ResultContent.buildSuccess(models);