topicpost

来源:互联网 发布:偏偏喜欢你续写淘宝 编辑:程序博客网 时间:2024/04/29 19:50
package com.zte.tbs.workroom.ui.web.workroomInfo.action; import java.math.BigInteger; import java.text.ParseException; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Vector; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.BeanUtils; import org.ecside.util.RequestUtil; import com.zte.ssb.framework.base.BaseAction; import com.zte.ssb.framework.base.util.PageInfo; import com.zte.ssb.framework.util.ApplicationGlobalResource; import com.zte.ssb.webcontainer.action.ActionForm; import com.zte.ssb.webcontainer.action.ActionForward; import com.zte.ssb.webcontainer.action.ActionMapping; import com.zte.tbs.workroom.access.workroomInfo.model.TbsTopicPost; import com.zte.tbs.workroom.access.workroomInfo.model.TbsWorkroom; import com.zte.tbs.workroom.business.workroomInfo.service.intf.ITbsCategoryDS; import com.zte.tbs.workroom.business.workroomInfo.service.intf.ITbsTopicPostDS; import com.zte.tbs.workroom.business.workroomInfo.service.intf.ITbsWorkroomDS; import com.zte.tbs.workroom.common.util.UtilConstants; import com.zte.tbs.workroom.common.util.UtilTools; import com.zte.tbs.workroom.ui.web.workroomInfo.form.TbsTopicPostForm; public final class TbsTopicPostAction extends BaseAction { public ActionForward preAdd(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("Entering 'preAdd' method"); } String wId = request.getParameter("workroomId"); BigInteger workroomId = BigInteger.valueOf(Long.parseLong(wId)); ITbsWorkroomDS workDS = (ITbsWorkroomDS)getBean("tbsWorkroomDS"); TbsWorkroom workroom = workDS.getTbsWorkroom(workroomId); ITbsCategoryDS cateDS = (ITbsCategoryDS)getBean("tbsCategoryDS"); List categoryList = cateDS.getTbsCategorys(workroomId); request.setAttribute("workroom", workroom); request.setAttribute("categoryList", categoryList); return mapping.findForward("addTopic"); } public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("Entering 'add' method"); } ApplicationGlobalResource appresource = ApplicationGlobalResource.getInstance(); HttpSession session = request.getSession(); String userId = session.getAttribute(appresource.getValueByKey(UtilConstants.USER_ID)).toString(); String userName = session.getAttribute(appresource.getValueByKey(UtilConstants.USER_ID)).toString(); TbsTopicPostForm tbsTopicPostForm = (TbsTopicPostForm)form; TbsTopicPost tbsTopicPostModel = new TbsTopicPost(); // �ж��ǻظ��������� if(UtilConstants.TOPIC_FLAG.equals(tbsTopicPostForm.getSegment1())) { this.webFromToModel(tbsTopicPostForm,tbsTopicPostModel); } else if(UtilConstants.RESPON_FLAG.equals(tbsTopicPostForm.getSegment1())) { this.webFromToModel(tbsTopicPostForm,tbsTopicPostModel); } else { request.setAttribute("addfail", "addfail"); } tbsTopicPostModel.setCreatedBy(userId); tbsTopicPostModel.setCreatedByName(userName); tbsTopicPostModel.setLastUpdatedBy(userId); tbsTopicPostModel.setCreateDate(new Date()); tbsTopicPostModel.setLastUpdateDate(new Date()); tbsTopicPostModel.setLastUpdatedByName(userName); ITbsTopicPostDS iTbsTopicPostDS = this.getTbsTopicPostService(); iTbsTopicPostDS.insertObject(tbsTopicPostModel); if (log.isInfoEnabled()) { log.info(tbsTopicPostForm.getPosttopic()+"create success!" ); } request.setAttribute("addsuccess", "addsuccess"); return mapping.findForward("listTopic"); } /** *
    *
  • �õ����� *
  • �������ڣ�2007-11-5 *
