ad5081d3
孙向锦
初始化项目
|
1
2
3
|
package com.fh.controller.system.login;
import java.util.ArrayList;
|
9f161055
孙向锦
修改高斯客户反馈
|
4
|
import java.util.Date;
|
ad5081d3
孙向锦
初始化项目
|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.fh.controller.base.BaseController;
|
9f161055
孙向锦
修改高斯客户反馈
|
25
26
27
|
import com.fh.entity.system.Menu;
import com.fh.entity.system.Role;
import com.fh.entity.system.User;
|
338594c8
孙向锦
添加教师端页面
|
28
|
import com.fh.service.api.V1Manager;
|
ad5081d3
孙向锦
初始化项目
|
29
|
import com.fh.service.fhoa.datajur.DatajurManager;
|
9f161055
孙向锦
修改高斯客户反馈
|
30
|
import com.fh.service.sunvote.event.EventManager;
|
83b5ddeb
孙向锦
模板添加
|
31
|
import com.fh.service.sunvote.pagetemplate.PageTemplateManager;
|
338594c8
孙向锦
添加教师端页面
|
32
|
import com.fh.service.sunvote.school.SchoolManager;
|
6b3a5ad0
孙向锦
添加管理员界面
|
33
34
|
import com.fh.service.sunvote.schooladmin.SchoolAdminManager;
import com.fh.service.sunvote.sclass.SClassManager;
|
338594c8
孙向锦
添加教师端页面
|
35
|
import com.fh.service.sunvote.teacher.TeacherManager;
|
ad5081d3
孙向锦
初始化项目
|
36
37
38
39
40
41
|
import com.fh.service.system.appuser.AppuserManager;
import com.fh.service.system.buttonrights.ButtonrightsManager;
import com.fh.service.system.fhbutton.FhbuttonManager;
import com.fh.service.system.fhlog.FHlogManager;
import com.fh.service.system.loginimg.LogInImgManager;
import com.fh.service.system.menu.MenuManager;
|
ad5081d3
孙向锦
初始化项目
|
42
43
44
45
46
47
48
49
50
|
import com.fh.service.system.role.RoleManager;
import com.fh.service.system.user.UserManager;
import com.fh.util.AppUtil;
import com.fh.util.Const;
import com.fh.util.DateUtil;
import com.fh.util.Jurisdiction;
import com.fh.util.PageData;
import com.fh.util.RightsHelper;
import com.fh.util.Tools;
|
bed6e1fc
孙向锦
添加其他功能
|
51
|
|
ad5081d3
孙向锦
初始化项目
|
52
53
|
/**
* 总入口
|
ad5081d3
孙向锦
初始化项目
|
54
55
56
|
* 修改日期:2015/11/2
*/
/**
|
ad5081d3
孙向锦
初始化项目
|
57
58
59
60
61
|
*
*/
@Controller
public class LoginController extends BaseController {
|
bed6e1fc
孙向锦
添加其他功能
|
62
|
@Resource(name = "userService")
|
ad5081d3
孙向锦
初始化项目
|
63
|
private UserManager userService;
|
bed6e1fc
孙向锦
添加其他功能
|
64
|
@Resource(name = "menuService")
|
ad5081d3
孙向锦
初始化项目
|
65
|
private MenuManager menuService;
|
bed6e1fc
孙向锦
添加其他功能
|
66
|
@Resource(name = "roleService")
|
ad5081d3
孙向锦
初始化项目
|
67
|
private RoleManager roleService;
|
bed6e1fc
孙向锦
添加其他功能
|
68
|
@Resource(name = "buttonrightsService")
|
ad5081d3
孙向锦
初始化项目
|
69
|
private ButtonrightsManager buttonrightsService;
|
bed6e1fc
孙向锦
添加其他功能
|
70
|
@Resource(name = "fhbuttonService")
|
ad5081d3
孙向锦
初始化项目
|
71
|
private FhbuttonManager fhbuttonService;
|
bed6e1fc
孙向锦
添加其他功能
|
72
|
@Resource(name = "appuserService")
|
ad5081d3
孙向锦
初始化项目
|
73
|
private AppuserManager appuserService;
|
bed6e1fc
孙向锦
添加其他功能
|
74
|
@Resource(name = "datajurService")
|
ad5081d3
孙向锦
初始化项目
|
75
|
private DatajurManager datajurService;
|
bed6e1fc
孙向锦
添加其他功能
|
76
|
@Resource(name = "fhlogService")
|
ad5081d3
孙向锦
初始化项目
|
77
|
private FHlogManager FHLOG;
|
bed6e1fc
孙向锦
添加其他功能
|
78
|
@Resource(name = "loginimgService")
|
ad5081d3
孙向锦
初始化项目
|
79
|
private LogInImgManager loginimgService;
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
80
|
@Resource(name = "teacherService")
|
338594c8
孙向锦
添加教师端页面
|
81
|
private TeacherManager teacherService;
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
82
|
@Resource(name = "schoolService")
|
338594c8
孙向锦
添加教师端页面
|
83
|
private SchoolManager schoolService;
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
84
|
|
338594c8
孙向锦
添加教师端页面
|
85
|
@Resource(name = "v1Service")
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
86
|
private V1Manager v1Service;
|
6b3a5ad0
孙向锦
添加管理员界面
|
87
88
89
|
@Resource(name="schooladminService")
private SchoolAdminManager schooladminService;
|
bed6e1fc
孙向锦
添加其他功能
|
90
|
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
91
|
@Resource(name = "eventService")
|
9f161055
孙向锦
修改高斯客户反馈
|
92
|
private EventManager eventService;
|
6b3a5ad0
孙向锦
添加管理员界面
|
93
94
95
96
|
@Resource(name="sclassService")
private SClassManager sclassService;
|
83b5ddeb
孙向锦
模板添加
|
97
98
99
|
@Resource(name="pagetemplateService")
private PageTemplateManager pagetemplateService;
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
100
|
|
bed6e1fc
孙向锦
添加其他功能
|
101
102
103
|
/**
* 访问登录页
*
|
ad5081d3
孙向锦
初始化项目
|
104
105
106
|
* @return
* @throws Exception
*/
|
bed6e1fc
孙向锦
添加其他功能
|
107
108
|
@RequestMapping(value = "/login_toLogin")
public ModelAndView toLogin() throws Exception {
|
ad5081d3
孙向锦
初始化项目
|
109
110
111
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
bed6e1fc
孙向锦
添加其他功能
|
112
|
pd = this.setLoginPd(pd); // 设置登录页面的配置参数
|
ad5081d3
孙向锦
初始化项目
|
113
|
mv.setViewName("system/index/login");
|
bed6e1fc
孙向锦
添加其他功能
|
114
|
mv.addObject("pd", pd);
|
ad5081d3
孙向锦
初始化项目
|
115
116
|
return mv;
}
|
bed6e1fc
孙向锦
添加其他功能
|
117
118
119
120
|
/**
* 请求登录,验证用户
*
|
ad5081d3
孙向锦
初始化项目
|
121
122
123
|
* @return
* @throws Exception
*/
|
bed6e1fc
孙向锦
添加其他功能
|
124
|
@RequestMapping(value = "/login_login", produces = "application/json;charset=UTF-8")
|
ad5081d3
孙向锦
初始化项目
|
125
|
@ResponseBody
|
bed6e1fc
孙向锦
添加其他功能
|
126
127
|
public Object login() throws Exception {
Map<String, String> map = new HashMap<String, String>();
|
ad5081d3
孙向锦
初始化项目
|
128
129
130
|
PageData pd = new PageData();
pd = this.getPageData();
String errInfo = "";
|
81df8ce6
孙向锦
去掉多余的信息
|
131
|
String KEYDATA[] = pd.getString("KEYDATA").split(";;;");
|
bed6e1fc
孙向锦
添加其他功能
|
132
|
if (null != KEYDATA && KEYDATA.length >= 2) {
|
ad5081d3
孙向锦
初始化项目
|
133
|
Session session = Jurisdiction.getSession();
|
bed6e1fc
孙向锦
添加其他功能
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
String sessionCode = (String) session
.getAttribute(Const.SESSION_SECURITY_CODE); // 获取session中的验证码
String USERNAME = KEYDATA[0]; // 登录过来的用户名
String PASSWORD = KEYDATA[1]; // 登录过来的密码
pd.put("USERNAME", USERNAME);
String passwd = new SimpleHash("SHA-1", USERNAME, PASSWORD)
.toString(); // 密码加密
pd.put("PASSWORD", passwd);
pd = userService.getUserByNameAndPwd(pd); // 根据用户名和密码去读取用户信息
if (pd != null) {
this.removeSession(USERNAME);// 请缓存
pd.put("LAST_LOGIN", DateUtil.getTime().toString());
userService.updateLastLogin(pd);
User user = new User();
user.setUSER_ID(pd.getString("USER_ID"));
user.setUSERNAME(pd.getString("USERNAME"));
user.setPASSWORD(pd.getString("PASSWORD"));
user.setNAME(pd.getString("NAME"));
user.setRIGHTS(pd.getString("RIGHTS"));
user.setROLE_ID(pd.getString("ROLE_ID"));
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
154
|
|
9f161055
孙向锦
修改高斯客户反馈
|
155
156
157
158
159
|
PageData eventPd = new PageData();
eventPd.put("EVENT_ID", get32UUID());
eventPd.put("EVENT_NAME", "login");
eventPd.put("EVENT_USER", pd.getString("USER_ID"));
eventPd.put("EVENT_TYPE", "0");
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
160
|
eventPd.put("EVENT_START_TIME", Tools.date2Str(new Date()));
|
9f161055
孙向锦
修改高斯客户反馈
|
161
|
eventPd.put("CLIENT_ID", "SERVER");
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
162
|
eventPd.put("EVENT_IP", pd.getString("IP"));
|
9f161055
孙向锦
修改高斯客户反馈
|
163
|
eventService.save(eventPd);
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
164
165
166
|
if ("57bb1e6f138247a0b05cc721a5da1b64".equals(pd
.getString("ROLE_ID"))) {
|
338594c8
孙向锦
添加教师端页面
|
167
|
map.put("teacher", pd.getString("RIGHTS"));
|
c617106f
孙向锦
添加即时测功能
|
168
169
170
171
172
173
174
|
PageData tpd = new PageData();
tpd.put("ACCOUT", pd.get("USERNAME"));
tpd.put("PASSWORD", PASSWORD);
PageData pageData = teacherService.getUserInfo(tpd);
if(pageData != null){
user.setTeacherID(pageData.getString("ID"));
}
|
338594c8
孙向锦
添加教师端页面
|
175
|
}
|
6b3a5ad0
孙向锦
添加管理员界面
|
176
177
178
179
180
181
182
183
184
|
if("51824b61dd6941f19c673996374781e5".equals(pd
.getString("ROLE_ID"))){
map.put("admin", pd.getString("RIGHTS"));
PageData tpd = new PageData();
tpd.put("ACCOUT", pd.get("USERNAME"));
tpd.put("PASSWORD", passwd);
PageData pageData = schooladminService.findByusername(tpd);
if(pageData != null){
user.setTeacherID(pageData.getString("SCHOOLADMIN_ID"));
|
6b3a5ad0
孙向锦
添加管理员界面
|
185
186
|
}
}
|
bed6e1fc
孙向锦
添加其他功能
|
187
188
189
190
191
192
193
194
195
196
197
198
199
|
user.setLAST_LOGIN(pd.getString("LAST_LOGIN"));
user.setIP(pd.getString("IP"));
user.setSTATUS(pd.getString("STATUS"));
session.setAttribute(Const.SESSION_USER, user); // 把用户信息放session中
session.removeAttribute(Const.SESSION_SECURITY_CODE); // 清除登录验证码的session
// shiro加入身份验证
Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(
USERNAME, PASSWORD);
try {
subject.login(token);
} catch (AuthenticationException e) {
errInfo = "身份验证失败!";
|
ad5081d3
孙向锦
初始化项目
|
200
|
}
|
bed6e1fc
孙向锦
添加其他功能
|
201
202
203
204
205
206
207
208
209
|
} else {
errInfo = "usererror"; // 用户名或密码有误
logBefore(logger, USERNAME + "登录系统密码或用户名错误");
FHLOG.save(USERNAME, "登录系统密码或用户名错误");
}
if (Tools.isEmpty(errInfo)) {
errInfo = "success"; // 验证成功
logBefore(logger, USERNAME + "登录系统");
FHLOG.save(USERNAME, "登录系统");
|
ad5081d3
孙向锦
初始化项目
|
210
|
}
|
bed6e1fc
孙向锦
添加其他功能
|
211
|
}
|
ad5081d3
孙向锦
初始化项目
|
212
213
214
|
map.put("result", errInfo);
return AppUtil.returnObject(new PageData(), map);
}
|
bed6e1fc
孙向锦
添加其他功能
|
215
216
217
218
219
220
|
/**
* 访问系统首页
*
* @param changeMenu
* :切换菜单参数
|
ad5081d3
孙向锦
初始化项目
|
221
222
|
* @return
*/
|
bed6e1fc
孙向锦
添加其他功能
|
223
224
225
|
@RequestMapping(value = "/main/{changeMenu}")
public ModelAndView login_index(
@PathVariable("changeMenu") String changeMenu) {
|
ad5081d3
孙向锦
初始化项目
|
226
227
228
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
|
bed6e1fc
孙向锦
添加其他功能
|
229
|
try {
|
ad5081d3
孙向锦
初始化项目
|
230
|
Session session = Jurisdiction.getSession();
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
231
|
|
f143f558
孙向锦
修改管理员登录白屏问题
|
232
|
User user = (User)session.getAttribute(Const.SESSION_USER); //读取session中的用户信息(单独用户信息)
|
ad5081d3
孙向锦
初始化项目
|
233
|
if (user != null) {
|
f143f558
孙向锦
修改管理员登录白屏问题
|
234
235
236
237
238
239
240
|
User userr = (User)session.getAttribute(Const.SESSION_USERROL); //读取session中的用户信息(含角色信息)
if(null == userr){
user = userService.getUserAndRoleById(user.getUSER_ID()); //通过用户ID读取用户信息和角色信息
session.setAttribute(Const.SESSION_USERROL, user); //存入session
}else{
user = userr;
}
|
ad5081d3
孙向锦
初始化项目
|
241
|
String USERNAME = user.getUSERNAME();
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
242
|
if ("teacher".equals(changeMenu)) {
|
338594c8
孙向锦
添加教师端页面
|
243
244
245
246
|
PageData tpd = new PageData();
tpd.put("ID", user.getUSER_ID());
List<PageData> teacherInfos = v1Service.getTeacherInfo(tpd);
pd.put("TEACHER", teacherInfos);
|
a51b67cf
孙向锦
交互第一个版本
|
247
|
if (teacherInfos != null && teacherInfos.size() > 0) {
|
f143f558
孙向锦
修改管理员登录白屏问题
|
248
|
PageData sData = teacherInfos.get(0);
|
a51b67cf
孙向锦
交互第一个版本
|
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
session.setAttribute(USERNAME + Const.SCHOOL_ID,
sData.get("SCHOOL_ID"));
session.setAttribute(USERNAME + Const.SCHOOL_NAME,
sData.get("SCHOOL_NAME"));
session.setAttribute(USERNAME + Const.GRADE_ID,
sData.get("GRADE_ID"));
session.setAttribute(USERNAME + Const.GRADE_NAME,
sData.get("GRADE_NAME"));
session.setAttribute(USERNAME + Const.CLASS_ID,
sData.get("CLASS_ID"));
session.setAttribute(USERNAME + Const.CLASS_NAME,
sData.get("CLASS_NAME"));
session.setAttribute(USERNAME + Const.SUBJECT_ID,
sData.get("SUBJECT_ID"));
session.setAttribute(USERNAME + Const.SUBJECT_NAME,
sData.get("SUBJECT_NAME"));
|
7d60b75e
孙向锦
添加班级-1
|
265
266
|
session.setAttribute(USERNAME + Const.TERM_ID,
sData.get("TERM_ID"));
|
83b5ddeb
孙向锦
模板添加
|
267
268
269
|
sData.put("USER_ID", user.getUSER_ID());
List<PageData> templateInfos = pagetemplateService.listAll(sData);
mv.addObject("templateInfos", templateInfos);
|
a51b67cf
孙向锦
交互第一个版本
|
270
|
}
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
271
|
session.setAttribute(Const.SESSION_USERNAME, USERNAME); // 放入用户名到session
|
338594c8
孙向锦
添加教师端页面
|
272
|
mv.setViewName("sunvote/teacher/teacher_main");
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
273
274
|
mv.addObject("user", user);
pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
|
6b3a5ad0
孙向锦
添加管理员界面
|
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
|
mv.addObject("pd", pd);
return mv;
}else if("admin".equals(changeMenu)){
PageData tpd = new PageData();
tpd.put("ID", user.getUSER_ID());
List<PageData> adminInfos = v1Service.getAdminInfo(tpd);
List<PageData> gradeInfos = new ArrayList<PageData>();
List<PageData> subjectInfos = new ArrayList<PageData>();
// 查询学校信息
for(PageData pad : adminInfos){
PageData tmpd = new PageData();
Object gradeId = pad.get("GRADE_ID");
tmpd.put("SNAME", pad.get("SNAME"));// 学校名称
tmpd.put("SCHOOL_ID", pad.get("SCHOOL_ID"));//学校ID
tmpd.put("GRADE_ID", pad.get("GRADE_ID"));//年级id
tmpd.put("GNAME", pad.get("GNAME"));//年级名称
tmpd.put("SUBJECT_ID", pad.get("SUBJECT_ID"));// 科目id
tmpd.put("SCNAME", pad.get("SCNAME"));// 科目名称
if(gradeId != null && !"".equals(gradeId)){
List<PageData> classInfos = sclassService.listAll(tmpd);
tmpd.put("classInfos", classInfos);
gradeInfos.add(tmpd);
}else{
subjectInfos.add(tmpd);
}
mv.addObject("SNAME", pad.get("SNAME"));
mv.addObject("SCHOOL_ID", pad.get("SCHOOL_ID"));
}
mv.addObject("gradeInfos", gradeInfos);
mv.addObject("subjectInfos", subjectInfos);
session.setAttribute(Const.SESSION_USERNAME, USERNAME); // 放入用户名到session
mv.setViewName("sunvote/admin/admin_main");
mv.addObject("user", user);
pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
310
311
|
mv.addObject("pd", pd);
return mv;
|
338594c8
孙向锦
添加教师端页面
|
312
|
}
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
Role role = user.getRole(); // 获取用户角色
String roleRights = role != null ? role.getRIGHTS() : ""; // 角色权限(菜单权限)
String ROLE_IDS = user.getROLE_IDS();
session.setAttribute(USERNAME + Const.SESSION_ROLE_RIGHTS,
roleRights); // 将角色权限存入session
session.setAttribute(Const.SESSION_USERNAME, USERNAME); // 放入用户名到session
this.setAttributeToAllDEPARTMENT_ID(session, USERNAME); // 把用户的组织机构权限放到session里面
List<Menu> allmenuList = new ArrayList<Menu>();
allmenuList = this.getAttributeMenu(session, USERNAME,
roleRights, getArrayRoleRights(ROLE_IDS)); // 菜单缓存
List<Menu> menuList = new ArrayList<Menu>();
if (null == session.getAttribute(USERNAME + Const.SESSION_QX)) {
session.setAttribute(USERNAME + Const.SESSION_QX,
this.getUQX(USERNAME)); // 主职角色按钮权限放到session中
session.setAttribute(USERNAME + Const.SESSION_QX2,
this.getUQX2(USERNAME)); // 副职角色按钮权限放到session中
}
this.getRemortIP(USERNAME); // 更新登录IP
menuList = this.changeMenuF(allmenuList, session, USERNAME,
changeMenu); // 切换菜单
mv.setViewName("system/index/main");
|
ad5081d3
孙向锦
初始化项目
|
336
337
|
mv.addObject("user", user);
mv.addObject("menuList", menuList);
|
bed6e1fc
孙向锦
添加其他功能
|
338
339
|
} else {
mv.setViewName("system/index/login");// session失效后跳转登录页面
|
ad5081d3
孙向锦
初始化项目
|
340
|
}
|
bed6e1fc
孙向锦
添加其他功能
|
341
|
} catch (Exception e) {
|
ad5081d3
孙向锦
初始化项目
|
342
343
344
|
mv.setViewName("system/index/login");
logger.error(e.getMessage(), e);
}
|
bed6e1fc
孙向锦
添加其他功能
|
345
346
|
pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
mv.addObject("pd", pd);
|
ad5081d3
孙向锦
初始化项目
|
347
348
|
return mv;
}
|
bed6e1fc
孙向锦
添加其他功能
|
349
350
351
352
|
/**
* 获取副职角色权限List
*
|
ad5081d3
孙向锦
初始化项目
|
353
354
355
356
|
* @param ROLE_IDS
* @return
* @throws Exception
*/
|
bed6e1fc
孙向锦
添加其他功能
|
357
358
|
public List<String> getArrayRoleRights(String ROLE_IDS) throws Exception {
if (Tools.notEmpty(ROLE_IDS)) {
|
ad5081d3
孙向锦
初始化项目
|
359
360
|
List<String> list = new ArrayList<String>();
String arryROLE_ID[] = ROLE_IDS.split(",fh,");
|
bed6e1fc
孙向锦
添加其他功能
|
361
|
for (int i = 0; i < arryROLE_ID.length; i++) {
|
ad5081d3
孙向锦
初始化项目
|
362
363
364
|
PageData pd = new PageData();
pd.put("ROLE_ID", arryROLE_ID[i]);
pd = roleService.findObjectById(pd);
|
bed6e1fc
孙向锦
添加其他功能
|
365
|
if (null != pd) {
|
ad5081d3
孙向锦
初始化项目
|
366
|
String RIGHTS = pd.getString("RIGHTS");
|
bed6e1fc
孙向锦
添加其他功能
|
367
|
if (Tools.notEmpty(RIGHTS)) {
|
ad5081d3
孙向锦
初始化项目
|
368
369
370
371
372
|
list.add(RIGHTS);
}
}
}
return list.size() == 0 ? null : list;
|
bed6e1fc
孙向锦
添加其他功能
|
373
|
} else {
|
ad5081d3
孙向锦
初始化项目
|
374
375
376
|
return null;
}
}
|
bed6e1fc
孙向锦
添加其他功能
|
377
378
379
380
|
/**
* 菜单缓存
*
|
ad5081d3
孙向锦
初始化项目
|
381
382
383
384
385
386
387
|
* @param session
* @param USERNAME
* @param roleRights
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
|
bed6e1fc
孙向锦
添加其他功能
|
388
389
|
public List<Menu> getAttributeMenu(Session session, String USERNAME,
String roleRights, List<String> arrayRoleRights) throws Exception {
|
ad5081d3
孙向锦
初始化项目
|
390
|
List<Menu> allmenuList = new ArrayList<Menu>();
|
bed6e1fc
孙向锦
添加其他功能
|
391
392
393
394
395
|
if (null == session.getAttribute(USERNAME + Const.SESSION_allmenuList)) {
allmenuList = menuService.listAllMenuQx("0"); // 获取所有菜单
if (Tools.notEmpty(roleRights)) {
allmenuList = this.readMenu(allmenuList, roleRights,
arrayRoleRights); // 根据角色权限获取本权限的菜单列表
|
ad5081d3
孙向锦
初始化项目
|
396
|
}
|
bed6e1fc
孙向锦
添加其他功能
|
397
398
399
400
401
|
session.setAttribute(USERNAME + Const.SESSION_allmenuList,
allmenuList);// 菜单权限放入session中
} else {
allmenuList = (List<Menu>) session.getAttribute(USERNAME
+ Const.SESSION_allmenuList);
|
ad5081d3
孙向锦
初始化项目
|
402
403
404
|
}
return allmenuList;
}
|
bed6e1fc
孙向锦
添加其他功能
|
405
406
407
408
409
410
411
412
|
/**
* 根据角色权限获取本权限的菜单列表(递归处理)
*
* @param menuList
* :传入的总菜单
* @param roleRights
* :加密的权限字符串
|
ad5081d3
孙向锦
初始化项目
|
413
414
|
* @return
*/
|
bed6e1fc
孙向锦
添加其他功能
|
415
416
417
418
419
420
421
422
423
424
|
public List<Menu> readMenu(List<Menu> menuList, String roleRights,
List<String> arrayRoleRights) {
for (int i = 0; i < menuList.size(); i++) {
Boolean b1 = RightsHelper.testRights(roleRights, menuList.get(i)
.getMENU_ID());
menuList.get(i).setHasMenu(b1); // 赋予主职角色菜单权限
if (!b1 && null != arrayRoleRights) {
for (int n = 0; n < arrayRoleRights.size(); n++) {
if (RightsHelper.testRights(arrayRoleRights.get(n),
menuList.get(i).getMENU_ID())) {
|
ad5081d3
孙向锦
初始化项目
|
425
426
427
428
429
|
menuList.get(i).setHasMenu(true);
break;
}
}
}
|
bed6e1fc
孙向锦
添加其他功能
|
430
431
432
|
if (menuList.get(i).isHasMenu()) { // 判断是否有此菜单权限
this.readMenu(menuList.get(i).getSubMenu(), roleRights,
arrayRoleRights);// 是:继续排查其子菜单
|
ad5081d3
孙向锦
初始化项目
|
433
434
435
436
|
}
}
return menuList;
}
|
bed6e1fc
孙向锦
添加其他功能
|
437
438
439
440
|
/**
* 切换菜单处理
*
|
ad5081d3
孙向锦
初始化项目
|
441
442
443
444
445
446
447
|
* @param allmenuList
* @param session
* @param USERNAME
* @param changeMenu
* @return
*/
@SuppressWarnings("unchecked")
|
bed6e1fc
孙向锦
添加其他功能
|
448
449
|
public List<Menu> changeMenuF(List<Menu> allmenuList, Session session,
String USERNAME, String changeMenu) {
|
ad5081d3
孙向锦
初始化项目
|
450
451
|
List<Menu> menuList = new ArrayList<Menu>();
/** 菜单缓存为空 或者 传入的菜单类型和当前不一样的时候,条件成立,重新拆分菜单,把选择的菜单类型放入缓存 */
|
bed6e1fc
孙向锦
添加其他功能
|
452
453
|
if (null == session.getAttribute(USERNAME + Const.SESSION_menuList)
|| (!changeMenu.equals(session.getAttribute("changeMenu")))) {
|
ad5081d3
孙向锦
初始化项目
|
454
455
456
457
|
List<Menu> menuList1 = new ArrayList<Menu>();
List<Menu> menuList2 = new ArrayList<Menu>();
List<Menu> menuList3 = new ArrayList<Menu>();
List<Menu> menuList4 = new ArrayList<Menu>();
|
bed6e1fc
孙向锦
添加其他功能
|
458
|
for (int i = 0; i < allmenuList.size(); i++) {// 拆分菜单
|
ad5081d3
孙向锦
初始化项目
|
459
|
Menu menu = allmenuList.get(i);
|
bed6e1fc
孙向锦
添加其他功能
|
460
461
462
463
464
465
466
467
|
if ("1".equals(menu.getMENU_TYPE())) {
menuList1.add(menu); // 系统菜单
} else if ("2".equals(menu.getMENU_TYPE())) {
menuList2.add(menu); // 业务菜单
} else if ("3".equals(menu.getMENU_TYPE())) {
menuList3.add(menu); // 菜单类型三
} else if ("4".equals(menu.getMENU_TYPE())) {
menuList4.add(menu); // 菜单类型四
|
ad5081d3
孙向锦
初始化项目
|
468
469
470
|
}
}
session.removeAttribute(USERNAME + Const.SESSION_menuList);
|
bed6e1fc
孙向锦
添加其他功能
|
471
472
473
|
if ("index".equals(changeMenu)) {
session.setAttribute(USERNAME + Const.SESSION_menuList,
menuList2);
|
ad5081d3
孙向锦
初始化项目
|
474
475
476
|
session.removeAttribute("changeMenu");
session.setAttribute("changeMenu", "index");
menuList = menuList2;
|
bed6e1fc
孙向锦
添加其他功能
|
477
478
479
|
} else if ("2".equals(changeMenu)) {
session.setAttribute(USERNAME + Const.SESSION_menuList,
menuList1);
|
ad5081d3
孙向锦
初始化项目
|
480
481
482
|
session.removeAttribute("changeMenu");
session.setAttribute("changeMenu", "2");
menuList = menuList1;
|
bed6e1fc
孙向锦
添加其他功能
|
483
484
485
|
} else if ("3".equals(changeMenu)) {
session.setAttribute(USERNAME + Const.SESSION_menuList,
menuList3);
|
ad5081d3
孙向锦
初始化项目
|
486
487
488
|
session.removeAttribute("changeMenu");
session.setAttribute("changeMenu", "3");
menuList = menuList3;
|
bed6e1fc
孙向锦
添加其他功能
|
489
490
491
|
} else if ("4".equals(changeMenu)) {
session.setAttribute(USERNAME + Const.SESSION_menuList,
menuList4);
|
ad5081d3
孙向锦
初始化项目
|
492
493
494
|
session.removeAttribute("changeMenu");
session.setAttribute("changeMenu", "4");
menuList = menuList4;
|
4f32cbf7
孙向锦
更新新东方服务界面维护文档
|
495
|
} else if ("teacher".equals(changeMenu)) {
|
338594c8
孙向锦
添加教师端页面
|
496
497
498
499
|
session.setAttribute(USERNAME + Const.SESSION_menuList,
menuList2);
session.removeAttribute("changeMenu");
session.setAttribute("changeMenu", "index");
|
ad5081d3
孙向锦
初始化项目
|
500
|
}
|
bed6e1fc
孙向锦
添加其他功能
|
501
502
503
|
} else {
menuList = (List<Menu>) session.getAttribute(USERNAME
+ Const.SESSION_menuList);
|
ad5081d3
孙向锦
初始化项目
|
504
505
506
|
}
return menuList;
}
|
bed6e1fc
孙向锦
添加其他功能
|
507
508
509
510
|
/**
* 把用户的组织机构权限放到session里面
*
|
ad5081d3
孙向锦
初始化项目
|
511
512
513
|
* @param session
* @param USERNAME
* @return
|
bed6e1fc
孙向锦
添加其他功能
|
514
|
* @throws Exception
|
ad5081d3
孙向锦
初始化项目
|
515
|
*/
|
bed6e1fc
孙向锦
添加其他功能
|
516
517
518
519
|
public void setAttributeToAllDEPARTMENT_ID(Session session, String USERNAME)
throws Exception {
String DEPARTMENT_IDS = "0", DEPARTMENT_ID = "0";
if (!"admin".equals(USERNAME)) {
|
ad5081d3
孙向锦
初始化项目
|
520
|
PageData pd = datajurService.getDEPARTMENT_IDS(USERNAME);
|
bed6e1fc
孙向锦
添加其他功能
|
521
522
|
DEPARTMENT_IDS = null == pd ? "无权" : pd.getString("DEPARTMENT_IDS");
DEPARTMENT_ID = null == pd ? "无权" : pd.getString("DEPARTMENT_ID");
|
ad5081d3
孙向锦
初始化项目
|
523
|
}
|
bed6e1fc
孙向锦
添加其他功能
|
524
525
|
session.setAttribute(Const.DEPARTMENT_IDS, DEPARTMENT_IDS); // 把用户的组织机构权限集合放到session里面
session.setAttribute(Const.DEPARTMENT_ID, DEPARTMENT_ID); // 把用户的最高组织机构权限放到session里面
|
ad5081d3
孙向锦
初始化项目
|
526
|
}
|
bed6e1fc
孙向锦
添加其他功能
|
527
|
|
ad5081d3
孙向锦
初始化项目
|
528
529
|
/**
* 进入tab标签
|
bed6e1fc
孙向锦
添加其他功能
|
530
|
*
|
ad5081d3
孙向锦
初始化项目
|
531
532
|
* @return
*/
|
bed6e1fc
孙向锦
添加其他功能
|
533
534
|
@RequestMapping(value = "/tab")
public String tab() {
|
ad5081d3
孙向锦
初始化项目
|
535
536
|
return "system/index/tab";
}
|
bed6e1fc
孙向锦
添加其他功能
|
537
|
|
ad5081d3
孙向锦
初始化项目
|
538
539
|
/**
* 进入首页后的默认页面
|
bed6e1fc
孙向锦
添加其他功能
|
540
|
*
|
ad5081d3
孙向锦
初始化项目
|
541
|
* @return
|
bed6e1fc
孙向锦
添加其他功能
|
542
|
* @throws Exception
|
ad5081d3
孙向锦
初始化项目
|
543
|
*/
|
bed6e1fc
孙向锦
添加其他功能
|
544
545
|
@RequestMapping(value = "/login_default")
public ModelAndView defaultPage() throws Exception {
|
ad5081d3
孙向锦
初始化项目
|
546
547
|
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
|
bed6e1fc
孙向锦
添加其他功能
|
548
549
550
551
552
553
554
|
pd.put("userCount",
Integer.parseInt(userService.getUserCount("").get("userCount")
.toString()) - 1); // 系统用户数
pd.put("appUserCount",
Integer.parseInt(appuserService.getAppUserCount("")
.get("appUserCount").toString())); // 会员数
mv.addObject("pd", pd);
|
ad5081d3
孙向锦
初始化项目
|
555
556
557
|
mv.setViewName("system/index/default");
return mv;
}
|
bed6e1fc
孙向锦
添加其他功能
|
558
|
|
ad5081d3
孙向锦
初始化项目
|
559
560
|
/**
* 用户注销
|
bed6e1fc
孙向锦
添加其他功能
|
561
|
*
|
ad5081d3
孙向锦
初始化项目
|
562
563
|
* @param session
* @return
|
bed6e1fc
孙向锦
添加其他功能
|
564
|
* @throws Exception
|
ad5081d3
孙向锦
初始化项目
|
565
|
*/
|
bed6e1fc
孙向锦
添加其他功能
|
566
567
568
569
|
@RequestMapping(value = "/logout")
public ModelAndView logout() throws Exception {
String USERNAME = Jurisdiction.getUsername(); // 当前登录的用户名
logBefore(logger, USERNAME + "退出系统");
|
ad5081d3
孙向锦
初始化项目
|
570
571
572
|
FHLOG.save(USERNAME, "退出");
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
|
bed6e1fc
孙向锦
添加其他功能
|
573
574
575
|
this.removeSession(USERNAME);// 请缓存
// shiro销毁登录
Subject subject = SecurityUtils.getSubject();
|
ad5081d3
孙向锦
初始化项目
|
576
577
578
|
subject.logout();
pd = this.getPageData();
pd.put("msg", pd.getString("msg"));
|
bed6e1fc
孙向锦
添加其他功能
|
579
|
pd = this.setLoginPd(pd); // 设置登录页面的配置参数
|
ad5081d3
孙向锦
初始化项目
|
580
|
mv.setViewName("system/index/login");
|
bed6e1fc
孙向锦
添加其他功能
|
581
|
mv.addObject("pd", pd);
|
ad5081d3
孙向锦
初始化项目
|
582
583
|
return mv;
}
|
bed6e1fc
孙向锦
添加其他功能
|
584
|
|
ad5081d3
孙向锦
初始化项目
|
585
586
587
|
/**
* 清理session
*/
|
bed6e1fc
孙向锦
添加其他功能
|
588
589
|
public void removeSession(String USERNAME) {
Session session = Jurisdiction.getSession(); // 以下清除session缓存
|
ad5081d3
孙向锦
初始化项目
|
590
591
592
593
594
595
596
597
598
599
600
601
602
|
session.removeAttribute(Const.SESSION_USER);
session.removeAttribute(USERNAME + Const.SESSION_ROLE_RIGHTS);
session.removeAttribute(USERNAME + Const.SESSION_allmenuList);
session.removeAttribute(USERNAME + Const.SESSION_menuList);
session.removeAttribute(USERNAME + Const.SESSION_QX);
session.removeAttribute(USERNAME + Const.SESSION_QX2);
session.removeAttribute(Const.SESSION_userpds);
session.removeAttribute(Const.SESSION_USERNAME);
session.removeAttribute(Const.SESSION_USERROL);
session.removeAttribute("changeMenu");
session.removeAttribute("DEPARTMENT_IDS");
session.removeAttribute("DEPARTMENT_ID");
}
|
bed6e1fc
孙向锦
添加其他功能
|
603
604
605
606
|
/**
* 设置登录页面的配置参数
*
|
ad5081d3
孙向锦
初始化项目
|
607
608
609
|
* @param pd
* @return
*/
|
bed6e1fc
孙向锦
添加其他功能
|
610
611
612
613
|
public PageData setLoginPd(PageData pd) {
pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
String strLOGINEDIT = Tools.readTxtFile(Const.LOGINEDIT); // 读取登录页面配置
if (null != strLOGINEDIT && !"".equals(strLOGINEDIT)) {
|
ad5081d3
孙向锦
初始化项目
|
614
|
String strLo[] = strLOGINEDIT.split(",fh,");
|
bed6e1fc
孙向锦
添加其他功能
|
615
|
if (strLo.length == 2) {
|
ad5081d3
孙向锦
初始化项目
|
616
617
618
619
620
|
pd.put("isZhuce", strLo[0]);
pd.put("isMusic", strLo[1]);
}
}
try {
|
bed6e1fc
孙向锦
添加其他功能
|
621
|
List<PageData> listImg = loginimgService.listAll(pd); // 登录背景图片
|
ad5081d3
孙向锦
初始化项目
|
622
623
624
625
626
627
|
pd.put("listImg", listImg);
} catch (Exception e) {
e.printStackTrace();
}
return pd;
}
|
bed6e1fc
孙向锦
添加其他功能
|
628
629
630
631
|
/**
* 获取用户权限
*
|
ad5081d3
孙向锦
初始化项目
|
632
633
634
|
* @param session
* @return
*/
|
bed6e1fc
孙向锦
添加其他功能
|
635
|
public Map<String, String> getUQX(String USERNAME) {
|
ad5081d3
孙向锦
初始化项目
|
636
637
638
639
|
PageData pd = new PageData();
Map<String, String> map = new HashMap<String, String>();
try {
pd.put(Const.SESSION_USERNAME, USERNAME);
|
bed6e1fc
孙向锦
添加其他功能
|
640
|
|
ad5081d3
孙向锦
初始化项目
|
641
|
PageData userpd = new PageData();
|
bed6e1fc
孙向锦
添加其他功能
|
642
|
userpd = userService.findByUsername(pd); // 通过用户名获取用户信息
|
ad5081d3
孙向锦
初始化项目
|
643
644
|
String ROLE_ID = userpd.get("ROLE_ID").toString();
String ROLE_IDS = userpd.getString("ROLE_IDS");
|
bed6e1fc
孙向锦
添加其他功能
|
645
646
647
648
649
650
|
pd.put("ROLE_ID", ROLE_ID); // 获取角色ID
pd = roleService.findObjectById(pd); // 获取角色信息
map.put("adds", pd.getString("ADD_QX")); // 增
map.put("dels", pd.getString("DEL_QX")); // 删
map.put("edits", pd.getString("EDIT_QX")); // 改
map.put("chas", pd.getString("CHA_QX")); // 查
|
ad5081d3
孙向锦
初始化项目
|
651
|
List<PageData> buttonQXnamelist = new ArrayList<PageData>();
|
bed6e1fc
孙向锦
添加其他功能
|
652
653
654
655
|
if ("admin".equals(USERNAME)) {
buttonQXnamelist = fhbuttonService.listAll(pd); // admin用户拥有所有按钮权限
} else {
if (Tools.notEmpty(ROLE_IDS)) {// (主副职角色综合按钮权限)
|
ad5081d3
孙向锦
初始化项目
|
656
657
|
ROLE_IDS = ROLE_IDS + ROLE_ID;
String arryROLE_ID[] = ROLE_IDS.split(",fh,");
|
bed6e1fc
孙向锦
添加其他功能
|
658
659
660
661
662
|
buttonQXnamelist = buttonrightsService
.listAllBrAndQxnameByZF(arryROLE_ID);
} else { // (主职角色按钮权限)
buttonQXnamelist = buttonrightsService
.listAllBrAndQxname(pd); // 此角色拥有的按钮权限标识列表
|
ad5081d3
孙向锦
初始化项目
|
663
664
|
}
}
|
bed6e1fc
孙向锦
添加其他功能
|
665
666
|
for (int i = 0; i < buttonQXnamelist.size(); i++) {
map.put(buttonQXnamelist.get(i).getString("QX_NAME"), "1"); // 按钮权限
|
ad5081d3
孙向锦
初始化项目
|
667
668
669
|
}
} catch (Exception e) {
logger.error(e.toString(), e);
|
bed6e1fc
孙向锦
添加其他功能
|
670
|
}
|
ad5081d3
孙向锦
初始化项目
|
671
672
|
return map;
}
|
bed6e1fc
孙向锦
添加其他功能
|
673
674
675
676
|
/**
* 获取用户权限(处理副职角色)
*
|
ad5081d3
孙向锦
初始化项目
|
677
678
679
|
* @param session
* @return
*/
|
bed6e1fc
孙向锦
添加其他功能
|
680
|
public Map<String, List<String>> getUQX2(String USERNAME) {
|
ad5081d3
孙向锦
初始化项目
|
681
682
683
684
685
|
PageData pd = new PageData();
Map<String, List<String>> maps = new HashMap<String, List<String>>();
try {
pd.put(Const.SESSION_USERNAME, USERNAME);
PageData userpd = new PageData();
|
bed6e1fc
孙向锦
添加其他功能
|
686
|
userpd = userService.findByUsername(pd); // 通过用户名获取用户信息
|
ad5081d3
孙向锦
初始化项目
|
687
|
String ROLE_IDS = userpd.getString("ROLE_IDS");
|
bed6e1fc
孙向锦
添加其他功能
|
688
|
if (Tools.notEmpty(ROLE_IDS)) {
|
ad5081d3
孙向锦
初始化项目
|
689
690
691
692
693
694
|
String arryROLE_ID[] = ROLE_IDS.split(",fh,");
PageData rolePd = new PageData();
List<String> addsList = new ArrayList<String>();
List<String> delsList = new ArrayList<String>();
List<String> editsList = new ArrayList<String>();
List<String> chasList = new ArrayList<String>();
|
bed6e1fc
孙向锦
添加其他功能
|
695
|
for (int i = 0; i < arryROLE_ID.length; i++) {
|
ad5081d3
孙向锦
初始化项目
|
696
697
698
699
700
701
702
|
rolePd.put("ROLE_ID", arryROLE_ID[i]);
rolePd = roleService.findObjectById(rolePd);
addsList.add(rolePd.getString("ADD_QX"));
delsList.add(rolePd.getString("DEL_QX"));
editsList.add(rolePd.getString("EDIT_QX"));
chasList.add(rolePd.getString("CHA_QX"));
}
|
bed6e1fc
孙向锦
添加其他功能
|
703
704
705
706
|
maps.put("addsList", addsList); // 增
maps.put("delsList", delsList); // 删
maps.put("editsList", editsList); // 改
maps.put("chasList", chasList); // 查
|
ad5081d3
孙向锦
初始化项目
|
707
708
709
|
}
} catch (Exception e) {
logger.error(e.toString(), e);
|
bed6e1fc
孙向锦
添加其他功能
|
710
|
}
|
ad5081d3
孙向锦
初始化项目
|
711
712
|
return maps;
}
|
bed6e1fc
孙向锦
添加其他功能
|
713
714
715
716
|
/**
* 更新登录用户的IP
*
|
ad5081d3
孙向锦
初始化项目
|
717
718
719
|
* @param USERNAME
* @throws Exception
*/
|
bed6e1fc
孙向锦
添加其他功能
|
720
|
public void getRemortIP(String USERNAME) throws Exception {
|
ad5081d3
孙向锦
初始化项目
|
721
722
723
|
PageData pd = new PageData();
HttpServletRequest request = this.getRequest();
String ip = "";
|
bed6e1fc
孙向锦
添加其他功能
|
724
725
726
727
728
|
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
|
ad5081d3
孙向锦
初始化项目
|
729
730
731
|
pd.put("USERNAME", USERNAME);
pd.put("IP", ip);
userService.saveIP(pd);
|
bed6e1fc
孙向锦
添加其他功能
|
732
733
|
}
|
ad5081d3
孙向锦
初始化项目
|
734
|
}
|