修复缺失的service文件
This commit is contained in:
@ -26,19 +26,18 @@ import com.xjrsoft.common.core.exception.ValidationException;
|
||||
import com.xjrsoft.common.redis.service.RedisUtil;
|
||||
import com.xjrsoft.organization.client.*;
|
||||
import com.xjrsoft.organization.entity.*;
|
||||
import com.xjrsoft.organization.service.*;
|
||||
import com.xjrsoft.system.client.ILoginConfigClient;
|
||||
import com.xjrsoft.system.client.ITenantClient;
|
||||
import com.xjrsoft.system.dto.CreateTokenDto;
|
||||
import com.xjrsoft.system.entity.LoginConfig;
|
||||
import com.xjrsoft.system.entity.Tenant;
|
||||
import com.xjrsoft.system.service.ILoginConfigService;
|
||||
import com.xjrsoft.system.vo.CreateTokenVo;
|
||||
import com.xjrsoft.system.vo.LoginVo;
|
||||
import com.xjrsoft.tenant.config.TenantConfig;
|
||||
import com.xjrsoft.tenant.util.SecureUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -79,9 +78,7 @@ public class LoginServiceImpl implements ILoginService {
|
||||
|
||||
@Override
|
||||
public User getUserInfoByName(String userName) {
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(User::getUserName, userName);
|
||||
User loginUser = userService.getOne(queryWrapper);
|
||||
User loginUser = userClient.getUserByUserNameFeign(userName);
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
@ -98,12 +95,9 @@ public class LoginServiceImpl implements ILoginService {
|
||||
throw new MyException("登录人数超过授权人数,无法登录,请联系管理员!");
|
||||
}
|
||||
}
|
||||
User loginUser = getUserInfoByName(dto.getUserName());
|
||||
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(User::getUserName, dto.getUserName());
|
||||
User loginUser = userService.getOne(queryWrapper);
|
||||
|
||||
List<LoginConfig> list = loginConfigService.list();
|
||||
List<LoginConfig> list = loginConfigClient.getAllListFeign();
|
||||
if (list.size() == 0){//如果没有,则设置为默认配置,并进行保存
|
||||
LoginConfig loginConfig = new LoginConfig();
|
||||
loginConfig.setId(1L);
|
||||
@ -113,7 +107,7 @@ public class LoginServiceImpl implements ILoginService {
|
||||
loginConfig.setPasswordStrategy(YesOrNoEnum.YES.getCode());
|
||||
loginConfig.setStrategyMaxNumber(7);
|
||||
list.add(loginConfig);
|
||||
loginConfigService.save(loginConfig);
|
||||
loginConfigClient.addLoginConfigFeign(loginConfig);
|
||||
}
|
||||
LoginConfig loginConfig = list.get(0);
|
||||
|
||||
@ -140,13 +134,13 @@ public class LoginServiceImpl implements ILoginService {
|
||||
redisUtil.set(GlobalConstant.LOGIN_ERROR_NUMBER + loginUser.getId() , Integer.valueOf(value) + 1);
|
||||
}else {
|
||||
loginUser.setEnabledMark(EnabledMark.DISABLED.getCode());
|
||||
userService.updateById(loginUser);
|
||||
userClient.updateUserInfoFeign(loginUser);
|
||||
throw new MyException("当前账号已被锁定,请联系管理员");
|
||||
}
|
||||
}else {
|
||||
if (loginConfig.getStrategyMaxNumber() == 1){
|
||||
loginUser.setEnabledMark(EnabledMark.DISABLED.getCode());
|
||||
userService.updateById(loginUser);
|
||||
userClient.updateUserInfoFeign(loginUser);
|
||||
throw new MyException("当前账号已被锁定,请联系管理员");
|
||||
}else {
|
||||
redisUtil.set(GlobalConstant.LOGIN_ERROR_NUMBER + loginUser.getId() , number);
|
||||
@ -189,24 +183,22 @@ public class LoginServiceImpl implements ILoginService {
|
||||
|
||||
SaSession tokenSession = StpUtil.getTokenSession();
|
||||
|
||||
List<UserDeptRelation> userDeptRelations = userDeptRelationService.list(Wrappers.lambdaQuery(UserDeptRelation.class)
|
||||
.eq(UserDeptRelation::getUserId, StpUtil.getLoginIdAsLong()));
|
||||
List<UserDeptRelation> userDeptRelations = userDeptRelationClient.getUserDeptRelationListFeign(StpUtil.getLoginIdAsLong());
|
||||
|
||||
List<UserPostRelation> userPostRelations = userPostRelationService.list(Wrappers.lambdaQuery(UserPostRelation.class)
|
||||
.eq(UserPostRelation::getUserId, StpUtil.getLoginIdAsLong()));
|
||||
List<UserPostRelation> userPostRelations = userPostRelationClient.getUserPostRelationListFeign(StpUtil.getLoginIdAsLong());
|
||||
|
||||
//获取登陆人所选择的身份缓存
|
||||
String postId = redisUtil.get(GlobalConstant.LOGIN_IDENTITY_CACHE_PREFIX + loginUser.getId());
|
||||
|
||||
Post post = new Post();
|
||||
if (StrUtil.isNotBlank(postId) && !postId.equals("null")) {
|
||||
post = postService.getById(Long.valueOf(postId));
|
||||
post = postClient.getPostByIdFeign(Long.valueOf(postId));
|
||||
}
|
||||
|
||||
if (userPostRelations.size() > 0) {
|
||||
List<Long> postIds = userPostRelations.stream().map(UserPostRelation::getPostId).collect(Collectors.toList());
|
||||
|
||||
List<Post> postList = postService.listByIds(postIds);
|
||||
List<Post> postList = postClient.getPostListByIdsFeign(postIds);
|
||||
if ((post == null || StrUtil.isBlank(postId)) && com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(postList)) {
|
||||
post = postList.get(0);
|
||||
}
|
||||
@ -222,8 +214,8 @@ public class LoginServiceImpl implements ILoginService {
|
||||
if (userDeptRelations.size() > 0) {
|
||||
// 存当前用户所有部门到缓存
|
||||
List<Long> departmentIds = userDeptRelations.stream().map(UserDeptRelation::getDeptId).collect(Collectors.toList());
|
||||
List<Department> departmentList = departmentService.listByIds(departmentIds);
|
||||
departmentService.queryPathFromRoot(departmentList);
|
||||
List<Department> departmentList = departmentClient.getDepartmentListByIdsFeign(departmentIds);
|
||||
departmentClient.queryPathFromRoot(departmentList);
|
||||
tokenSession.set(GlobalConstant.LOGIN_USER_DEPT_LIST_KEY, departmentList);
|
||||
|
||||
//主部门
|
||||
@ -234,7 +226,7 @@ public class LoginServiceImpl implements ILoginService {
|
||||
Department department = departmentList.get(0);
|
||||
//如果此人有岗位 使用岗位的deptId 找到当前组织机构
|
||||
if (ObjectUtil.isNotNull(post.getId())) {
|
||||
department = departmentService.getById(post.getDeptId());
|
||||
department = departmentClient.getDepartmentByIdFeign(post.getDeptId());
|
||||
}else if(ObjectUtil.isNotEmpty(mainDepartmentIds)){
|
||||
//找一个主部门
|
||||
department=departmentList.stream().filter(x->mainDepartmentIds.contains(x.getId())).findFirst().get();
|
||||
@ -251,10 +243,10 @@ public class LoginServiceImpl implements ILoginService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断用户名和密码是否正确,有2中情况,1:账号密码登录,2:互信token登录,
|
||||
* 方式1是传入的未加密的密码,方式2传入的是通过md5已加密的密码,所以通过判断密码的长度来判断是否已加密
|
||||
* */
|
||||
/**
|
||||
* 判断用户名和密码是否正确,有2中情况,1:账号密码登录,2:互信token登录,
|
||||
* 方式1是传入的未加密的密码,方式2传入的是通过md5已加密的密码,所以通过判断密码的长度来判断是否已加密
|
||||
* */
|
||||
public boolean checkPassword(User loginUser,LoginDto dto)
|
||||
{
|
||||
//如果长度是32,即传入的是密文
|
||||
@ -262,7 +254,7 @@ public class LoginServiceImpl implements ILoginService {
|
||||
return (loginUser == null || !StrUtil.equals(loginUser.getPassword(), dto.getPassword()));
|
||||
}
|
||||
else {
|
||||
return (loginUser == null || !StrUtil.equals(loginUser.getPassword(), SaSecureUtil.md5BySalt(dto.getPassword(), GlobalConstant.SECRET_KEY)));
|
||||
return (loginUser == null || !StrUtil.equals(loginUser.getPassword(), SaSecureUtil.md5BySalt(dto.getPassword(), GlobalConstant.SECRET_KEY)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,7 +280,7 @@ public class LoginServiceImpl implements ILoginService {
|
||||
* @param deviceType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
/*@Override
|
||||
public LoginConfig validateLoginConfig(Integer deviceType) {
|
||||
if (licenseConfig.getEnabled()) {
|
||||
//查出所有在线用户
|
||||
@ -335,6 +327,6 @@ public class LoginServiceImpl implements ILoginService {
|
||||
SaManager.setConfig(oldConfig);
|
||||
|
||||
return loginConfig;
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@ -73,6 +73,9 @@ public class SsoServiceImpl implements SsoService {
|
||||
@Value("${xjrsoft.dist.url:}")
|
||||
private String url;
|
||||
|
||||
@Value("${xjrsoft.openLoginLog: false}")
|
||||
private boolean openLoginLog;
|
||||
|
||||
private String pcPath = "/flow/%s/%s/approveFlow?taskId=%s";
|
||||
|
||||
private String mobilePath = "/pages/workflow/approval?taskId=%s&processId=%s&type=todo";
|
||||
|
||||
Reference in New Issue
Block a user