Exemple #1
0
  @Override
  @Success(path = "/WEB-INF/pages/freeze/team/viewAdd.jsp")
  @Fail(path = "/WEB-INF/pages/freeze/team/viewAdd.jsp")
  public String add(HttpServletRequest req, HttpServletResponse resp) {
    int userID = param(req, "userID", -1);
    String headimage = param(req, "headimage");
    int start = param(req, "start", 0);
    int end = param(req, "end", 0);

    Team model = new Team();
    model.setUserID(userID);
    model.setHeadimage(headimage);
    model.setStart(start);
    model.setEnd(end);

    User user = new User();
    setAttr(req, PAGE_TEAM_USER_LIST_KEY, user.listAll(" order by username desc"));

    setAttr(req, MODEL, model);

    if (StringUtils.isBlank(headimage)) {
      setAttr(req, TIP_NAME_KEY, "请上传用户头像");
      return FAIL;
    }
    if (userID == -1) {
      setAttr(req, TIP_NAME_KEY, "请选择用户");
      return FAIL;
    }
    if (model.existProperty("userID", userID)) {
      setAttr(req, TIP_NAME_KEY, "此用户已在管理团队中,如需要更改请选择编辑功能");
      return FAIL;
    }
    if (start == 0) {
      setAttr(req, TIP_NAME_KEY, "请选择任期开始时间");
      return FAIL;
    }
    if (end == 0) {
      setAttr(req, TIP_NAME_KEY, "请选择任期结束时间");
      return FAIL;
    }
    if (start > end) {
      setAttr(req, TIP_NAME_KEY, "任期开始时间必须小于结束时间");
      model.setEnd(start);
      return FAIL;
    }
    if (model.save() > 0) {
      setAttr(req, TIP_NAME_KEY, "添加管理团队成员成功");
      model.setUserID(-1);
      model.setHeadimage("");
      model.setStart(0);
      model.setEnd(0);
      return SUCCESS;
    } else {
      setAttr(req, TIP_NAME_KEY, "添加管理团队成员失败");
      return FAIL;
    }
  }
Exemple #2
0
  @Override
  @Success(path = "/WEB-INF/pages/freeze/team/viewModify.jsp")
  @Fail(path = "/WEB-INF/pages/freeze/team/viewModify.jsp")
  public String modify(HttpServletRequest req, HttpServletResponse resp) {
    int id = param(req, "id", 0);

    String headimage = param(req, "headimage");
    int start = param(req, "start", 0);
    int end = param(req, "end", 0);

    Team model = new Team();
    model = model.get(id);

    User user = new User();
    setAttr(req, PAGE_TEAM_USER_LIST_KEY, user.listAll(" order by username desc"));

    if (StringUtils.equals(headimage, model.getHeadimage())
        && start == model.getStart()
        && end == model.getEnd()) {
      setAttr(req, TIP_NAME_KEY, "无任何变更");
      setAttr(req, MODEL, model);
      return FAIL;
    }
    model.setHeadimage(headimage);
    model.setStart(start);
    model.setEnd(end);

    setAttr(req, MODEL, model);
    if (StringUtils.isBlank(headimage)) {
      setAttr(req, TIP_NAME_KEY, "请先上传用户头像");
      return FAIL;
    }
    if (start == 0) {
      setAttr(req, TIP_NAME_KEY, "请选择任期开始时间");
      return FAIL;
    }
    if (end == 0) {
      setAttr(req, TIP_NAME_KEY, "请选择任期结束时间");
      return FAIL;
    }
    if (start > end) {
      setAttr(req, TIP_NAME_KEY, "任期开始时间必须小于结束时间");
      model.setEnd(start);
      return FAIL;
    }
    if (model.save() > 0) {
      setAttr(req, TIP_NAME_KEY, "编辑管理团队成员成功");
      return SUCCESS;
    } else {
      setAttr(req, TIP_NAME_KEY, "编辑管理团队成员失败");
      return FAIL;
    }
  }