コード例 #1
0
 @RequestMapping("/user_update")
 public ModelAndView updateUser(HttpServletRequest request) {
   String id = request.getParameter("id").trim();
   String username = request.getParameter("username").trim();
   String realname = request.getParameter("realname").trim();
   String mobile = request.getParameter("mobile").trim();
   String weixinno = request.getParameter("weixinno").trim();
   String email = request.getParameter("email").trim();
   logger.info(
       "用户请求数据:"
           + "----id:"
           + id
           + "----email:"
           + email
           + "----weixinno:"
           + weixinno
           + "--------mobile:"
           + mobile
           + "----------realname:"
           + realname
           + "----username"
           + username);
   ModelAndView mv = new ModelAndView();
   if (StringUtils.isNoneBlank(id)
       && StringUtils.isNoneBlank(email)
       && StringUtils.isNoneBlank(username)
       && StringUtils.isNoneBlank(mobile)
       && StringUtils.isNoneBlank(realname)) {
     Map<String, Object> params = new HashMap<String, Object>();
     if (StringUtils.isNoneBlank(id)) {
       params.put("id", new Integer(id));
       TUser user = userService.queryUser(params);
       user.setUsername(username);
       user.setEmail(email);
       user.setRealname(realname);
       user.setMobile(mobile);
       user.setWeixinno(weixinno);
       user.setUpdatetime(new Timestamp(new Date().getTime()));
       userService.updateUser(user);
       mv.setViewName("redirect:/user_list");
     }
   }
   return mv;
 }
コード例 #2
0
 @RequestMapping("/user_save")
 public ModelAndView saveUser(HttpServletRequest request) {
   String username = request.getParameter("username").trim();
   String realname = request.getParameter("realname").trim();
   String mobile = request.getParameter("mobile").trim();
   String weixinno = request.getParameter("weixinno").trim();
   String email = request.getParameter("email").trim();
   logger.info(
       "用户请求数据:"
           + "----email:"
           + email
           + "----weixinno:"
           + weixinno
           + "--------mobile:"
           + mobile
           + "----------realname:"
           + realname
           + "----username"
           + username);
   ModelAndView mv = new ModelAndView();
   if (StringUtils.isNoneBlank(email)
       && StringUtils.isNoneBlank(username)
       && StringUtils.isNoneBlank(mobile)
       && StringUtils.isNoneBlank(realname)) {
     TUser user = new TUser();
     user.setUsertype(1); // 管理平台用户
     user.setUsername(username);
     user.setEmail(email);
     user.setRealname(realname);
     user.setMobile(mobile);
     user.setWeixinno(weixinno);
     user.setPassword(Md5.md5("123456")); // 初始密码123456
     user.setRegtime(new Timestamp(new Date().getTime()));
     user.setUpdatetime(new Timestamp(new Date().getTime()));
     userService.saveUser(user);
     mv.setViewName("redirect:/user_list");
   }
   return mv;
 }