Exemplo n.º 1
0
  /** 用户导出 */
  @RequestMapping("/user/export")
  public void userListExport(
      HttpServletRequest request, HttpServletResponse response, @ModelAttribute User user) {
    try {
      // 指定文件生成路径
      String dir = request.getSession().getServletContext().getRealPath("/excelfile/user");
      // 文件名
      String expName = "学员信息_" + DateUtils.getStringDateShort();
      // 表头信息
      String[] headName = {"ID", "昵称", "真实姓名", "学员邮箱", "学员手机", "注册时间", "状态"};

      // 拆分为一万条数据每Excel,防止内存使用太大
      PageEntity page = new PageEntity();
      page.setPageSize(10000);
      userService.getUserListByCondition(user, page);
      int num = page.getTotalPageSize(); // 总页数
      List<File> srcfile = new ArrayList<File>(); // 生成的excel的文件的list
      for (int i = 1; i <= num; i++) { // 循环生成num个xls文件
        page.setCurrentPage(i);
        List<User> userList = userService.getUserListByCondition(user, page);
        List<List<String>> list = userJoint(userList);
        File file = FileExportImportUtil.createExcel(headName, list, expName + "_" + i, dir);
        srcfile.add(file);
      }
      FileExportImportUtil.createRar(response, dir, srcfile, expName); // 生成的多excel的压缩包
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  /**
   * 禁用学员账号(冻结)
   *
   * @param user
   * @return
   */
  @RequestMapping("/user/updateIsavalible")
  @ResponseBody
  public Map<String, Object> updateIsavalible(
      HttpServletRequest request, @ModelAttribute User user) {
    try {
      userService.updateUserForIsavalibleById(user);
      this.setJson(true, "success", null);

      // 记录系统用户操作
      Map<String, Object> descMap = new HashMap<String, Object>();
      descMap.put("optuser", "操作id_" + SingletonLoginUtils.getSysUserId(request));
      descMap.put("optType", user.getIsavalible() == 1 ? "禁用" : "正常");
      descMap.put("userId", "用户id_" + user.getId());
      userService.addUserOptRecord(
          user.getId(),
          user.getIsavalible() == 1
              ? UserOptType.DISABLE.toString()
              : UserOptType.ACTIVE.toString(),
          SingletonLoginUtils.getSysUserId(request),
          this.getSysLoginLoginName(request),
          user.getId(),
          gson.toJson(descMap));
    } catch (Exception e) {
      logger.error("AdminUserController.updateIsavalible", e);
    }
    return json;
  }
Exemplo n.º 3
0
 /**
  * 短信邮件发送 查询用户列表集合
  *
  * @param user
  * @param page
  * @return
  */
 @RequestMapping("/user/select_userlist/{type}")
 public ModelAndView selectUserList(
     @ModelAttribute User user,
     @ModelAttribute("page") PageEntity page,
     @PathVariable("type") int type) {
   ModelAndView modelandView = new ModelAndView();
   // 设置返回页面
   modelandView.setViewName(toSelectUserList);
   try {
     if (type == 3) {
       page.setPageSize(5);
     }
     // 设置分页 ,默认每页10
     this.setPage(page);
     // 查询学员列表
     List<User> list = userService.getUserListAndCourse(user, this.getPage());
     // 把参数放到modelAndView中
     modelandView.addObject("list", list);
     modelandView.addObject("page", this.getPage());
     modelandView.addObject("type", type); // 1 短信  2邮箱  3系统消息
   } catch (Exception e) {
     logger.error("AdminUserController.userList", e);
   }
   return modelandView;
 }
Exemplo n.º 4
0
 /**
  * 获取用户信息 ById
  *
  * @return
  */
 @RequestMapping("/user/getUserInfo/{id}")
 public String getUserInfo(Model model, @PathVariable("id") Long id) {
   try {
     User user = userService.getUserById(id);
     model.addAttribute("user", user);
   } catch (Exception e) {
     logger.error("getUserInfo:" + e);
   }
   return "路径";
 }
Exemplo n.º 5
0
 /**
  * 跳转到修改密码
  *
  * @return
  */
 @RequestMapping("/user/toupdatepwd/{id}")
 public ModelAndView toUpdatePwd(@PathVariable("id") Long id) {
   ModelAndView modelAndView = new ModelAndView();
   modelAndView.setViewName(toUpdatePwd);
   try {
     User user = userService.getUserById(id);
     modelAndView.addObject("user", user);
   } catch (Exception e) {
     logger.error("AdminUserController.toUpdatePwd", e);
   }
   return modelAndView;
 }
Exemplo n.º 6
0
  /**
   * 修改密码
   *
   * @return
   */
  @RequestMapping("/user/updatepwd")
  @ResponseBody
  public Map<String, Object> updatePwd(HttpServletRequest request, @ModelAttribute User user) {
    try {
      userService.updatePwdById(user, null);
      this.setJson(true, "success", null);

      // 记录系统用户操作
      Map<String, Object> descMap = new HashMap<String, Object>();
      descMap.put("optuser", "操作id_" + SingletonLoginUtils.getSysUserId(request));
      descMap.put("optType", "操作_修改用户密码");
      descMap.put("userId", "用户id_" + user.getId());
      userService.addUserOptRecord(
          user.getId(),
          UserOptType.CHANGEPWD.toString(),
          SingletonLoginUtils.getSysUserId(request),
          this.getSysLoginLoginName(request),
          user.getId(),
          gson.toJson(descMap));
    } catch (Exception e) {
      logger.error("AdminUserController.updatePwd", e);
    }
    return json;
  }
Exemplo n.º 7
0
  /**
   * 修改用户信息
   *
   * @param user
   * @return
   */
  @RequestMapping("/user/updateUserInfo")
  @ResponseBody
  public Map<String, Object> updateUserInfo(@ModelAttribute("user") User user) {
    try {
      // 修改用户信息
      if (ObjectUtils.isNull(user)) {
        this.setJson(false, "信息错误", null);
        return json;
      }

      userService.updateUser(user);
      this.setJson(true, "修改成功", null);
    } catch (Exception e) {
      logger.error("updateUserInfo:" + e);
    }
    return json;
  }
Exemplo n.º 8
0
 /**
  * 用户列表集合
  *
  * @param user
  * @param page
  * @return
  */
 @RequestMapping("/user/list")
 public ModelAndView userList(@ModelAttribute User user, @ModelAttribute("page") PageEntity page) {
   ModelAndView modelandView = new ModelAndView();
   // 设置返回页面
   modelandView.setViewName(toUserList);
   try {
     // 设置分页 ,默认每页10
     this.setPage(page);
     // 查询学员列表
     List<User> list = userService.getUserListByCondition(user, this.getPage());
     // 把参数放到modelAndView中
     modelandView.addObject("list", list);
     modelandView.addObject("page", this.getPage());
   } catch (Exception e) {
     logger.error("AdminUserController.userList", e);
   }
   return modelandView;
 }
Exemplo n.º 9
0
  /**
   * 批量发送 系统消息
   *
   * @param request
   * @param content
   * @param cusId
   * @return
   */
  @RequestMapping(value = "/letter/sendSystemInfoByCusIds")
  @ResponseBody
  public Map<String, Object> sendSystemInfoByCusIds(
      @ModelAttribute User user,
      HttpServletRequest request,
      @ModelAttribute("page") PageEntity page) {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
      page.setPageSize(10000);
      // 查询学员列表
      List<User> list = userService.getUserListAndCourse(user, page);

      String content = request.getParameter("messsageContent"); // 发送系统消息的内容
      if (list == null || list.size() == 0) {
        map.put("message", "没有符合条件的会员");
      } else {
        List<MsgReceive> msgrcList = new ArrayList<MsgReceive>();
        for (int i = 0; i < list.size(); i++) {
          MsgReceive msgReceive1 = new MsgReceive();
          msgReceive1.setContent(content);
          msgReceive1.setAddTime(new Date());
          msgReceive1.setReceivingCusId(list.get(i).getId());
          msgReceive1.setStatus(LetterConstans.LETTER_STATUS_READ);
          msgReceive1.setType(LetterConstans.LETTER_TYPE_SYSTEMINFORM);
          msgReceive1.setUpdateTime(new Date());
          msgReceive1.setShowname("");
          msgReceive1.setCusId(0L);
          msgrcList.add(msgReceive1);
        }
        // 发送
        msgReceiveService.addMsgReceiveBatch(msgrcList);
        map.put("message", "success");
      }

    } catch (Exception e) {
      logger.error("AdminLetterAction.sendSystemInfoByCusIds", e);
      setExceptionRequest(request, e);
    }
    return map;
  }