用户登录后处理头像到前台
This commit is contained in:
@@ -61,6 +61,11 @@
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -190,6 +190,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
||||
map.put(SecurityConstants.USER_NICKNAME_KEY, user.getNickName());
|
||||
map.put(SecurityConstants.CLIENT_ID_KEY, clientId);
|
||||
map.put(SecurityConstants.DEPT_INDEX_KEY, user.getDeptIndex());
|
||||
map.put(SecurityConstants.USER_HEAD_KEY, user.getHeadSculpture());
|
||||
if (StrUtil.isNotBlank(user.getAuthenticationMethod())) {
|
||||
map.put(SecurityConstants.AUTHENTICATION_METHOD, user.getAuthenticationMethod());
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public class BusinessUser implements UserDetails {
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String headSculpture;
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.njcn.auth.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.auth.pojo.bo.BusinessUser;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.dto.UserDTO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
@@ -29,6 +31,8 @@ public class UserDetailsServiceImpl implements CustomUserDetailsService {
|
||||
|
||||
private final UserFeignClient userFeignClient;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String loginName) throws UsernameNotFoundException {
|
||||
@@ -40,10 +44,13 @@ public class UserDetailsServiceImpl implements CustomUserDetailsService {
|
||||
//成功获取用户信息
|
||||
UserDTO userDTO = result.getData();
|
||||
BeanUtil.copyProperties(userDTO, businessUser, true);
|
||||
//处理头像
|
||||
dealHead(businessUser);
|
||||
businessUser.setAuthorities(AuthorityUtils.commaSeparatedStringToAuthorityList(String.join(",", userDTO.getRoleName())));
|
||||
return businessUser;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByPhone(String phone) throws UsernameNotFoundException {
|
||||
String clientId = RequestUtil.getOAuth2ClientId();
|
||||
@@ -54,8 +61,18 @@ public class UserDetailsServiceImpl implements CustomUserDetailsService {
|
||||
//成功获取用户信息
|
||||
UserDTO userDTO = result.getData();
|
||||
BeanUtil.copyProperties(userDTO, businessUser, true);
|
||||
dealHead(businessUser);
|
||||
businessUser.setAuthorities(AuthorityUtils.commaSeparatedStringToAuthorityList(String.join(",", userDTO.getRoleName())));
|
||||
return businessUser;
|
||||
}
|
||||
|
||||
/***
|
||||
*处理用户头像,如果存在头像地址,则去minioss获取url
|
||||
*/
|
||||
private void dealHead(BusinessUser businessUser) {
|
||||
if(StrUtil.isNotBlank(businessUser.getHeadSculpture())){
|
||||
businessUser.setHeadSculpture(fileStorageUtil.getFileUrl(businessUser.getHeadSculpture()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public interface SecurityConstants {
|
||||
String USER_INDEX_KEY = "userIndex";
|
||||
String USER_TYPE = "userType";
|
||||
String USER_NAME_KEY = "user_name";
|
||||
String USER_HEAD_KEY = "headSculpture";
|
||||
String USER_NICKNAME_KEY = "nickname";
|
||||
String CLIENT_ID_KEY = "client_id";
|
||||
String DEPT_INDEX_KEY = "deptIndex";
|
||||
|
||||
@@ -43,5 +43,6 @@ public class UserDTO {
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String headSculpture;
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
}
|
||||
List<String> roleNames = roleService.getRoleNameByUserId(user.getId());
|
||||
UserSet userSet = userSetService.lambdaQuery().eq(UserSet::getUserId, user.getId()).one();
|
||||
return new UserDTO(user.getId(), user.getLoginName(), user.getName(), user.getPassword(), roleNames, userSet.getSecretKey(), userSet.getStandBy(), user.getDeptId(), user.getType());
|
||||
return new UserDTO(user.getId(), user.getLoginName(), user.getName(), user.getPassword(), roleNames, userSet.getSecretKey(), userSet.getStandBy(), user.getDeptId(), user.getType(),user.getHeadSculpture());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +111,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
}
|
||||
List<String> roleNames = roleService.getRoleNameByUserId(user.getId());
|
||||
UserSet userSet = userSetService.lambdaQuery().eq(UserSet::getUserId, user.getId()).one();
|
||||
return new UserDTO(user.getId(), user.getLoginName(), user.getName(), user.getPassword(), roleNames, userSet.getSecretKey(), userSet.getStandBy(), user.getDeptId(), user.getType());
|
||||
return new UserDTO(user.getId(), user.getLoginName(), user.getName(), user.getPassword(), roleNames, userSet.getSecretKey(), userSet.getStandBy(), user.getDeptId(), user.getType(),user.getHeadSculpture());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,10 +78,3 @@ mybatis-plus:
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
#oss服务器配置
|
||||
#min:
|
||||
# io:
|
||||
# endpoint: http://192.168.1.13:9009
|
||||
# accessKey: minio
|
||||
# secretKey: minio@123
|
||||
# bucket: excelreport
|
||||
|
||||
Reference in New Issue
Block a user