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;
}