Package com.ourlinc.activity.domain

Examples of com.ourlinc.activity.domain.Activity


  @Resource
  IActivityService activityService;

 
  public void testA() {
    Activity act = activityService.getActivity(-1);
    if (logger.isDebugEnabled()) {
      logger.debug(act.toString());
    }
  }
View Full Code Here


  String join(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    User user = (User) request.getSession().getAttribute("userLogin");
    String actId = request.getParameter("actId");
    int actIdI = Integer.valueOf(actId);
    Activity act = activityService.getActivity(actIdI);
    if (null == act) {
      request.setAttribute("errorMsg", "找不到id=" + actId + "的活动");
      return "error";
    }
    // 检查这个活动能不能参加
    if (activityService.isEditEnable(act.getId())) {
      // 用户能不能参加这个活动
      userService.joinActivity(user.getId(), actIdI);
      response.sendRedirect("/user/myact.jspx");
      return null;
    }
View Full Code Here

  String canceljoin(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    User user = (User) request.getSession().getAttribute("userLogin");
    String actId = request.getParameter("actId");
    int actIdI = Integer.valueOf(actId);
    Activity act = activityService.getActivity(actIdI);
    if (null == act) {
      request.setAttribute("errorMsg", "找不到id=" + actId + "的活动");
      return "error";
    }
    userService.cancelJoinActivity(user.getId(), actIdI);
View Full Code Here

   */
  @RequestMapping(value = "/cancel.jspx")
  String cancel(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    String actId = request.getParameter("actId");
    Activity act = activityService.getActivity(Integer.valueOf(actId));
    if (null == act) {
      request.setAttribute("errorMsg", "找不到id=" + actId + "的活动");
      return "error";
    }
    activityService.cancelActivity(act.getId());
    response.sendRedirect("sendemail.jspx?op=cancel&actId="
        + WebUtils.encodeUrl(String.valueOf(act.getId())));
    return null;
  }
View Full Code Here

      request.setAttribute("overDate", overDate);
      request.setAttribute("note", note);
      return "activity/addact";
    }
    // 发布活动
    Activity act = new Activity();
    act.setTitle(title);
    act.setTime(dTime);
    act.setPlace(place);
    act.setContent(content);
    act.setStartTime(dStartDate);
    act.setOverTime(dOverDate);
    act.setNote(note);
    activityService.addActivity(act);
    // 把人员添加到活动中
    Page rp = userService.listAllUser(1);
    for (User u : (List<User>) rp.getData()) {
      userService.joinActivity(u.getId(), act.getId());
    }
    // 重定向防止重复提交
    response.sendRedirect("sendemail.jspx?op=add&actId="
        + WebUtils.encodeUrl(String.valueOf(act.getId())));
    return null;

  }
