派生自 projectDept/qhighschool

胡仁荣
2022-10-31 fe7381d6e8ec1f427408de0297ac7f41533202f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
package com.qxueyou.scc.base.model;
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.qxueyou.scc.admin.classes.model.ClsClass;
import com.qxueyou.scc.org.model.OrgCollegeCourse;
import com.qxueyou.scc.org.model.Organization;
import com.qxueyou.scc.sys.model.SysMenu;
import com.qxueyou.scc.user.model.User;
 
/**
 * ±£´æÓû§»º´æÐÅÏ¢
 * @author µÂ»¢
 *
 */
public class UserInfoWrapper implements Serializable{
 
    private static final long serialVersionUID = 5715001537102570184L;
 
    private List<SysMenu> menus = new ArrayList<SysMenu>(10);
 
    private boolean admin = false;
 
    /** Óû§ÐÅÏ¢map */
    private final Map<String,Object> currentUser = new HashMap<String,Object>(10);
 
    /** "role":"½ÇÉ«", [STUDENT,CHARGER,TEACHER,SALESMAN,ADMIN] */
    public final static String INF_ROLE = "role";
 
    /** "roleId":sessionÖÐUserInfoWrapper±£´æµÄkey */
    public static final String SESSION_USER_INFO_KEY = "SESSION_USER_INFO_KEY";
 
    /**±£´æµ±Ç°ÔÚÏßÓû§IDÓësessionID*/
    public static final String REDIS_USER_ONLINE_MAP_KEY="redis.user.online.map.key";
 
    /** "roleId":½ÇÉ«ID */
    public final static String INF_ROLE_ID = "roleId";
 
    /** "roleIsAdmin":ÊÇ·ñΪ¹ÜÀíÔ± */
    public final static String INF_ROLE_IS_ADMIN = "roleIsAdmin";
 
    /** "roleValue":"½Çɫֵ" */
    public final static String INF_ROLE_VALUE = "roleValue";
 
    /** "roleValue":"½ÇÉ«" */
    public final static String INF_ROLE_ENAME = "roleEname";
 
    /** "userId":"Óû§ID" */
    public final static String INF_USER_ID = "userId";
 
    /** "userName":"Óû§Ãû" */
    public final static String INF_USER_NAME = "userName";
 
    /** "userNickName":"Óû§êdzÆ" */
    public final static String INF_USER_NICK_NAME = "userNickName";
 
    /** "userMobilePhone":"ÊÖ»úºÅ" */
    public final static String INF_USER_MOBILE_PHONE = "userMobilePhone";
 
    /** "userAccount":"ÕʺÅ" */
    public final static String INF_USER_ACCOUNT = "userAccount";
 
    /** "userHeadImg":"Í·Ïñ" */
    public final static String INF_USER_HEAD_IMG = "userHeadImg";
 
    /** "orgId":"»ú¹¹ID" */
    public final static String INF_ORG_ID = "orgId";
 
    /** "topOrgId":"×îÉϲã»ú¹¹ID" */
    public final static String INF_TOP_ORG_ID = "topOrgId";
 
    /** "orgName":"»ú¹¹Ãû³Æ" */
    public final static String INF_ORG_NAME = "orgName";
 
    /** "orgShortName":"»ú¹¹¼ò³Æ" */
    public final static String INF_ORG_SHORT_NAME = "orgShortName";
 
    /** "orgCode":"»ú¹¹´úÂë" */
    public final static String INF_ORG_CODE = "orgCode";
 
    /** "orgType":"»ú¹¹ÀàÐÍ" */
    public final static String INF_ORG_TYPE = "orgType";
 
    /** "orgLogPath":"»ú¹¹LOGO" */
    public final static String INF_ORG_LOGO_PATH = "orgLogPath";
 
    /** "courseId":"¿ÆÄ¿ID" */
    public final static String INF_COURSE_ID = "courseId";
 
    /** "courseCode":"¿ÆÄ¿´úÂë" */
    public final static String INF_COURSE_CODE = "courseCode";
 
    /** "courseName":"¿ÆÄ¿Ãû³Æ" */
    public final static String INF_COURSE_NAME = "courseName";
 
    /** "courseType":"¿ÆÄ¿ÀàÐÍ" */
    public final static String INF_COURSE_TYPE = "courseType";
 
    /** "classId":"°à¼¶ID" */
    public final static String INF_CLASS_ID = "classId";
 
    /** "className":"°à¼¶Ãû" */
    public final static String INF_CLASS_NAME = "className";
 
    /** "classCharger":"°àÖ÷ÈÎ" */
    public final static String INF_CLASS_CHARGER = "classCharger";
 
    /** "teacher":"½²Ê¦" */
    public final static String ROLE_TEACHER = "teacher";
 
    /** "assistantTeacher":"ÖúÀí½²Ê¦" */
    public final static String ROLE_ASSISTANT_TEACHER = "assistantTeacher";
 
    /** "salesman":"ÏúÊÛ" */
    public final static String ROLE_SALESMAN = "salesman";
 
