* @throws IOException
*/
@RequestMapping(value = "/userinfo.jspx")
String userinfo(HttpServletRequest request, HttpServletResponse response)
throws IOException {
User user = (User) request.getSession().getAttribute("userLogin");
String email = request.getParameter("email");
String password = request.getParameter("password");
String repassword = request.getParameter("repassword");
String username = request.getParameter("username");
String department = request.getParameter("department");
String birthday = request.getParameter("birthday");
String entryDate = request.getParameter("entryDate");
String leaveDate = request.getParameter("leaveDate");
String editUserId = request.getParameter("editUserId");
// 返回页面展示
if (null == email || null == username || null == department
|| null == birthday || null == entryDate) {
String id = request.getParameter("id");
int idI = Integer.valueOf(id);
User u = userService.getUserById(idI);
if (null == u) {
return "error";
}
List<Activity> list = userService.listActivities(u.getId());
request.setAttribute("actList", list);
request.setAttribute("editUser", u);
return "user/userinfo";
}
// 真正修改
int editUserIdI = Integer.valueOf(editUserId);
User editUser = userService.getUserById(editUserIdI);
List<Activity> list0 = userService.listActivities(editUser.getId());
if ("".equals(email) || "".equals(username) || "".equals(department)
|| "".equals(birthday) || "".equals(entryDate)) {
request.setAttribute("editUser", editUser);
request.setAttribute("actList", list0);
request.setAttribute("errorMsg", "请填写必填的信息!");
return "user/userinfo";
}
// 管理员不能修改管理员
if (editUser.getPrivilege() == User.ADMIN
&& editUser.getId() != user.getId()) {
request.setAttribute("errorMsg", "你不能修改其他管理员的信息");
request.setAttribute("editUser", editUser);
request.setAttribute("actList", list0);
return "user/userinfo";
}
// 检查邮箱相同
if (!email.equals(editUser.getEmail())) {
User u = userService.getUserByEmail(email);
if (null != u) {
request.setAttribute("errorMsg", "邮箱已经被注册");
request.setAttribute("editUser", editUser);
request.setAttribute("actList", list0);
return "user/userinfo";