📄 informationaddaction.java
字号:
package com.longtime.wap.module.information.web.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
import org.springframework.web.struts.DispatchActionSupport;
import com.longtime.wap.common.WapConstant;
import com.longtime.wap.frame.common.UserSessionVO;
import com.longtime.wap.model.Business;
import com.longtime.wap.module.information.common.DateUtil;
import com.longtime.wap.module.information.common.InformationConstant;
import com.longtime.wap.module.information.service.InformationService;
import com.longtime.wap.module.information.web.form.InformationAddForm;
import com.longtime.wap.module.information.web.form.InformationEditForm;
/**
* 处理添加信息请求
*
* @author bulc
* @date Nov 19, 2007
*/
public class InformationAddAction extends DispatchActionSupport {
private static final Log LOGGER =
LogFactory.getLog(InformationAddAction.class);
private InformationService informationService;
/**
* 注入服务对象
*
* @param informationService
* 服务对象
*/
public void setInformationService(InformationService informationService) {
this.informationService = informationService;
}
/**
* 处理显示所有业务的请求
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
@SuppressWarnings("unchecked")
public ActionForward listBusinesses(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
try {
UserSessionVO usVo = (UserSessionVO) request.getSession()
.getAttribute(WapConstant.USER_SESSION);
long cpId = 0;
if (usVo.getUserGroup() == 1) {
cpId = usVo.getCpId();
}
List businesses = informationService.getBusinesses(cpId);
List returnBusinesses = new ArrayList();
if (null != businesses && businesses.size() > 0) {
for (int i = 0; i < businesses.size(); i++) {
Business business = (Business) businesses.get(i);
if (!DateUtil.isOverDue(business.getPubDate(), business
.getDuration())) {
returnBusinesses.add(new LabelValueBean(business
.getBusinessName(), String.valueOf(business
.getBusinessId())));
}
}
}
request.setAttribute(InformationConstant.BUSINESSES,
returnBusinesses);
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return mapping.findForward("listBusinesses");
}
/**
* 处理进入新建信息页面的请求
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
public ActionForward getNewInformation(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
try {
InformationAddForm infoAddForm = (InformationAddForm) form;
Business business = informationService.getBusinessById(Long
.parseLong(infoAddForm.getBusinessId()));
InformationEditForm infoEditForm = new InformationEditForm();
infoEditForm.setBusinessName(business.getBusinessName());
infoEditForm.setBusinessId(String.valueOf(business
.getBusinessId()));
if (business.getCategory() == 0) {
infoEditForm.setDetailType("text");
} else if (business.getCategory() == 1) {
infoEditForm.setDetailType("music");
} else if (business.getCategory() == 2) {
infoEditForm.setDetailType("pic");
}
infoEditForm.setEditFlug("save");
request.setAttribute(InformationConstant.INFORMATION_EDIT_FORM,
infoEditForm);
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return mapping.findForward("detailInformation");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -