mirror of https://gitee.com/stylefeng/roses
【7.4.0】【user】更新用户格式化
parent
2bfa3feeda
commit
b862b650aa
|
@ -0,0 +1,45 @@
|
|||
package cn.stylefeng.roses.kernel.system.api.format;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 针对用户详情的渲染,增加对用户头像的支持
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/4/24 23:53
|
||||
*/
|
||||
public class UserAvatarFormatProcess extends UserFormatProcess {
|
||||
|
||||
protected Object execute(Object businessId) {
|
||||
|
||||
if (ObjectUtil.isEmpty(businessId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Long userId = Convert.toLong(businessId);
|
||||
UserServiceApi bean = SpringUtil.getBean(UserServiceApi.class);
|
||||
SysUserDTO userInfoByUserId = bean.getUserInfoByUserId(userId);
|
||||
if (userInfoByUserId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取用户姓名
|
||||
String realName = userInfoByUserId.getRealName();
|
||||
|
||||
// 获取用户头像
|
||||
String avatarUrl = userInfoByUserId.getAvatarUrl();
|
||||
|
||||
HashMap<String, Object> userInfo = new HashMap<>();
|
||||
userInfo.put("realName", realName);
|
||||
userInfo.put("avatarUrl", avatarUrl);
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ public class UserFormatProcess extends BaseSimpleFieldFormatProcess {
|
|||
/**
|
||||
* 未知人员的名称
|
||||
*/
|
||||
private static final String NOT_FIND_USER_NAME = "未知人员";
|
||||
public static final String NOT_FIND_USER_NAME = "未知人员";
|
||||
|
||||
@Override
|
||||
public Class<?> getItemClass() {
|
||||
|
@ -58,7 +58,7 @@ public class UserFormatProcess extends BaseSimpleFieldFormatProcess {
|
|||
* @author fengshuonan
|
||||
* @since 2022/11/10 1:29
|
||||
*/
|
||||
private Object execute(Object businessId) {
|
||||
protected Object execute(Object businessId) {
|
||||
Long userId = Convert.toLong(businessId);
|
||||
UserServiceApi bean = SpringUtil.getBean(UserServiceApi.class);
|
||||
SysUserDTO userInfoByUserId = bean.getUserInfoByUserId(userId);
|
||||
|
|
Loading…
Reference in New Issue