    /** "role":"½ÇÉ«", [STUDENT,CHARGER,TEACHER,SALESMAN,ADMIN] */
    public final static String ROLE_CHARGER = "charger";
 
    /** "role":"½ÇÉ«", [STUDENT,CHARGER,TEACHER,SALESMAN,ADMIN] */
    public final static String ROLE_ADMIN = "admin";
 
    /** "role":"½ÇÉ«", [STUDENT,CHARGER,TEACHER,SALESMAN,ADMIN] */
    public final static String ROLE_STUDENT = "student";
 
    /** "role":"½ÇÉ«", [STUDENT,CHARGER,TEACHER,SALESMAN,ADMIN] */
    public final static String ROLE_CUSTOM = "custom";
 
    /** "buttonPrivilege":"" */
    public final static String INF_BUTTON_PRIVILEGE_EDIT = "buttonPrivilege";
 
    /** "loginIp":"µÇ¼IP" */
    public final static String INF_LOGIN_IP = "loginIp";
 
    /** "loginPlatForm":"µÇ¼ƽ̨" */
    public final static String INF_LOGIN_PLAT_FORM = "loginPlatForm";
 
    /** "loginCacheIpFlag":"ÊÇ·ñÐèÒªÔÚ¹ýÂËÆ÷¶Ôµ±Ç°Óû§Ôö¼Ó»º´æ£¨ÓÃÓÚ±£Ö¤Ò»¸öÓû§Ö»ÄÜÔÚÒ»¸öIPÉϵǼ£©" */
    public final static String INF_LOGIN_CACHE_IP_FLAG = "loginCacheIpFlag";
 
    /** "rolesKey":"",  */
    String[] rolesKey = new String[]{"admins","chargers","teachers","salesmen","students","customs","assistantTeachers"};
 
    /** "roles":"" */
    private final Map<String,List<Map<String,Object>>> roles = new HashMap<String,List<Map<String,Object>>>(5);
 
    /**
     * ¸ù¾ÝkeyÖµ»ñÈ¡µ±Ç°Óû§ÐÅÏ¢
     * @param key
     * @return
     */
    public String getInfo(String key){
        return (String)(currentUser.get(key));
    }
 
    /**
     * »ñÈ¡µ±Ç°Óû§½ÇÉ«
     * @param key
     * @return
     */
    public String getCurrentRole(){
        return getInfo(INF_ROLE);
    }
 
    /**
     * »ñÈ¡µ±Ç°Óû§½ÇÉ«ID
     * @param key
     * @return
     */
    public String getCurrentRoleId(){
        return getInfo(INF_ROLE_ID);
    }
 
    /**
     * »ñÈ¡µ±Ç°Óû§½Çɫֵ
     * @param key
     * @return
     */
    public String getCurrentRoleValue(){
        return getInfo(INF_ROLE_VALUE);
    }
 
    /**
     * ¸ù¾ÝkeyÖµÉèÖõ±Ç°Óû§ÐÅÏ¢
     * @param key
     * @return
     */
    public void setInfo(String key,Object value){
        currentUser.put(key,value);
    }
 
    /**
     * ÉèÖÃÓû§ÐÅÏ¢
     * @param key
     * @return
     */
    public void setUser(User user){
        currentUser.put(INF_USER_ID, user.getUserId());
        currentUser.put(INF_USER_NAME, user.getName());
        currentUser.put(INF_USER_NICK_NAME, user.getName());
        currentUser.put(INF_USER_MOBILE_PHONE, user.getMobilePhone());
        currentUser.put("email", user.getEmail());
        currentUser.put("imei", user.getImei());
        currentUser.put("age", String.valueOf(user.getAge()));
        currentUser.put(INF_USER_HEAD_IMG, user.getImgPath());
    }
 
    /**
     * ÉèÖûú¹¹ÐÅÏ¢
     * @param key
     * @return
     */
    public void setOrg(Organization org){
 
        if(org==null){
            currentUser.put(INF_ORG_ID, null);
            currentUser.put(INF_TOP_ORG_ID, null);
            currentUser.put(INF_ORG_NAME, null);
            currentUser.put(INF_ORG_CODE, null);
            currentUser.put(INF_ORG_LOGO_PATH, null);
            currentUser.put(INF_ORG_SHORT_NAME, null);
            return;
        }
 
        currentUser.put(INF_ORG_ID, org.getOrganizationId());
        currentUser.put(INF_TOP_ORG_ID, org.getTopOrganizationId());
        currentUser.put(INF_ORG_NAME, org.getName());
        currentUser.put(INF_ORG_SHORT_NAME, org.getShortName());
        currentUser.put(INF_ORG_CODE, org.getCode());
        currentUser.put(INF_ORG_LOGO_PATH, org.getLogoPath());
    }
 