* @return void * @author wangyuqing */ private ITbsTopicPostDS getTbsTopicPostService() { return (ITbsTopicPostDS) getBean("tbsTopicPostDS"); } /** *
    *
  • formתʵ�� *
  • �������ڣ�2007-11-5 *
* @param tbsTopicPostForm * @param tbsTopicPostModel * @return void * @throws ParseException * @author wangyuqing */ private void webFromToModel(TbsTopicPostForm tbsTopicPostForm, TbsTopicPost tbsTopicPostModel) throws ParseException { String parentpostid = tbsTopicPostForm.getParentpostid(); tbsTopicPostModel.setParentpostid(null == parentpostid?BigInteger.ZERO:BigInteger.valueOf(Long.parseLong(parentpostid))); String topicId = tbsTopicPostForm.getTopicId(); tbsTopicPostModel.setTopicId(null == topicId?null:BigInteger.valueOf(Long.parseLong(topicId))); String categoryId = tbsTopicPostForm.getCategoryId(); tbsTopicPostModel.setCategoryId(null == categoryId?null:BigInteger.valueOf(Long.parseLong(categoryId))); String workroomid = tbsTopicPostForm.getWorkroomid(); tbsTopicPostModel.setCategoryId(null == workroomid?null:BigInteger.valueOf(Long.parseLong(workroomid))); String lvl = tbsTopicPostForm.getLvl(); tbsTopicPostModel.setLvl(null == lvl?null:BigInteger.valueOf(Long.parseLong(lvl))); tbsTopicPostModel.setPosttopic(tbsTopicPostForm.getPosttopic()); tbsTopicPostModel.setPostbody(tbsTopicPostForm.getPostbody()); tbsTopicPostModel.setPostcreationip(tbsTopicPostForm.getPostcreationip()); tbsTopicPostModel.setPostlasteditip(tbsTopicPostForm.getPostlasteditip()); String posteditcount = tbsTopicPostForm.getPosteditcount(); tbsTopicPostModel.setPosteditcount(null == posteditcount?null:BigInteger.valueOf(Long.parseLong(posteditcount))); String postformatoption = tbsTopicPostForm.getPostformatoption(); tbsTopicPostModel.setPostformatoption(null == postformatoption?null:BigInteger.valueOf(Long.parseLong(postformatoption))); String postoption = tbsTopicPostForm.getPostoption(); tbsTopicPostModel.setPostoption(null == postoption?null:BigInteger.valueOf(Long.parseLong(postoption))); String poststatus = tbsTopicPostForm.getPoststatus(); tbsTopicPostModel.setPoststatus(null == poststatus?null:BigInteger.valueOf(Long.parseLong(poststatus))); tbsTopicPostModel.setPosticon(tbsTopicPostForm.getPosticon()); String postattachcount = tbsTopicPostForm.getPostattachcount(); tbsTopicPostModel.setPostattachcount(null == postattachcount?null:BigInteger.valueOf(Long.parseLong(postattachcount))); tbsTopicPostModel.setEnabledFlag(tbsTopicPostForm.getEnabledFlag()); tbsTopicPostModel.setCreatedBy(tbsTopicPostForm.getCreatedBy()); tbsTopicPostModel.setCreatedByName(tbsTopicPostForm.getCreatedByName()); tbsTopicPostModel.setLastUpdatedBy(tbsTopicPostForm.getLastUpdatedBy()); tbsTopicPostModel.setLastUpdatedBy(tbsTopicPostForm.getLastUpdatedByName()); tbsTopicPostModel.setCreateDate(tbsTopicPostModel.getCreateDate()); tbsTopicPostModel.setLastUpdateDate(new Date()); tbsTopicPostModel.setSegment1(tbsTopicPostForm.getSegment1()); tbsTopicPostModel.setSegment2(tbsTopicPostForm.getSegment2()); tbsTopicPostModel.setSegment3(tbsTopicPostForm.getSegment3()); tbsTopicPostModel.setSegment4(tbsTopicPostForm.getSegment4()); tbsTopicPostModel.setSegment5(tbsTopicPostForm.getSegment5()); } public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("Entering 'delete' method"); } //todo delete operation return mapping.findForward("viewTbsTopicPosts"); } public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("Entering 'edit' method"); } //todo edit operation return mapping.findForward("edit"); } public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("Entering 'search' method"); } /*PageInfo pageInfo = new PageInfo(); int size = RequestUtil.getCurrentRowsDisplayed(request); int pageNum = RequestUtil.getPageNo(request); int totalrow = RequestUtil.getTotalRowsFromRequest(request); if (size == 0) { size = UtilConstants.PAGE_SIZE; } String posttopic = request.getParameter("posttopic"); String workroomid = request.getParameter("workroomid"); String createdByName = request.getParameter("createdByName"); String oneType = request.getParameter("oneType"); String twoType = request.getParameter("twoType"); String threeType = request.getParameter("threeType"); TbsTopicPostForm tbsTopicPostForm = new TbsTopicPostForm(); tbsTopicPostForm.setPostid(posttopic); tbsTopicPostForm.setWorkroomid(workroomid); tbsTopicPostForm.setCreatedByName(createdByName); tbsTopicPostForm.setOneType(oneType); tbsTopicPostForm.setOneType(twoType); tbsTopicPostForm.setOneType(threeType); List tbsTopicPostLst = new ArrayList(); // ��ѯ�Ҵ����� if(UtilConstants.MY_CREATE.equals(oneType)) { pageInfo = this.getTbsTopicPostService().advanceQry(tbsTopicPostForm, pageNum, size); } // ��ѯ�ҳ��͵� else if(UtilConstants.MY_COPY.equals(oneType)) { pageInfo = this.getTbsTopicPostService().advanceQry(tbsTopicPostForm, pageNum, size); } else { pageInfo = this.getTbsTopicPostService().advanceQry(tbsTopicPostForm, pageNum, size); } totalrow = (int) pageInfo.getTotalCount(); int page = (int) pageInfo.getTotalPageCount(); List tbsTopicPostList = (List) pageInfo.getResult(); Iterator iterator = tbsTopicPostList.iterator(); while (iterator.hasNext()) { TbsTopicPost tbsTopicPostModel = (TbsTopicPost) iterator .next(); } // �޼�¼ if (totalrow == 0) { request.setAttribute("queryFail","queryFail"); return mapping.findForward("serachTopic"); } else { request.setAttribute("tbsTopicPostList", tbsTopicPostList); request.setAttribute("totalRows", totalrow); request.setAttribute("totalpages", new Integer(page)); }*/ List tbsTopicPostList = new ArrayList(); for(int i =0;i<1;i++) { TbsTopicPost tbsTopicPost0 = new TbsTopicPost(); tbsTopicPost0.setPostid(BigInteger.valueOf(Long.parseLong("40"))); tbsTopicPost0.setParentpostid(BigInteger.ONE); tbsTopicPost0.setTopicId(BigInteger.ONE); tbsTopicPost0.setCategoryId(BigInteger.ONE); tbsTopicPost0.setWorkroomid(BigInteger.ONE); tbsTopicPost0.setLvl(BigInteger.ONE); tbsTopicPost0.setPosttopic("我的主题王毓清"); tbsTopicPost0.setPostbody("我的主题的内"); tbsTopicPost0.setPostcreationip("10.40.54.136"); tbsTopicPost0.setPostattachcount(BigInteger.ONE); tbsTopicPost0.setPosteditcount(BigInteger.ONE); tbsTopicPost0.setCreatedBy("404085"); tbsTopicPost0.setCreateDate(new Date()); tbsTopicPost0.setCreatedByName("王毓清"); tbsTopicPost0.setPosticon("Y"); tbsTopicPostList.add(tbsTopicPost0); /* TbsTopicPost tbsTopicPost01 = new TbsTopicPost(); tbsTopicPost01.setPostid(BigInteger.valueOf(Long.parseLong("01"))); tbsTopicPost01.setParentpostid(BigInteger.valueOf(Long.parseLong("40"))); tbsTopicPost01.setTopicId(BigInteger.valueOf(Long.parseLong("40"))); tbsTopicPost01.setCategoryId(BigInteger.ONE); tbsTopicPost01.setWorkroomid(BigInteger.ONE); tbsTopicPost01.setLvl(BigInteger.ONE); tbsTopicPost01.setPosttopic("我的回复王毓清1"); tbsTopicPost01.setPostbody("我的回复王毓清1"); tbsTopicPost01.setPostcreationip("10.40.54.136"); tbsTopicPost01.setPostattachcount(BigInteger.ONE); tbsTopicPost01.setPosteditcount(BigInteger.ONE); tbsTopicPost01.setCreatedBy("404085"); tbsTopicPost01.setCreateDate(new Date()); tbsTopicPost01.setCreatedByName("王毓清"); tbsTopicPostList.add(tbsTopicPost01); TbsTopicPost tbsTopicPost02 = new TbsTopicPost(); tbsTopicPost02.setPostid(BigInteger.valueOf(Long.parseLong("01"))); tbsTopicPost02.setParentpostid(BigInteger.valueOf(Long.parseLong("40"))); tbsTopicPost02.setTopicId(BigInteger.valueOf(Long.parseLong("40"))); tbsTopicPost02.setCategoryId(BigInteger.ONE); tbsTopicPost02.setWorkroomid(BigInteger.ONE); tbsTopicPost02.setLvl(BigInteger.ONE); tbsTopicPost02.setPosttopic("我的回复王毓清3"); tbsTopicPost02.setPostbody("我的回复王毓清2"); tbsTopicPost02.setPostcreationip("10.40.54.136"); tbsTopicPost02.setPostattachcount(BigInteger.ONE); tbsTopicPost02.setPosteditcount(BigInteger.ONE); tbsTopicPost02.setCreatedBy("404085"); tbsTopicPost02.setCreateDate(new Date()); tbsTopicPost02.setCreatedByName("王毓清"); tbsTopicPostList.add(tbsTopicPost02);*/ TbsTopicPost tbsTopicPost1 = new TbsTopicPost(); tbsTopicPost1.setPostid(BigInteger.TEN); tbsTopicPost1.setParentpostid(BigInteger.ZERO); tbsTopicPost1.setTopicId(BigInteger.ZERO); tbsTopicPost1.setCategoryId(BigInteger.ZERO); tbsTopicPost1.setWorkroomid(BigInteger.ZERO); tbsTopicPost1.setLvl(BigInteger.valueOf(2)); tbsTopicPost1.setPosttopic("我的主题全景明"); tbsTopicPost1.setPostbody("我的主题的内容全景明"); tbsTopicPost1.setPostcreationip("10.40.54.136"); tbsTopicPost1.setPostattachcount(BigInteger.ZERO); tbsTopicPost1.setPosteditcount(BigInteger.ZERO); tbsTopicPost1.setCreatedBy("404085"); tbsTopicPost1.setCreateDate(new Date()); tbsTopicPost1.setCreatedByName("全景明"); tbsTopicPost1.setPosticon("N"); tbsTopicPostList.add(tbsTopicPost1); } request.removeAttribute("tbsTopicPostList"); request.setAttribute("totalRows", 2); request.setAttribute("tbsTopicPostList", tbsTopicPostList); return mapping.findForward("listTopic"); } public TbsTopicPost getTbsTopicPostFromForm(ActionForm tbsTopicPostForm) throws Exception { TbsTopicPost tbsTopicPost = new TbsTopicPost(); BeanUtils.copyProperties(tbsTopicPost, tbsTopicPostForm); return tbsTopicPost; } /** *
    *
  • ������ʼ�� *
  • �������ڣ�2007-11-5 *
* @param mapping * @param form * @param request * @param response * @return * @throws Exception * @return ActionForward */ public ActionForward initAdd(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("Entering 'initAdd' method"); } return mapping.findForward("list"); } }
原创粉丝点击