inleft
2022-02-21 cfde488bdd0163986087c880e0a2762645f8c14c
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.context.login;
26
27 import vip.xiaonuo.core.pojo.login.SysLoginUser;
28
29 import java.util.List;
30
31 /**
32  * 登录用户上下文
33  *
34  * @author xuyuxiang
35  * @date 2020/3/13 12:16
36  */
37 public interface LoginContext {
38
39     /**
40      * 获取当前登录用户
41      *
42      * @return 当前登录用户信息
43      * @author xuyuxiang
44      * @date 2020/3/13 14:40
45      */
46     SysLoginUser getSysLoginUser();
47
48     /**
49      * 获取当前登录用户,如未登录,则返回null,不抛异常
50      *
51      * @return 当前登录用户信息
52      * @author xuyuxiang
53      * @date 2020/3/13 14:40
54      */
55     SysLoginUser getSysLoginUserWithoutException();
56
57     /**
58      * 获取当前登录用户的id
59      *
60      * @return 当前登录用户的id
61      * @author xuyuxiang
62      * @date 2020/3/18 19:25
63      */
64     Long getSysLoginUserId();
65
66     /**
67      * 判断用户是否登录
68      *
69      * @return 是否登录,true是,false否
70      * @author xuyuxiang
71      * @date 2020/3/18 19:22
72      */
73     boolean hasLogin();
74
75     /**
76      * 获取当前登录用户的账户
77      *
78      * @return 当前登陆用户的账户account
79      * @author xuyuxiang
80      * @date 2020/3/19 20:37
81      */
82     String getSysLoginUserAccount();
83
84     /**
85      * 判断当前登录用户是否有某资源的访问权限
86      *
87      * @param requestUri 请求的url
88      * @return 是否有访问权限,true是,false否
89      * @author xuyuxiang
90      * @date 2020/3/23 8:48
91      */
92     boolean hasPermission(String requestUri);
93
94     /**
95      * 判断当前登录用户是否包含某个角色
96      *
97      * @param roleCode 角色编码
98      * @return 是否包含该角色,true是,false否
99      * @author xuyuxiang
100      * @date 2020/3/23 8:53
101      */
102     boolean hasRole(String roleCode);
103
104     /**
105      * 判断当前登录用户是否包含任意一个角色
106      *
107      * @param roleCodes 角色集合,逗号拼接
108      * @return 是否包含任一角色,true是,false否
109      * @author xuyuxiang
110      * @date 2020/3/23 8:54
111      */
112     boolean hasAnyRole(String roleCodes);
113
114     /**
115      * 判断当前登录用户是否是超级管理员
116      *
117      * @return 当前登录用户是否是超级管理员
118      * @author xuyuxiang
119      * @date 2020/3/23 17:50
120      */
121     boolean isSuperAdmin();
122
123     /**
124      * 判断当前登录用户是否包含所有角色
125      *
126      * @param roleCodes 角色集合,逗号拼接
127      * @return 是否包含所有角色,true是,false否
128      * @author xuyuxiang
129      * @date 2020/4/5 10:28
130      */
131     boolean hasAllRole(String roleCodes);
132
133     /**
134      * 获取当前登录用户的数据范围集合(组织机构id集合)
135      *
136      * @return 数据范围集合(组织机构id集合)
137      * @author xuyuxiang
138      * @date 2020/4/5 17:20
139      */
140     List<Long> getLoginUserDataScopeIdList();
141
142     /**
143      * 获取当前登录用户的组织机构id
144      *
145      * @return 当前登录用户的组织机构id
146      * @author xuyuxiang
147      * @date 2020/4/5 18:31
148      */
149     Long getSysLoginUserOrgId();
150
151     /**
152      * 获取当前登录用户的角色id集合
153      *
154      * @return 当前登录用户角色id集合
155      * @author xuyuxiang
156      * @date 2020/4/20 16:04
157      */
158     List<String> getLoginUserRoleIds();
159
160     /**
161      * 获取最新的用户信息,用于修改之后前端获取
162      *
163      * @return 最新的用户信息
164      * @author xuyuxiang
165      * @date 2020/9/20 15:18
166      **/
167     SysLoginUser getSysLoginUserUpToDate();
168 }