Blame view

src/com/fh/controller/base/BaseController.java 3.48 KB
ad5081d3   孙向锦   初始化项目
1
2
3
4
5
  package com.fh.controller.base;
  
  
  import javax.servlet.http.HttpServletRequest;
  
92455d76   孙向锦   添加更新到服务器
6
  import org.apache.shiro.session.Session;
ad5081d3   孙向锦   初始化项目
7
8
9
10
11
  import org.springframework.web.context.request.RequestContextHolder;
  import org.springframework.web.context.request.ServletRequestAttributes;
  import org.springframework.web.servlet.ModelAndView;
  
  import com.fh.entity.Page;
92455d76   孙向锦   添加更新到服务器
12
13
14
  import com.fh.entity.system.User;
  import com.fh.util.Const;
  import com.fh.util.Jurisdiction;
ad5081d3   孙向锦   初始化项目
15
16
17
18
19
  import com.fh.util.Logger;
  import com.fh.util.PageData;
  import com.fh.util.UuidUtil;
  
  /**
ad5081d3   孙向锦   初始化项目
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
   * 修改时间:20151211
   */
  public class BaseController {
  	
  	protected Logger logger = Logger.getLogger(this.getClass());
  
  	private static final long serialVersionUID = 6357869213649815390L;
  	
  	/** new PageData对象
  	 * @return
  	 */
  	public PageData getPageData(){
  		return new PageData(this.getRequest());
  	}
  	
  	/**得到ModelAndView
  	 * @return
  	 */
  	public ModelAndView getModelAndView(){
  		return new ModelAndView();
  	}
  	
  	/**得到request对象
  	 * @return
  	 */
  	public HttpServletRequest getRequest() {
  		HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
  		return request;
  	}
  
  	/**得到32位的uuid
  	 * @return
  	 */
  	public String get32UUID(){
  		return UuidUtil.get32UUID();
  	}
  	
  	/**得到分页列表的信息
  	 * @return
  	 */
  	public Page getPage(){
  		return new Page();
  	}
  	
  	public static void logBefore(Logger logger, String interfaceName){
  		logger.info("");
  		logger.info("start");
  		logger.info(interfaceName);
  	}
  	
  	public static void logAfter(Logger logger){
  		logger.info("end");
  		logger.info("");
  	}
  	
92455d76   孙向锦   添加更新到服务器
75
76
77
78
79
80
81
82
83
  	
  	public String getUsername(){
  		Session session = Jurisdiction.getSession();
  		User user = (User)session.getAttribute(Const.SESSION_USER);
  		if(user != null){
  			return user.getUSERNAME();
  		}
  		return "ERROR";
  	}
338594c8   孙向锦   添加教师端页面
84
  	
a51b67cf   孙向锦   交互第一个版本
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
  	public String getUserID(){
  		Session session = Jurisdiction.getSession();
  		User user = (User)session.getAttribute(Const.SESSION_USER);
  		if(user != null){
  			return user.getUSER_ID();
  		}
  		return "ERROR";
  	}
  	
  	
  	public String getSchoolID(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.SCHOOL_ID);
  		return schoolName;
  	}
  	public String getSchoolName(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.SCHOOL_NAME);
  		return schoolName;
  	}
  	public String getGradeID(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.GRADE_ID);
  		return schoolName;
  	}
  	public String getGradeName(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.GRADE_NAME);
  		return schoolName;
  	}
  	public String getSubjectId(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.SUBJECT_ID);
  		return schoolName;
  	}
  	public String getSubjectName(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.SUBJECT_NAME);
  		return schoolName;
  	}
  	public String getClassId(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.CLASS_ID);
  		return schoolName;
  	}
  	public String getClassName(){
  		Session session = Jurisdiction.getSession();
  		String schoolName = (String)session.getAttribute(getUsername() + Const.CLASS_NAME);
  		return schoolName;
  	}
338594c8   孙向锦   添加教师端页面
135
  	
ad5081d3   孙向锦   初始化项目
136
  }