初始化
This commit is contained in:
parent
6760c1c30b
commit
e54b6ec6ba
|
|
@ -85,7 +85,6 @@ public class DepartmentController extends BaseController {
|
|||
|
||||
/**
|
||||
* 搜索部门返回基本信息
|
||||
*
|
||||
* @param key 部门名称或代码
|
||||
*/
|
||||
@GetMapping("searchSimple")
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ public class PositionController extends BaseController {
|
|||
|
||||
/**
|
||||
* 启用/禁用职位
|
||||
*
|
||||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("enable")
|
||||
|
|
@ -66,7 +65,6 @@ public class PositionController extends BaseController {
|
|||
|
||||
/**
|
||||
* 搜索职位列表
|
||||
*
|
||||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("search")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ public class UserController extends BaseController {
|
|||
|
||||
/**
|
||||
* 启用/禁用用户
|
||||
*
|
||||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("enable")
|
||||
|
|
@ -74,7 +73,6 @@ public class UserController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取已授权角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@GetMapping("getAuthorizeRole")
|
||||
|
|
@ -84,7 +82,6 @@ public class UserController extends BaseController {
|
|||
|
||||
/**
|
||||
* 搜索用户
|
||||
*
|
||||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("search")
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class DepartmentControllerService {
|
|||
public void syncFromLdap(AdDTO ad) {
|
||||
if (ad.getType() != 3) {
|
||||
LdapService ldapService = new LdapService();
|
||||
ldapService.init(ad.getServer(), ad.getPort(), ad.getUserName(), ad.getUserPwd(), ad.getOu());
|
||||
ldapService.init(ad.getServer(), ad.getPort(), ad.getUserName(), ad.getUserPwd(), ad.getOu(), ad.getTimeout());
|
||||
LdapDepartmentDTO department = ldapService.getDepartmentTree(ad.getMapFrom(), ad.getType() == 1);
|
||||
if (Objects.nonNull(department)) {
|
||||
save(department, Optional.ofNullable(ad.getMapTo()).orElse(0L));
|
||||
|
|
|
|||
|
|
@ -12,10 +12,7 @@ import org.springframework.ldap.query.LdapQuery;
|
|||
import org.springframework.ldap.query.LdapQueryBuilder;
|
||||
import org.springframework.ldap.query.SearchScope;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class LdapService {
|
||||
|
|
@ -24,7 +21,7 @@ public class LdapService {
|
|||
|
||||
private String baseDn;
|
||||
|
||||
public void init(String server, int port, String username, String password, String baseDn) {
|
||||
public void init(String server, int port, String username, String password, String baseDn, int timeout) {
|
||||
this.baseDn = baseDn;
|
||||
LdapContextSource contextSource = new LdapContextSource();
|
||||
contextSource.setUrl("ldap://" + server + ":" + port);
|
||||
|
|
@ -34,6 +31,11 @@ public class LdapService {
|
|||
contextSource.setAnonymousReadOnly(false);
|
||||
contextSource.setPooled(false); // 启用连接池
|
||||
contextSource.setReferral("follow"); // 处理引用
|
||||
Map<String, Object> env = new HashMap<>();
|
||||
// 全局读取超时(所有操作)
|
||||
env.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(timeout * 1000));
|
||||
env.put("com.sun.jndi.ldap.read.timeout", String.valueOf(timeout * 1000 * 5));
|
||||
contextSource.setBaseEnvironmentProperties(env);
|
||||
contextSource.afterPropertiesSet();
|
||||
ldapTemplate = new LdapTemplate(contextSource);
|
||||
ldapTemplate.setIgnorePartialResultException(true);
|
||||
|
|
@ -77,7 +79,7 @@ public class LdapService {
|
|||
.setName(attributes.get("name").get().toString())
|
||||
.setDistinguishedName(attributes.get("distinguishedName").get().toString())
|
||||
);
|
||||
log.info("开始获取部门父级信息完成");
|
||||
log.info("获取部门父级信息完成");
|
||||
if (CollectionUtil.isNotEmpty(departments)) {
|
||||
LdapDepartmentDTO parent = departments.get(0);
|
||||
parent.getChildren().add(dto);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public class PositionControllerService {
|
|||
.throwMessage("职位已存在");
|
||||
positionService.save(new Position()
|
||||
.setName(request.getName())
|
||||
.setEnable(request.getEnable())
|
||||
.setRemark(request.getRemark())
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now()));
|
||||
|
|
@ -53,6 +54,7 @@ public class PositionControllerService {
|
|||
positionService.updateById(new Position()
|
||||
.setId(request.getId())
|
||||
.setName(request.getName())
|
||||
.setEnable(request.getEnable())
|
||||
.setRemark(request.getRemark())
|
||||
.setUpdateBy(UserUtil.getUserName())
|
||||
.setUpdateTime(LocalDateTime.now()));
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class UserControllerService {
|
|||
@Transactional
|
||||
public void syncFromLdap(AdDTO ad) {
|
||||
LdapService ldapService = new LdapService();
|
||||
ldapService.init(ad.getServer(), ad.getPort(), ad.getUserName(), ad.getUserPwd(), ad.getOu());
|
||||
ldapService.init(ad.getServer(), ad.getPort(), ad.getUserName(), ad.getUserPwd(), ad.getOu(), ad.getTimeout());
|
||||
List<LdapUserDTO> users = ldapService.getUsers(ad.getMapFrom());
|
||||
List<User> forAdd = new ArrayList<>();
|
||||
List<User> forUpdate = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package com.nflg.wms.auth.controller;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.sso.config.SaSsoServerConfig;
|
||||
import cn.dev33.satoken.sso.processor.SaSsoServerProcessor;
|
||||
import cn.dev33.satoken.stp.SaLoginConfig;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.wms.common.constant.Constant;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.vo.RoleVO;
|
||||
|
|
@ -87,6 +83,8 @@ public class SsoServerController {
|
|||
.setUserId(user.getId())
|
||||
.setToken(tokenInfo.getTokenValue())
|
||||
.setExpire(tokenInfo.getTokenTimeout())
|
||||
.setMustResetPwd(user.getMustResetPwd())
|
||||
.setEmail(user.getEmail())
|
||||
.setRoles(roleCodes.stream().map(RoleVO::getName).collect(Collectors.toList())));
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,9 @@ public class DepartmentAddQO {
|
|||
*/
|
||||
@NotBlank
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,31 +27,6 @@ public class DepartmentVO {
|
|||
private Integer source;
|
||||
|
||||
private String sourceDesc;
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String sourceId;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
private List<DepartmentVO> children = new ArrayList<>();
|
||||
|
||||
public String getSourceDesc() {
|
||||
return switch (source) {
|
||||
|
|
@ -60,4 +35,36 @@ public class DepartmentVO {
|
|||
default -> "未知";
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String sourceId;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
private List<DepartmentVO> children = new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,5 +15,15 @@ public class UserLoginVO {
|
|||
|
||||
private Long expire;
|
||||
|
||||
/**
|
||||
* 是否必须要重新设置密码
|
||||
*/
|
||||
private Boolean mustResetPwd;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
private List<String> roles;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,4 +108,9 @@ public class User implements Serializable {
|
|||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 登录后是否必须重设密码
|
||||
*/
|
||||
private Boolean mustResetPwd;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue