Min 2 роки тому
батько
коміт
0c108fbd2f

+ 8 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java

@@ -346,21 +346,21 @@ public class UserController {
     }
 
     @RequestMapping("/getOU")
-    public HttpRespMsg getOU(String ouName) throws NamingException {
+    public HttpRespMsg getOU() throws NamingException {
         HttpRespMsg httpRespMsg=new HttpRespMsg();
-        httpRespMsg.setData(userService.ldapGetOU(ouName));
+        httpRespMsg.setData(userService.ldapGetOU());
         return httpRespMsg;
     }
 
     @RequestMapping("/getUser")
-    public HttpRespMsg getUser(String ouName) throws Exception {
+    public HttpRespMsg getUser() throws Exception {
         HttpRespMsg httpRespMsg=new HttpRespMsg();
-        httpRespMsg.setData(userService.getUser(ouName));
+        httpRespMsg.setData(userService.getUser());
         return httpRespMsg;
     }
 
     @RequestMapping("/initSystemForAd")
-    public HttpRespMsg initSystemForAd(String companyName,String ouName) throws Exception {
+    public HttpRespMsg initSystemForAd(String companyName) throws Exception {
         HttpRespMsg msg = new HttpRespMsg();
         Company company = new Company().setCompanyName(companyName)
                 .setExpirationDate(LocalDateTime.now().plusDays(36500));
@@ -388,7 +388,7 @@ public class UserController {
             companyReportMapper.insert(companyReport);
         }
         SysRole role = sysRoleMapper.selectOne(new QueryWrapper<SysRole>().eq("company_id", company.getId()).eq("rolename","普通员工"));
-        List<JSONObject> deptArrays = userService.ldapGetOU(ouName);
+        List<JSONObject> deptArrays = userService.ldapGetOU();
         for (JSONObject dept : deptArrays) {
             Department department=new Department();
             department.setDepartmentName(dept.getString("name"))
@@ -405,7 +405,7 @@ public class UserController {
             departmentMapper.insert(department);
         }
         List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", company.getId()));
-        List<JSONObject> userArrays = userService.getUser(ouName);
+        List<JSONObject> userArrays = userService.getUser();
         for (JSONObject user : userArrays) {
             User u=new User();
             u.setId(SnowFlake.nextId()+"")
@@ -427,8 +427,8 @@ public class UserController {
                 if(one!=null){
                     u.setDepartmentId(one.getDepartmentId()).setDepartmentName(one.getDepartmentName()).setDepartmentCascade(convertDepartmentIdToCascade(one.getDepartmentId(),departmentList));
                 }
+                userService.save(u);
             }
-            userService.save(u);
         }
         return msg;
     }

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java

@@ -96,7 +96,7 @@ public interface UserService extends IService<User> {
 
     boolean ldapAuth(String username, String passWord);
 
-    List<JSONObject> ldapGetOU(String ouName) throws NamingException;
+    List<JSONObject> ldapGetOU() throws NamingException;
 
-    List<JSONObject> getUser(String ouName) throws Exception;
+    List<JSONObject> getUser() throws Exception;
 }

+ 4 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -2951,11 +2951,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     }
 
     @Override
-    public List<JSONObject> ldapGetOU(String ouName) throws NamingException {
+    public List<JSONObject> ldapGetOU() throws NamingException {
         LdapContext ldapContext = adLogin();
         HttpRespMsg httpRespMsg=new HttpRespMsg();
         //域部门节点
-        String searchBase = "OU="+ouName+",DC="+dcFirst+",DC="+dcSecond;
+        String searchBase = "DC="+dcFirst+",DC="+dcSecond;
         //搜索条件
         String searchFilter = "objectclass=organizationalUnit";
         //String searchFilter = "(&(objectclass=organizationalUnit)(|(name=名称1)(name=名称2)))"; //查询部门,并且部门名称等于名称1或者名称2
@@ -2997,11 +2997,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     }
 
     @Override
-    public List<JSONObject> getUser(String ouName) throws Exception{
+    public List<JSONObject> getUser() throws Exception{
         HttpRespMsg httpRespMsg=new HttpRespMsg();
         LdapContext ldapContext = this.adLogin();
         String searchFilter = "objectclass=User";
-        String searchBase = "OU="+ouName+",DC="+dcFirst+",DC="+dcSecond;
+        String searchBase = "DC="+dcFirst+",DC="+dcSecond;
         // 创建搜索控制器
         SearchControls searchCtls = new SearchControls();
         String[]  returnedAttrs={"givenName","name","distinguishedName","objectGUID", "objectCategory", "logonCount","sAMAccountName","userPrincipalName"};