cl
2024-01-22 8de0bed14d364e3d3adae6b6e2260b838d180c23
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.oauth2.service.impl;
2
3 import cn.stylefeng.guns.base.oauth2.service.OauthUserInfoService;
4 import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
5 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
6 import cn.stylefeng.guns.base.oauth2.entity.OauthUserInfo;
7 import cn.stylefeng.guns.oauth2.mapper.OauthUserInfoMapper;
8 import cn.stylefeng.guns.base.oauth2.model.params.OauthUserInfoParam;
9 import cn.stylefeng.guns.base.oauth2.model.result.OauthUserInfoResult;
10 import cn.stylefeng.roses.core.util.ToolUtil;
11 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
12 import com.baomidou.mybatisplus.core.metadata.IPage;
13 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
14 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
15 import org.springframework.stereotype.Service;
16
17 import java.io.Serializable;
18 import java.util.List;
19
20 /**
21  * <p>
22  * 第三方用户信息表 服务实现类
23  * </p>
24  *
25  * @author stylefeng
26  * @since 2019-06-09
27  */
28 @Service
29 public class OauthUserInfoServiceImpl extends ServiceImpl<OauthUserInfoMapper, OauthUserInfo> implements OauthUserInfoService {
30
31     @Override
32     public void add(OauthUserInfoParam param) {
33         OauthUserInfo entity = getEntity(param);
34         this.save(entity);
35     }
36
37     @Override
38     public void delete(OauthUserInfoParam param) {
39         this.removeById(getKey(param));
40     }
41
42     @Override
43     public void update(OauthUserInfoParam param) {
44         OauthUserInfo oldEntity = getOldEntity(param);
45         OauthUserInfo newEntity = getEntity(param);
46         ToolUtil.copyProperties(newEntity, oldEntity);
47         this.updateById(newEntity);
48     }
49
50     @Override
51     public OauthUserInfoResult findBySpec(OauthUserInfoParam param) {
52         return null;
53     }
54
55     @Override
56     public List<OauthUserInfoResult> findListBySpec(OauthUserInfoParam param) {
57         return null;
58     }
59
60     @Override
61     public LayuiPageInfo findPageBySpec(OauthUserInfoParam param) {
62         Page pageContext = getPageContext();
63         IPage page = this.baseMapper.customPageList(pageContext, param);
64         return LayuiPageFactory.createPageInfo(page);
65     }
66
67     @Override
68     public String getAvatarUrl(Long userId) {
69         OauthUserInfo oauthUserInfo = this.getOne(new QueryWrapper<OauthUserInfo>().eq("user_id", userId));
70         return oauthUserInfo.getAvatar();
71     }
72
73     private Serializable getKey(OauthUserInfoParam param) {
74         return param.getOauthId();
75     }
76
77     private Page getPageContext() {
78         return LayuiPageFactory.defaultPage();
79     }
80
81     private OauthUserInfo getOldEntity(OauthUserInfoParam param) {
82         return this.getById(getKey(param));
83     }
84
85     private OauthUserInfo getEntity(OauthUserInfoParam param) {
86         OauthUserInfo entity = new OauthUserInfo();
87         ToolUtil.copyProperties(param, entity);
88         return entity;
89     }
90
91 }