@RequestMapping("/Subjectmajor/addlist")
  @ResponseBody
  public Map<String, Object> addSubjectMajorByids(HttpServletRequest request) {
    try {
      String ids = request.getParameter("ids");
      Long subjectId = Long.parseLong(request.getParameter("subjectId"));
      Subject subject = new Subject();
      subject.setSubjectId(subjectId);
      subject = subjectService.getSubjectBySubjectId(subject);
      if (ObjectUtils.isNull(subject.getParentId()) || subject.getParentId().intValue() == 0) {
        this.setJson(false, "subjectIdError", null);
        return json;
      }
      ids = ids.replace(",", " ").trim().replace(" ", ",");
      if (ObjectUtils.isNotNull(ids)) {
        String[] idsArray = ids.split(",");
        List<SubjectMajor> subList = new ArrayList<SubjectMajor>();
        for (int i = 0; i < idsArray.length; i++) {
          SubjectMajor subjectMajor = new SubjectMajor();

          subjectMajor.setMajorid(Long.parseLong(idsArray[i]));
          subjectMajor.setSubjectid(subjectId);
          subList.add(subjectMajor);
        }
        subjectMajorService.addSubjectMajorBatch(subList);

        this.setJson(true, "success", null);
      }

    } catch (Exception e) {
      this.setJson(false, "error", null);
      logger.info("MagorController------addSubjectMajorByids");
    }
    return json;
  }
Example #2
0
 /*
  * 检查code是否核查不合法返回null
  */
 @Override
 public UserCode checkUserCode(String code) throws Exception {
   // 获取加密后的信息解密
   String msg = PurseSecurityUtils.decryption(code, CommonConstants.SecurityKey);
   // 解密后的json格式验证是否正确
   JsonParser jsonParser = new JsonParser();
   JsonObject jsonObject = jsonParser.parse(msg).getAsJsonObject();
   String createTime = jsonObject.get("createTime").getAsString();
   Long userId = jsonObject.get("userId").getAsLong();
   Long id = jsonObject.get("id").getAsLong();
   // 验证信息为空
   if (StringUtils.isEmpty(createTime) || ObjectUtils.isNull(userId) || ObjectUtils.isNull(id)) {
     return null;
   }
   UserCode userCode = userCodeDao.getUserCodeById(id);
   // 查询userCode 状态是否已经使用过
   if (ObjectUtils.isNotNull(userCode) && userCode.getStatus().longValue() == 0) {
     Calendar c = Calendar.getInstance();
     c.setTime(userCode.getCreateTime());
     c.add(Calendar.DAY_OF_MONTH, 3);
     if (new Date().getTime() > c.getTime().getTime()) { // 超过三天
       return null;
     }
     return userCode;
   }
   return null;
 }
Example #3
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;
  }
