inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 /*
I 2 Copyright [2020] [https://www.xiaonuo.vip]
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
17
18 1.请不要删除和修改根目录下的LICENSE文件。
19 2.请不要删除和修改Snowy源码头部的版权声明。
20 3.请保留源码和相关描述文件的项目出处,作者声明等。
21 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy
22 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy
23 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
24  */
25 package vip.xiaonuo.core.pojo.login;
26
27 import cn.hutool.core.collection.CollectionUtil;
28 import cn.hutool.core.lang.Dict;
29 import cn.hutool.core.util.ObjectUtil;
30 import lombok.Data;
31 import org.springframework.security.core.GrantedAuthority;
32 import org.springframework.security.core.userdetails.UserDetails;
33 import vip.xiaonuo.core.consts.CommonConstant;
34 import vip.xiaonuo.core.pojo.node.LoginMenuTreeNode;
35
36 import java.io.Serializable;
37 import java.util.ArrayList;
38 import java.util.Collection;
39 import java.util.Date;
40 import java.util.List;
41
42 /**
43  * 登录用户模型
44  *
45  * @author xuyuxiang
46  * @date 2020/3/11 12:21
47  */
48 @Data
49 public class SysLoginUser implements UserDetails, Serializable {
50
51     private static final long serialVersionUID = 1L;
52
53     /**
54      * 主键
55      */
56     private Long id;
57
58     /**
59      * 账号
60      */
61     private String account;
62
63     /**
64      * 昵称
65      */
66     private String nickName;
67
68     /**
69      * 姓名
70      */
71     private String name;
72
73     /**
74      * 头像
75      */
76     private String avatar;
77
78     /**
79      * 生日
80      */
81     private Date birthday;
82
83     /**
84      * 性别(字典 1男 2女)
85      */
86     private Integer sex;
87
88     /**
89      * 邮箱
90      */
91     private String email;
92
93     /**
94      * 手机
95      */
96     private String phone;
97
98     /**
99      * 电话
100      */
101     private String tel;
102
103     /**
104      * 管理员类型(0超级管理员 1非管理员)
105      */
106     private Integer adminType;
107
108     /**
109      * 最后登陆IP
110      */
111     private String lastLoginIp;
112
113     /**
114      * 最后登陆时间
115      */
116     private String lastLoginTime;
117
118     /**
119      * 最后登陆地址
120      */
121     private String lastLoginAddress;
122
123     /**
124      * 最后登陆所用浏览器
125      */
126     private String lastLoginBrowser;
127
128     /**
129      * 最后登陆所用系统
130      */
131     private String lastLoginOs;
132
133     /**
134      * 员工信息
135      */
136     private LoginEmpInfo loginEmpInfo;
137
138     /**
139      * 具备应用信息
140      */
141     private List<Dict> apps;
142
143     /**
144      * 角色信息
145      */
146     private List<Dict> roles;
147
148     /**
149      * 权限信息
150      */
151     private List<String> permissions;
152
153     /**
154      * 登录菜单信息,AntDesign版本菜单
155      */
156     private List<LoginMenuTreeNode> menus;
157
158     /**
159      * 数据范围信息
160      */
161     private List<Long> dataScopes;
162
163     /**
164      * 租户信息
165      */
166     private Dict tenants;
167
168     /**
169      * 角色名称集合
170      */
171     @Override
172     public Collection<? extends GrantedAuthority> getAuthorities() {
173         ArrayList<SnowyAuthority> grantedAuthorities = CollectionUtil.newArrayList();
174         if (ObjectUtil.isNotEmpty(roles)) {
175             roles.forEach(dict -> {
176                 String roleName = dict.getStr(CommonConstant.NAME);
177                 SnowyAuthority snowyAuthority = new SnowyAuthority(roleName);
178                 grantedAuthorities.add(snowyAuthority);
179             });
180         }
181         return grantedAuthorities;
182     }
183
184     @Override
185     public String getPassword() {
186         return null;
187     }
188
189     @Override
190     public String getUsername() {
191         return this.account;
192     }
193
194     @Override
195     public boolean isAccountNonExpired() {
196         //能生成loginUser就是jwt解析成功,没锁定
197         return true;
198     }
199
200     @Override
201     public boolean isAccountNonLocked() {
202         //能生成loginUser就是jwt解析成功,没锁定
203         return true;
204     }
205
206     @Override
207     public boolean isCredentialsNonExpired() {
208         //能生成loginUser就是jwt解析成功,没锁定
209         return true;
210     }
211
212     @Override
213     public boolean isEnabled() {
214         //能生成loginUser就是jwt解析成功,没锁定
215         return true;
216     }
217 }