/** * 添加栏目 * * @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()); }
/** * 添加栏目 * * @param req * @param resp * @return * @throws Exception 2010-5-10 */ public String create2(HkRequest req, HkResponse resp) { req.setAttribute("active_1", 1); long parentId = req.getLongAndSetAttr("parentId"); long companyId = req.getLong("companyId"); int ch = req.getInt("ch"); if (ch == 0) { CmpNav parent = this.cmpNavService.getCmpNav(parentId); req.setAttribute("parent", parent); List<CmpFuncRef> funcreflist = this.cmpFuncService.getCmpFuncRefListByCompanyId(companyId); req.setAttribute("funcreflist", funcreflist); return this.getWebPath("admin/cmpnav/create2.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_2); cmpNav.setReffunc(reffunc); cmpNav.setShowflg(showflg); cmpNav.setParentId(parentId); cmpNav.setApplyformflg(req.getByte("applyformflg")); cmpNav.setTitle(req.getHtmlRow("title")); cmpNav.setIntro(req.getHtml("intro")); cmpNav.setUrl(req.getHtmlRow("url")); 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); } } code = this.cmpNavProcessor.createCmpNav(cmpNav, null, req.getFile("bgf")); 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"}, "createerror", null); } return this.onError(req, code, "createerror", null); } this.setOpFuncSuccessMsg(req); return this.onSuccess2(req, "createok", cmpNav.getOid()); }