diff --git a/dq-financial-guarantee/src/main/resources/bootstrap.properties b/dq-financial-guarantee/src/main/resources/bootstrap.properties index e979dd87..7e9ffae0 100644 --- a/dq-financial-guarantee/src/main/resources/bootstrap.properties +++ b/dq-financial-guarantee/src/main/resources/bootstrap.properties @@ -1,5 +1,5 @@ #服务名称 -#spring.application.name=dq-financial-guarantee +spring.application.name=dq-financial-guarantee ##配置中心地址 spring.cloud.nacos.config.server-addr=192.168.31.140:8848 spring.cloud.nacos.config.namespace=58fa89c6-0e23-4530-ac13-95747e873c60 diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java index ec65bf6e..943c3b31 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java @@ -31,4 +31,6 @@ public interface UserLoginDao extends BaseMapper { Boolean updateUserLogin(@Param("userId") Long userId, @Param("date") Date date); Integer countWeChatId(String weChatId); + + String getNameByUserId(Long userId); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java index e5fe5b68..61dc4d7b 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java @@ -47,6 +47,8 @@ public class UserDetailsServiceImpl implements UserDetailsService { private AuthEmployeeRoleDao userRoleMapper; @Autowired private HrauthFeignService hrauthFeignService; + @Autowired + private UserLoginDao userLoginDao; /*** * 根据账号获取用户信息 @@ -57,13 +59,20 @@ public class UserDetailsServiceImpl implements UserDetailsService { public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { // 从数据库中取出用户信息 List userList = userMapper.selectList(new QueryWrapper().eq("phone_account", username)); + List userList2 = userMapper.selectList(new QueryWrapper().eq("account", username)); UserEntity user; + String name = null; // 判断用户是否存在 if (!CollectionUtils.isEmpty(userList)) { user = userList.get(0); + name = userLoginDao.getNameByUserId(userList.get(0).getId()); + } else if(!CollectionUtils.isEmpty(userList2)){ + user = userList2.get(0); + name = userLoginDao.getNameByUserId(userList2.get(0).getId()); } else { throw new UsernameNotFoundException("用户名不存在或已禁用!"); } + user.setAccount(name); // 返回UserDetails实现类 return new SecurityUser(user, getUserRoles(user.getId().intValue())); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java index df1192d7..69c23249 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java @@ -117,7 +117,10 @@ public class UserLoginServiceImpl extends ServiceImpl public ResponseResult login(LoginRequest loginRequest) { //判断用户登录方式 UserEntity userEntity = baseMapper.login(loginRequest); + String name = null; if(userEntity != null){ + //获取员工name + name = baseMapper.getNameByUserId(userEntity.getId()); //删除redis里面的userEntity JwtUtils.removeUserEntityByUserId(userEntity.getId()); } @@ -206,7 +209,7 @@ public class UserLoginServiceImpl extends ServiceImpl //返回用户信息 LoginResponse loginResponse = new LoginResponse(); - loginResponse.setAccount(userEntity.getAccount()); + loginResponse.setAccount(name); loginResponse.setToken(token); if(headImg != null) loginResponse.setHeadPortaritUrl(headImg); diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml index c6499ec2..958a9e0a 100644 --- a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml @@ -28,7 +28,7 @@ select id,account,phone_account,password,login_num from hrms_user where del_or_not = 0 and status = 0 - and phone_account = #{phone} + and (phone_account = #{phone} or account = #{phone}) and wechat_id = #{wechatId} @@ -63,4 +63,8 @@ SELECT COUNT(id) FROM hrms_user WHERE wechat_id = #{weChatId} + + \ No newline at end of file diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/LoginRequest.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/LoginRequest.java index af330c96..03a41c9b 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/LoginRequest.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/LoginRequest.java @@ -8,7 +8,7 @@ public class LoginRequest { private int id; - @ApiModelProperty(value = "手机号码") + @ApiModelProperty(value = "手机号码/账号") private String phone; @ApiModelProperty(value = "登录类型(1:手机号 2:微信登录)")