Example #4
0
  /**
   * 发送邮件
   *
   * @param request
   * @return
   */
  @RequestMapping("/user/sendEmailMsg")
  @ResponseBody
  public Map<String, Object> sendEmailMsg(HttpServletRequest request) {
    try {
      String linksman = request.getParameter("linksman"); // 获取联系人
      String title = request.getParameter("title"); // 获取标题
      String content = request.getParameter("content"); // 获取内容

      int type = Integer.valueOf(request.getParameter("type")); // 邮件类型
      String startTime = request.getParameter("startTime"); // 发送时间
      Date starttime = new Date();
      // 如果是定时短信发送时间要大于当前时间
      if (type == 2) {
        if ("".equals(startTime)) {
          this.setJson(false, "请输入发送时间", "");
          return json;
        }
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        starttime = formatDate.parse(startTime);
        if (!starttime.after(new Date())) {
          this.setJson(false, "定时发送的时间要大于当前日期", "");
          return json;
        }
      }

      if (StringUtils.isNotEmpty(linksman)
          && StringUtils.isNotEmpty(content)
          && StringUtils.isNotEmpty(title)) {
        // 验证邮箱
        Map<String, Object> returnMap = checkEmail(linksman);
        // 错误信息
        String errorEmail = returnMap.get("errorMessage").toString();
        if (Boolean.parseBoolean(returnMap.get("flag").toString()) == false) {
          this.setJson(false, errorEmail, "");
          return json;
        } else {
          JsonObject user = SingletonLoginUtils.getSysUser(request);
          List<UserEmailMsg> emailMsgList = new ArrayList<UserEmailMsg>();
          UserEmailMsg userEmailMsg = new UserEmailMsg();
          userEmailMsg.setId(0);
          userEmailMsg.setTitle(title);
          userEmailMsg.setContent(content);
          userEmailMsg.setEmail(returnMap.get("returnList").toString());
          userEmailMsg.setType(type);
          userEmailMsg.setSendTime(starttime);
          if (type == 1) {
            // 发送邮件
            userEmailMsgService.batchSendEmail(
                returnMap.get("returnList").toString().split(","), content, title, 3);
            // emailService.sendBatchMail(returnMap.get("returnList").toString().split(","),
            // content, title);
            userEmailMsg.setStatus(1);
          } else {
            userEmailMsg.setStatus(2);
          }
          if (ObjectUtils.isNotNull(user)) {
            userEmailMsg.setUserId(user.get("userId").getAsLong());
          } else {
            userEmailMsg.setUserId(0L);
          }
          userEmailMsg.setCreateTime(new Date());
          emailMsgList.add(userEmailMsg);
          userEmailMsgService.addUserEmailMsg(emailMsgList);
          errorEmail = "发送成功";
        }
        this.setJson(Boolean.parseBoolean(returnMap.get("flag").toString()), errorEmail, "");
      } else {
        this.setJson(false, "联系人、标题或内容不能为空", null);
      }
    } catch (Exception e) {
      logger.error("sendEmailMsg", e);
    }
    return json;
  }
Example #5
0
  /**
   * 发送短信
   *
   * @param request
   * @return
   */
  @RequestMapping("/user/sendMsg")
  @ResponseBody
  public Map<String, Object> sendMobileMsg(HttpServletRequest request) {
    try {

      List<UserMobileMsg> msgList = new ArrayList<UserMobileMsg>();

      String linksman = request.getParameter("linksman"); // 获取联系人
      String content = request.getParameter("content"); // 获取内容
      Integer type = Integer.parseInt(request.getParameter("sendType")); // 发送方式

      Date now = new Date();
      Date sendTime = now;
      if (type == 2) { // 定时发送

        if (StringUtils.isEmpty(request.getParameter("sendTime"))) {
          this.setJson(false, "定时发送时间不能为空", "");
          return json;
        }
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        sendTime = df.parse(request.getParameter("sendTime")); // 定时发送时间
      }
      if (StringUtils.isNotEmpty(linksman) && StringUtils.isNotEmpty(content)) {
        // 验证手机
        Map<String, Object> returnMap = checkMobile(linksman);
        // 错误信息
        String errorMobile = returnMap.get("errorMobile").toString();
        if (Boolean.parseBoolean(returnMap.get("flag").toString()) == false) {
          this.setJson(false, errorMobile, "");
          return json;
        } else {
          // 添加发送记录
          JsonObject user = SingletonLoginUtils.getSysUser(request);
          UserMobileMsg userMobileMsg = new UserMobileMsg();
          userMobileMsg.setSendTime(sendTime);
          if (type == 1) { // 正常发送
            userMobileMsg.setStatus(1);
          } else { // 定时发送
            userMobileMsg.setStatus(2);
          }
          userMobileMsg.setId(0);
          userMobileMsg.setType(type);

          userMobileMsg.setContent(content);
          userMobileMsg.setMobile(returnMap.get("mobileList").toString());
          if (ObjectUtils.isNotNull(user)) {
            userMobileMsg.setUserId(user.get("userId").getAsLong());
          } else {
            userMobileMsg.setUserId(0L);
          }
          userMobileMsg.setCreateTime(now);
          msgList.add(userMobileMsg);
          // 添加记录 暂不发送
          userMobileMsgService.addUserMobileMsg(msgList);
          if (type == 1) { // 正常发送
            userMobileMsgService.batchSendMobileMsg(
                content, returnMap.get("mobileList").toString().split(","), 3);
          }
          errorMobile = "发送成功";
        }
        this.setJson(Boolean.parseBoolean(returnMap.get("flag").toString()), errorMobile, "");
      } else {
        this.setJson(false, "联系人或内容不能为空", null);
      }
    } catch (Exception e) {
      logger.error("sendMobileMsg", e);
    }
    return json;
  }