    /**
     * ÉèÖð༶ÐÅÏ¢
     * @param key
     * @return
     */
    public void setClass(ClsClass cls){
        if(cls==null){
            currentUser.put(INF_CLASS_ID, null);
            currentUser.put(INF_CLASS_NAME, null);
            currentUser.put(INF_CLASS_CHARGER, null);
            return;
        }
 
        currentUser.put(INF_CLASS_ID, cls.getClassId());
        currentUser.put(INF_CLASS_NAME, cls.getName());
        currentUser.put(INF_CLASS_CHARGER, cls.getClassCharger());
        System.out.println(cls.getClassId());
    }
 
    /**
     * ÉèÖÿÆÄ¿ÐÅÏ¢
     * @param key
     * @return
     */
    public void setCource(OrgCollegeCourse cource){
 
        if(cource==null){
            currentUser.put(INF_COURSE_ID, null);
            currentUser.put(INF_COURSE_CODE, null);
            currentUser.put(INF_COURSE_NAME, null);
            return;
        }
 
        //currentUser.put(INF_COURSE_ID, cource.getCourseId());
        currentUser.put(INF_COURSE_ID, cource.getCollegeCourseId());
        currentUser.put(INF_COURSE_CODE, cource.getCode());
        currentUser.put(INF_COURSE_NAME, cource.getName());
 
    }
 
    /**
     * ÉèÖõ±Ç°¿Í»§ÊÇ·ñ±à¼­¹ý½ÇÉ«µÄ°´Å¥È¨ÏÞÐÅÏ¢
     * @param key
     * @return
     */
    public void setButtonPrivilegeEdit(Boolean flag){
 
        if(flag==null){
            currentUser.put(INF_BUTTON_PRIVILEGE_EDIT, false);
            return;
        }
 
        currentUser.put(INF_BUTTON_PRIVILEGE_EDIT, flag);
 
    }
 
    /**
     * »ñÈ¡µ±Ç°Óû§½ÇÉ«ÊÇ·ñ´¦Àí¹ý°´Å¥È¨ÏÞ
     * @param key
     * @return
     */
    public Boolean getButtonPrivilegeEdit(){
        return (Boolean)(currentUser.get(INF_BUTTON_PRIVILEGE_EDIT));
    }
 
    /**
     * ÉèÖÃÓû§µÇ¼IPÐÅÏ¢
     * @param cacheIpFlag ÊÇ·ñÐèÒª»º´æ
     * @param ip
     */
    public void setLoginInfo(boolean cacheIpFlag,String ip, String platForm){
        currentUser.put(INF_LOGIN_CACHE_IP_FLAG, cacheIpFlag);
        currentUser.put(INF_LOGIN_IP, ip);
        currentUser.put(INF_LOGIN_PLAT_FORM, platForm);
    }
 
    /**
     * »ñÈ¡µ±Ç°Óû§µÇ¼IP
     * @param key
     * @return
     */
    public String getCurrentLoginIp(){
        return (String)(currentUser.get(INF_LOGIN_IP));
    }
 
    /**
     * »ñÈ¡µ±Ç°Óû§ÊÇ·ñÐèÒª»º´æ
     * @param key
     * @return
     */
    public Boolean getCurrentLoginCacheIpFlag(){
        return (Boolean)(currentUser.get(INF_LOGIN_CACHE_IP_FLAG));
    }
 
    /**
     * »ñÈ¡µ±Ç°µÇ¼ƽ̨
     * @param key
     * @return
     */
    public String getCurrentLoginPlatForm(){
        return (String)(currentUser.get(INF_LOGIN_PLAT_FORM));
    }
 
    /**
     * Ìí¼Ó½ÇÉ«
     * @param key
     * @param value
     * @return
     */
    public void addRole(String key,List<Map<String,Object>> value){
        roles.put(key, value);
    }
 
    /**
     * »ñÈ¡×î¸ßÓÅÏȼ¶½ÇÉ«
     * @return
     */
    public List<Map<String,Object>> getDefaultRole(){
 
        for(String role:rolesKey){
            if(roles.containsKey(role)){
                return roles.get(role);
            }
        }
 
        return null;
 
    }
 
    /**
     * »ñȡָ¶¨½ÇÉ«µÄÐÅÏ¢
     * @return
     */
    public List<Map<String,Object>> getRoleInfo(String roleKey){
 
        for(String role:rolesKey){
            if(role.equals(roleKey)){
                return roles.get(role);
            }
        }
 
        return null;
 
    }
 
    /**
     * »ñÈ¡×î¸ßÓÅÏȼ¶½ÇÉ«Ãû×Ö
     * @return
     */
    public String getDefaultRoleName(){
 
        for(String role:rolesKey){
            if(roles.containsKey(role)){
                return role;
            }
        }
 
        return null;
 
    }
 
    /**
     * »ñÈ¡ËùÓв˵¥
     * @return
     */
    public List<SysMenu> getMenus() {
        return menus;
    }
 
    /**
     * ÉèÖÃËùÓв˵¥
     * @return
     */
    public void setMenus(List<SysMenu> menus) {
        this.menus = menus;
    }
 
    public boolean isAdmin() {
        return admin;
    }
 
    public void setAdmin(boolean admin) {
        this.admin = admin;
    }
}