View Full Code Here

    String op = request.getParameter("op");
    String[] toAddresses = request.getParameterValues("toAddresses");
    String smtpHost = EmailConfig.getValue("smtpHost");
    String needAuth = EmailConfig.getValue("needAuth");
    Page rp = userService.listAllUser(1);
    Activity act = activityService.getActivity(Integer.valueOf(actId));
    // 返回页面
    if (WebUtils.isEmptyString(email) || null == act) {
      request.setAttribute("actMsg", (null == act) ? "找不到该活动!" : "操作成功!");
      request.setAttribute("email", user.getEmail());
      request.setAttribute("actId", actId);
      request.setAttribute("list", rp);
      request.setAttribute("op", op);
      request.setAttribute("smtpHost", smtpHost);
      request.setAttribute("needAuth", needAuth);
      return "activity/sendemail";
    }
    // 发送邮件
    boolean flag = false;
    Mail mail = new Mail(email, password);
    try {
      if ("add".equals(op)) {
        mail.send(
            email,
            toAddresses,
            null,
            "活动通知",
            EmailTemplates.buildAddContent(act.getTime(),
                act.getTitle(), act.getId()));
      } else if ("edit".equals(op)) {
        mail.send(
            email,
            toAddresses,
            null,
            "活动修改通知",
            EmailTemplates.buildEditContent(act.getTime(),
                act.getTitle(),
                EmailConfig.getValue("editContent"),
                act.getId()));
      } else if ("cancel".equals(op)) {
        mail.send(
            email,
            toAddresses,
            null,
            "活动取消通知",
            EmailTemplates.buildCancelContent(act.getTime(),
                act.getTitle()));
      }
      flag = true;
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

  String postcomment(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    User user = (User) request.getSession().getAttribute("userLogin");
    String actId = request.getParameter("actId");
    String content = request.getParameter("content");
    Activity act = activityService.getActivity(Integer.valueOf(actId));
    if (null == act || null == content) {
      request.setAttribute("errorMsg", "找不到id=" + actId + "的活动");
      return "error";
    }
    content = WebUtils.escapeHTML(content);
    userService.postComment(user.getId(), act.getId(), content);
    response.sendRedirect("../activity/activity.jspx?actId="
        + URLEncoder.encode(actId, "utf-8"));
    return null;
  }
View Full Code Here

    String content = request.getParameter("content");
    String startDate = request.getParameter("startDate");
    String overDate = request.getParameter("overDate");
    String note = request.getParameter("note");
    String actId = request.getParameter("actId");
    Activity act = activityService.getActivity(Integer.valueOf(actId));
    if (null == act) {
      request.setAttribute("errorMsg", "找不到id=" + actId + "的活动");
      return "error";
    }
    List<User> userList = activityService.getActMembers(act.getId());
    if (null == title || null == time || null == place || null == content
        || null == startDate || null == overDate) {
      request.setAttribute("activity", act);
      request.setAttribute("userList", userList);
      return "activity/editact";
    }
    Date dTime = WebUtils.strFormatDateAndTime(time);
    // 报名开始时间不填表示用现在作为开始时间
    Date dStartDate = ("".equals(startDate)) ? WebUtils.getClearDate()
        : WebUtils.strFormatDateAndTime(startDate);
    Date dOverDate = WebUtils.strFormatDateAndTime(overDate);
    // 截止时间必须在现在时间之后
    if (new Date().after(dOverDate)) {
      request.setAttribute("activity", act);
      request.setAttribute("userList", userList);
      request.setAttribute("errorMsg", "截止时间必须在现在时间之后");
      return "activity/editact";
    }
    // 报名时间必须在截止时间之前
    if (dStartDate.after(dOverDate)) {
      request.setAttribute("activity", act);
      request.setAttribute("userList", userList);
      request.setAttribute("errorMsg", "报名时间必须在截止时间之前");
      return "activity/editact";
    }
    // 活动时间必须在截止之后
    if (dTime.before(dOverDate)) {
      request.setAttribute("activity", act);
      request.setAttribute("userList", userList);
      request.setAttribute("errorMsg", "活动时间必须在截止时间之后");
      return "activity/editact";
    }

    // 找出修改了的地方
    List<String> diff = findDifferent(act, title, dTime, place, content,
        note, dStartDate, dOverDate);
    if (diff.size() > 0) {
      String diff0 = listToStr(diff);
      // EmailUtils eu = new EmailUtils(act);
      // eu.setDifferent(diff);
      // System.out.print(diff0);
      act.setTitle(title);
      act.setTime(dTime);
      act.setPlace(place);
      act.setContent(content);
      act.setNote(note);
      act.setStartTime(dStartDate);
      act.setOverTime(dOverDate);
      activityService.updateActivity(act);
      // 把修改的内容记到文件吧
      try {
        EmailConfig.updateProperties("editContent", diff0);
      } catch (Exception e) {
        e.printStackTrace();
      }
      response.sendRedirect("sendemail.jspx?op=edit&actId="
          + WebUtils.encodeUrl(String.valueOf(act.getId())));
      return null;
    }
    response.sendRedirect("index.jspx");
    return null;
  }
View Full Code Here

   */
  @RequestMapping(value = "/activity.jspx")
  String activity(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    String actId = request.getParameter("actId");
    Activity act = activityService.getActivity(Integer.valueOf(actId));
    if (null == act) {
      request.setAttribute("errorMsg", "找不到id=" + actId + "的活动");
      return "error";
    }
    List<User> userList = activityService.getActMembers(act.getId());
    List<Comment> rp2 = activityService.listComment(Integer.valueOf(actId));
    request.setAttribute("userList", userList);
    request.setAttribute("commentList", rp2);
    request.setAttribute("activity", act);
    return "activity/activity";
View Full Code Here

    String op = request.getParameter("op");
    String id = request.getParameter("id");
    String condition = request.getParameter("condition");
    String inputText = WebUtils.toString(request.getParameter("inputText"))
        .trim();
    Activity act = activityService.getActivity(Integer.valueOf(actId));
    if (null == act) {
      request.setAttribute("errorMsg", "找不到id=" + actId + "的活动");
      return "error";
    }
    if ("add".equals(op)) {// 增加用户
      List<User> users = new ArrayList<User>();// 解决重名问题的策略:全加了
      if ("email".equals(condition)) {
        User dUser = userService
            .getUserByEmail(inputText.toLowerCase());
        if (null != dUser) {
          users.add(dUser);
        }
      } else if ("username".equals(condition)) {
        users = userService.getUserByUsername(inputText);
      }
      // 找不到人
      if (0 == users.size()) {
        request.setAttribute("errorMsg", "找不到" + condition + "为 "
            + inputText + " 人员");
        return "error";
      }
      // 这个活动能不能参加
      if (!activityService.isJoinEnable(act.getId())) {
        request.setAttribute("errorMsg", condition + "为 " + inputText
            + " 人员不能参加这个活动");
        return "error";
      }
      // 帮用户参加活动
      for (User u : users) {
        userService.joinActivity(u.getId(), act.getId());
      }
    } else if ("delete".equals(op)) {// 删除用户
      User dUser = userService.getUserById(Integer.valueOf(id));
      if (null != dUser) {
        userService.cancelJoinActivity(dUser.getId(), act.getId());
      }
    }
    List<User> u = activityService.getActMembers(act.getId());
    Page rp = new Page();
    rp.setData(u);
    int intp = WebUtils.toInt(p);
    rp.setNowpage(intp);
    request.setAttribute("activity", act);
View Full Code Here

TOP

Related Classes of com.ourlinc.activity.domain.Activity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.