feat: 用户服务通用接口新增查询用户昵称接口

This commit is contained in:
konbai
2023-06-04 23:09:18 +08:00
parent c40c5f777a
commit d9a168f550
3 changed files with 21 additions and 0 deletions

View File

@@ -35,6 +35,11 @@ public interface CacheNames {
*/
String SYS_USER_NAME = "sys_user_name#30d";
/**
* 用户昵称
*/
String SYS_NICK_NAME = "sys_nick_name#30d";
/**
* 部门
*/

View File

@@ -15,4 +15,12 @@ public interface UserService {
*/
String selectUserNameById(Long userId);
/**
* 通过用户ID查询用户昵称
*
* @param userId 用户ID
* @return 用户昵称
*/
String selectNickNameById(Long userId);
}

View File

@@ -482,4 +482,12 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
return ObjectUtil.isNull(sysUser) ? null : sysUser.getUserName();
}
@Cacheable(cacheNames = CacheNames.SYS_NICK_NAME, key = "#userId")
@Override
public String selectNickNameById(Long userId) {
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getNickName).eq(SysUser::getUserId, userId));
return ObjectUtil.isNull(sysUser) ? null : sysUser.getNickName();
}
}