Ver Fonte

机构类型

TRX há 1 ano atrás
pai
commit
605ac41bd7

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

@@ -99,5 +99,8 @@ public class OrganizationUserModel extends SuperModel {
     private List<RoleModel> roles = new ArrayList<>();
 
     @Schema(description = "部门信息")
+    DepartmentModel department;
+
+    @Schema(description = "部门信息所有级")
     private List<DepartmentModel> departments = new ArrayList<>();
 }

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

@@ -19,6 +19,7 @@ public class RoleAddParam extends SuperParam {
     @Schema(description = "角色编码")
     private String code;
 
+    @Schema(description = "角色类型", hidden = true)
     RoleType roleType = RoleType.Custom;
 
     @Schema(description = "默认角色的类型")

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

@@ -50,7 +50,7 @@ public class UserCountAddParam extends SuperParam {
     UserState state = UserState.Normal;
 
     @Schema(description = "部门信息")
-    List<String> departmentIds;
+    String departmentId;
 
     @Schema(description = "角色信息")
     List<String> roleIds;

+ 1 - 5
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/UserController.java → FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/UserManagerController.java

@@ -3,13 +3,11 @@ package com.zhongshu.card.server.core.controller.org;
 import com.github.microservice.auth.security.annotations.ResourceAuth;
 import com.github.microservice.auth.security.helper.AuthHelper;
 import com.github.microservice.auth.security.type.AuthType;
-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.ret.ResultContent;
 import com.zhongshu.card.client.service.org.OrganizationService;
 import com.zhongshu.card.client.service.org.UserAccountService;
-import com.zhongshu.card.client.utils.type.UserState;
 import com.zhongshu.card.server.core.service.org.IndexService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -24,8 +22,6 @@ 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/4
@@ -33,7 +29,7 @@ import java.util.List;
 @RestController
 @RequestMapping("user")
 @Tag(name = "用户管理")
-public class UserController {
+public class UserManagerController {
 
     @Autowired
     IndexService indexService;

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

@@ -90,6 +90,6 @@ public class OrganizationUser extends SuperMain {
 
     @Schema(description = "部门信息")
     @DBRef(lazy = true)
-    private List<Department> departments = new ArrayList<>();
+    private Department department;
 
 }

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

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -155,6 +156,9 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
         List<Department> list = new ArrayList<>();
         loopLoad(id, list);
         List<DepartmentModel> models = list.stream().map(this::toModel).collect(Collectors.toList());
+        if (ObjectUtils.isNotEmpty(models)) {
+            Collections.reverse(models);
+        }
         return models;
     }
 
@@ -169,8 +173,9 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
     }
 
     public DepartmentModel toModel(Department entity) {
-        DepartmentModel model = new DepartmentModel();
+        DepartmentModel model = null;
         if (ObjectUtils.isNotEmpty(entity)) {
+            model = new DepartmentModel();
             BeanUtils.copyProperties(entity, model);
         }
         return model;

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

@@ -10,15 +10,11 @@ import com.github.microservice.components.data.base.util.PageEntityUtil;
 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.school.DictInfoParam;
 import com.zhongshu.card.client.model.school.DictInfoSimpleModel;
-import com.zhongshu.card.client.model.school.RegisterUserParam;
 import com.zhongshu.card.client.ret.ResultContent;
 import com.zhongshu.card.client.ret.ResultMessage;
-import com.zhongshu.card.client.service.org.DepartmentService;
 import com.zhongshu.card.client.service.org.OrganizationService;
 import com.zhongshu.card.client.service.org.UserAccountService;
-import com.zhongshu.card.client.service.school.DictInfoService;
 import com.zhongshu.card.client.utils.type.*;
 import com.zhongshu.card.server.core.dao.org.*;
 import com.zhongshu.card.server.core.dao.school.DictInfoDao;
@@ -27,7 +23,10 @@ import com.zhongshu.card.server.core.domain.org.*;
 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.school.DictInfoServiceImpl;
-import com.zhongshu.card.server.core.util.*;
+import com.zhongshu.card.server.core.util.BeanUtils;
+import com.zhongshu.card.server.core.util.CommonUtil;
+import com.zhongshu.card.server.core.util.ValidateResult;
+import com.zhongshu.card.server.core.util.ValidateUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -116,12 +115,12 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
             return ResultContent.buildFail(String.format("oid不存在:%s", oid));
         }
         List<Role> roles = new ArrayList<>();
-        List<Department> departments = new ArrayList<>();
+        Department department = null;
         if (ObjectUtils.isNotEmpty(param.getRoleIds())) {
             roles = roleDao.findByOidAndIdIn(oid, param.getRoleIds());
         }
-        if (ObjectUtils.isNotEmpty(param.getDepartmentIds())) {
-            departments = departmentDao.findByOidAndIdIn(oid, param.getDepartmentIds());
+        if (ObjectUtils.isNotEmpty(param.getDepartmentId())) {
+            department = departmentDao.findTopById(param.getDepartmentId());
         }
 
         UserAccount temp = null;
@@ -210,14 +209,17 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
 
         BeanUtils.copyProperties(param, organizationUser, "id", "oid");
         // 职位信息
+        DictInfo position = null;
         if (StringUtils.isNotEmpty(param.getPositionId())) {
-            organizationUser.setPosition(dictInfoDao.findTopById(param.getPositionId()));
+            position = dictInfoDao.findTopById(param.getPositionId());
         }
+        organizationUser.setPosition(position);
+
         organizationUser.setAuthType(organization.getAuthType());
         // 设置角色
         organizationUser.setRoles(roles);
         // 设置部门
-        organizationUser.setDepartments(departments);
+        organizationUser.setDepartment(department);
         organizationUserDao.save(organizationUser);
 
         // 权限中心
@@ -585,9 +587,11 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
                 model.setRoles(roleModels);
             }
             // 部门信息
-            if (ObjectUtils.isNotEmpty(entity.getDepartments())) {
-                List<DepartmentModel> roleModels = entity.getDepartments().stream().map(departmentService::toModel).collect(Collectors.toList());
-                model.setDepartments(roleModels);
+            if (ObjectUtils.isNotEmpty(entity.getDepartment())) {
+                DepartmentModel departmentModel = departmentService.toModel(entity.getDepartment());
+                model.setDepartment(departmentModel);
+                List<DepartmentModel> departmentModels = departmentService.getParents(entity.getDepartment().getId());
+                model.setDepartments(departmentModels);
             }
         }
         return model;