コード例 #1
0
 /**
  * 添加栏目
  *
  * @param req
  * @param resp
  * @return
  * @throws Exception 2010-5-10
  */
 public String create(HkRequest req, HkResponse resp) {
   req.setAttribute("active_1", 1);
   long companyId = req.getLong("companyId");
   int ch = req.getInt("ch");
   if (ch == 0) {
     List<CmpFuncRef> funcreflist = this.cmpFuncService.getCmpFuncRefListByCompanyId(companyId);
     req.setAttribute("funcreflist", funcreflist);
     return this.getWebPath("admin/cmpnav/create.jsp");
   }
   String name = req.getHtmlRow("name");
   int reffunc = req.getInt("reffunc");
   byte showflg = req.getByte("showflg");
   CmpNav cmpNav = new CmpNav();
   cmpNav.setCompanyId(companyId);
   cmpNav.setName(name);
   cmpNav.setNlevel(CmpNav.NLEVEL_1);
   cmpNav.setReffunc(reffunc);
   cmpNav.setShowflg(showflg);
   cmpNav.setApplyformflg(req.getByte("applyformflg"));
   cmpNav.setFileShowflg(req.getByte("fileShowflg"));
   cmpNav.setFileShowLink(req.getString("fileShowLink"));
   cmpNav.setTitle(req.getHtmlRow("title"));
   cmpNav.setIntro(req.getHtml("intro"));
   cmpNav.setBgflg(req.getByte("bgflg"));
   int code = cmpNav.validate();
   if (code != Err.SUCCESS) {
     return this.onError(req, code, "createerror", null);
   }
   if (reffunc == CmpNav.REFFUNC_BBS || reffunc == CmpNav.REFFUNC_PRODUCT) {
     CmpNav o = this.cmpNavService.getCmpNavByCompanyIdAndReffunc(companyId, reffunc);
     if (o != null) {
       if (reffunc == CmpNav.REFFUNC_BBS) {
         return this.onError(req, Err.CMPNAV_REFFUNC_BBS_EXIST, "createerror", null);
       }
       return this.onError(req, Err.CMPNAV_REFFUNC_PRODUCT_EXIST, "createerror", null);
     }
   }
   if (cmpNav.getFileShowLink() != null
       && cmpNav.getFileShowLink().toLowerCase().startsWith("http://")) {
     cmpNav.setFileShowLink(cmpNav.getFileShowLink().substring(7));
   }
   File f = req.getFile("f");
   File bgFile = null;
   if (cmpNav.isBgSet()) {
     bgFile = req.getFile("bgf");
   }
   code = this.cmpNavProcessor.createCmpNav(cmpNav, f, bgFile);
   if (code != Err.SUCCESS) {
     if (code == Err.IMG_OUTOFSIZE_ERROR_FOR_SIZE) {
       return this.onError(req, code, new Object[] {"200k"}, "createerror", null);
     }
     return this.onError(req, code, "createerror", null);
   }
   this.setOpFuncSuccessMsg(req);
   return this.onSuccess2(req, "createok", cmpNav.getOid());
 }
コード例 #2
0
 /**
  * 修改栏目
  *
  * @param req
  * @param resp
  * @return
  * @throws Exception 2010-5-10
  */
 public String update(HkRequest req, HkResponse resp) {
   req.setAttribute("active_1", 1);
   long oid = req.getLongAndSetAttr("oid");
   CmpNav cmpNav = this.cmpNavService.getCmpNav(oid);
   req.setAttribute("cmpNav", cmpNav);
   int ch = req.getInt("ch");
   long companyId = req.getLong("companyId");
   if (ch == 0) {
     if (cmpNav.getKindId() > 0) {
       CmpStudyKind cmpStudyKind =
           this.cmpStudyKindService.getCmpStudyKind(companyId, cmpNav.getKindId());
       req.setAttribute("cmpStudyKind", cmpStudyKind);
     }
     List<CmpFuncRef> funcreflist = this.cmpFuncService.getCmpFuncRefListByCompanyId(companyId);
     req.setAttribute("funcreflist", funcreflist);
     return this.getWebPath("admin/cmpnav/update.jsp");
   }
   String name = req.getHtmlRow("name");
   int reffunc = req.getInt("reffunc");
   byte showflg = req.getByte("showflg");
   cmpNav.setName(name);
   cmpNav.setReffunc(reffunc);
   cmpNav.setShowflg(showflg);
   cmpNav.setApplyformflg(req.getByte("applyformflg"));
   cmpNav.setFileShowflg(req.getByte("fileShowflg"));
   cmpNav.setFileShowLink(req.getString("fileShowLink"));
   cmpNav.setTitle(req.getHtmlRow("title"));
   cmpNav.setIntro(req.getHtml("intro"));
   cmpNav.setBgflg(req.getByte("bgflg"));
   int code = cmpNav.validate();
   if (code != Err.SUCCESS) {
     return this.onError(req, code, "updateerror", null);
   }
   if (reffunc == CmpNav.REFFUNC_BBS || reffunc == CmpNav.REFFUNC_PRODUCT) {
     CmpNav o =
         this.cmpNavService.getCmpNavByCompanyIdAndReffunc(req.getLong("companyId"), reffunc);
     if (o != null && o.getOid() != cmpNav.getOid()) {
       if (reffunc == CmpNav.REFFUNC_BBS) {
         return this.onError(req, Err.CMPNAV_REFFUNC_BBS_EXIST, "updateerror", null);
       }
       return this.onError(req, Err.CMPNAV_REFFUNC_PRODUCT_EXIST, "updateerror", null);
     }
   }
   File bgFile = null;
   if (cmpNav.isBgSet()) {
     bgFile = req.getFile("bgf");
   }
   code = this.cmpNavProcessor.updateCmpNav(cmpNav, req.getFile("f"), bgFile);
   if (code != Err.SUCCESS) {
     if (code == Err.IMG_OUTOFSIZE_ERROR_FOR_SIZE) {
       return this.onError(
           req, Err.IMG_OUTOFSIZE_ERROR_FOR_SIZE, new Object[] {"200k"}, "updateerror", null);
     }
     return this.onError(req, code, "updateerror", null);
   }
   this.setOpFuncSuccessMsg(req);
   return this.onSuccess2(req, "updateok", null);
 }