예제 #1
0
 /**
  * 验证项目是否ok
  *
  * @param contextPath 项目路径
  */
 public static boolean isdomainok(String contextPath, String securityKey, String domiankey) {
   try {
     if (contextPath.indexOf("127.0.") > -1 || contextPath.indexOf("192.168.") > -1) {
       return true;
     }
     String dedomaininfo = PurseSecurityUtils.decryption(domiankey, securityKey);
     Gson gson = new Gson();
     JsonParser jsonParser = new JsonParser();
     JsonObject jsonObject = jsonParser.parse(dedomaininfo).getAsJsonObject();
     Map<String, String> map =
         gson.fromJson(jsonObject, new TypeToken<Map<String, String>>() {}.getType());
     String domain = map.get("domain");
     if (contextPath.indexOf(domain) < 0) {
       System.exit(2);
       return false;
     }
     String dt = map.get("dt");
     if (com.yizhilu.os.core.util.StringUtils.isNotEmpty(dt)) {
       Date t = DateUtils.toDate(dt, "yyyy-MM-dd");
       if (t.compareTo(new Date()) < 0) {
         System.exit(3);
         return false;
       }
     }
     return true;
   } catch (Exception e) {
     return false;
   }
 }
예제 #2
0
 /**
  * 获取的专业下的科目
  *
  * @param request
  * @return
  */
 @RequestMapping("/subjectmajor/getmajor")
 @ResponseBody
 public Map<String, Object> getMajor(HttpServletRequest request) {
   try {
     String subjectId = request.getParameter("subjectId");
     if (StringUtils.isNotEmpty(subjectId)) {
       SubjectMajor query = new SubjectMajor();
       query.setSubjectid(Long.parseLong(subjectId));
       List<SubjectMajor> list = subjectMajorService.querySubjectMajorList(query);
       this.setJson(true, null, list);
     } else {
       this.setJson(false, null, null);
     }
   } catch (Exception e) {
     // TODO: handle exception
     logger.info("SubjectMajorController.getMajor---error", e);
     this.setJson(false, null, null);
   }
   return json;
 }
예제 #3
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;
  }
예제 #4
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;
  }