提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.framework.operatelog.core; |
H |
2 |
|
|
3 |
import cn.hutool.core.convert.Convert; |
|
4 |
import cn.hutool.core.util.StrUtil; |
|
5 |
import com.iailab.module.system.dal.dataobject.user.AdminUserDO; |
|
6 |
import com.iailab.module.system.service.user.AdminUserService; |
|
7 |
import com.mzt.logapi.service.IParseFunction; |
|
8 |
import lombok.extern.slf4j.Slf4j; |
|
9 |
import org.springframework.stereotype.Component; |
|
10 |
|
|
11 |
import javax.annotation.Resource; |
|
12 |
|
|
13 |
/** |
|
14 |
* 管理员名字的 {@link IParseFunction} 实现类 |
|
15 |
* |
|
16 |
* @author HUIHUI |
|
17 |
*/ |
|
18 |
@Slf4j |
|
19 |
@Component |
|
20 |
public class AdminUserParseFunction implements IParseFunction { |
|
21 |
|
|
22 |
public static final String NAME = "getAdminUserById"; |
|
23 |
|
|
24 |
@Resource |
|
25 |
private AdminUserService adminUserService; |
|
26 |
|
|
27 |
@Override |
|
28 |
public String functionName() { |
|
29 |
return NAME; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public String apply(Object value) { |
|
34 |
if (StrUtil.isEmptyIfStr(value)) { |
|
35 |
return ""; |
|
36 |
} |
|
37 |
|
|
38 |
// 获取用户信息 |
|
39 |
AdminUserDO user = adminUserService.getUser(Convert.toLong(value)); |
|
40 |
if (user == null) { |
|
41 |
log.warn("[apply][获取用户{{}}为空", value); |
|
42 |
return ""; |
|
43 |
} |
|
44 |
// 返回格式 iailab(13888888888) |
|
45 |
String nickname = user.getNickname(); |
|
46 |
if (StrUtil.isEmpty(user.getMobile())) { |
|
47 |
return nickname; |
|
48 |
} |
|
49 |
return StrUtil.format("{}({})", nickname, user.getMobile()); |
|
50 |
} |
|
51 |
|
|
52 |
} |