提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.service.member; |
H |
2 |
|
|
3 |
import cn.hutool.core.util.ClassUtil; |
|
4 |
import cn.hutool.core.util.ReflectUtil; |
|
5 |
import cn.hutool.extra.spring.SpringUtil; |
|
6 |
import org.springframework.beans.factory.annotation.Value; |
|
7 |
import org.springframework.stereotype.Service; |
|
8 |
|
|
9 |
/** |
|
10 |
* Member Service 实现类 |
|
11 |
* |
|
12 |
* @author iailab |
|
13 |
*/ |
|
14 |
@Service |
|
15 |
public class MemberServiceImpl implements MemberService { |
|
16 |
|
|
17 |
@Value("${iailab.info.base-package}") |
|
18 |
private String basePackage; |
|
19 |
|
|
20 |
private volatile Object memberUserApi; |
|
21 |
|
|
22 |
@Override |
|
23 |
public String getMemberUserMobile(Long id) { |
|
24 |
Object user = getMemberUser(id); |
|
25 |
if (user == null) { |
|
26 |
return null; |
|
27 |
} |
|
28 |
return ReflectUtil.invoke(user, "getMobile"); |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public String getMemberUserEmail(Long id) { |
|
33 |
Object user = getMemberUser(id); |
|
34 |
if (user == null) { |
|
35 |
return null; |
|
36 |
} |
|
37 |
return ReflectUtil.invoke(user, "getEmail"); |
|
38 |
} |
|
39 |
|
|
40 |
private Object getMemberUser(Long id) { |
|
41 |
if (id == null) { |
|
42 |
return null; |
|
43 |
} |
|
44 |
return ReflectUtil.invoke(getMemberUserApi(), "getUser", id); |
|
45 |
} |
|
46 |
|
|
47 |
private Object getMemberUserApi() { |
|
48 |
if (memberUserApi == null) { |
|
49 |
memberUserApi = SpringUtil.getBean(ClassUtil.loadClass(String.format("%s.module.member.api.user.MemberUserApi", basePackage))); |
|
50 |
} |
|
51 |
return memberUserApi; |
|
52 |
} |
|
53 |
|
|
54 |
} |