📄 manageaction.java
字号:
GenericVO gvo = new GoodsMgr().getGoodsDetail(goodsId);
//得到相关商品
request.setAttribute("bean", gvo);
return mapping.findForward("toGoodsDetail");
}
public ActionForward toOOGoodsAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
//设置查询条件
GenericVO gvo = new GenericVO();
ListVO lvo = new ListVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo\uFFFD?
lvo.setItemsPerPage(30);
lvo = AppUtil.processListVO(lvo, request); //设置ListVO
gvo.setListVO(lvo);
//查询数据
lvo = new GoodsMgr().searchGoods(gvo);
gvo.setListVO(lvo);
//设置页面数据
request.setAttribute("bean", gvo);
return mapping.findForward("toOOGoodsAdd");
}
public ActionForward doOOGoodsAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
String[] goodIds = request.getParameterValues("good_id");
GoodsMgr gm = new GoodsMgr();
GenericVO gvo = new GenericVO();
for (int i = 0; i < goodIds.length; i++) {
gvo.add("GOODS_ID", request.getParameter("goods_id"));
gvo.add("RELATEGOODS_ID", goodIds[i]);
gm.addOOGoods(gvo);
}
return mapping.findForward("doOOGoodsAdd");
}
public ActionForward doOOGoodsDelete(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
new GoodsMgr().deleteOOGoods(BaseUtil.toInt(request.getParameter("id")));
return mapping.findForward("doOOGoodsAdd");
}
public ActionForward toGoodsModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
return mapping.findForward("toGoodsModify");
}
public ActionForward doGoodsModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
try {
//上传图片
// 新建�?个SmartUpload对象
SmartUpload su = new SmartUpload();
// 上传初始�?
su.initialize(request.getSession().getServletContext(),
(HttpServletRequest) request,
(HttpServletResponse) response);
// 设定上传限制
// 1.限制每个上传文件的最大长度�??
su.setMaxFileSize(10000000);
// 2.限制总上传数据的长度�?
// su.setTotalMaxFileSize(20000);
// 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件�?
su.setAllowedFilesList("jpg,gif,JPG,GIF");
// 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp, htm, html扩展名的文件和没有扩展名的文�? �?
// su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
// 上传文件
su.upload();
// 将上传文件全部保存到指定目录
su.save("/images/goodsphotoes");
// 逐一提取上传文件信息,同时可保存文件�?
for (int i = 0; i < su.getFiles().getCount(); i++) {
SmartFile file = su.getFiles().getFile(i);
SmartRequest sr = su.getRequest();
String goodsId = sr.getParameter("goods_id");
String name = sr.getParameter("name");
String brandId = sr.getParameter("brand_id");
String goodsTypeId = sr.getParameter("goodstype_id");
String goodsTypeId2 = sr.getParameter("goodstype_id2");
String price1 = sr.getParameter("price1");
String price2 = sr.getParameter("price2");
String dot = sr.getParameter("dot");
String weight = sr.getParameter("weight");
String kucun = sr.getParameter("kucun");
String description = sr.getParameter("description");
GenericVO gvo = new GenericVO();
// 若文件不存在则继�?
if (!file.isMissing()) {
//得到文件�?
String fileName = su.getFileNames()[i];
//生成缩小图片
ImgUtil iutil = new ImgUtil();
String tfileName = fileName.substring(0,
fileName.indexOf(".")) +
"_s." + file.getFileExt();
iutil.reduce(getServlet().getServletContext().getRealPath(
"/") +
fileName,
getServlet().getServletContext().getRealPath(
"/") +
tfileName, 125, 125);
gvo.add("PHOTO", fileName);
gvo.add("SPHOTO", tfileName);
}
gvo.add("GOODS_ID", goodsId);
gvo.add("NAME", name);
gvo.add("BRAND_ID", brandId);
gvo.add("GOODSTYPE_ID", goodsTypeId);
gvo.add("GOODSTYPE_ID2", goodsTypeId2);
gvo.add("PRICE1", price1);
gvo.add("PRICE2", price2);
gvo.add("DOT", dot);
gvo.add("WEIGHT", weight);
gvo.add("KUCUN", kucun);
gvo.add("DESCRIPTION", description);
new GoodsMgr().modifyGoods(gvo);
request.setAttribute("GOODS_ID", "" + goodsId);
}
} catch (Exception ex) {
ex.printStackTrace();
throw new AppException(ex);
}
return mapping.findForward("doGoodsModify");
}
//商品分类
public ActionForward toCategoryManage(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
Vector result = new GoodsMgr().getTopGoodsType();
request.setAttribute("RESULT", result);
return mapping.findForward("toCategoryManage");
}
public ActionForward toCategoryAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
Vector pid = new GoodsMgr().getTopGoodsType();
request.setAttribute("RESULT", pid);
return mapping.findForward("toCategoryAdd");
}
public ActionForward doCategoryAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo
new GoodsMgr().addGoodsType(gvo);
//重新生成首页商品分类列表
this.genIndexCate();
return mapping.findForward("doCategoryAdd");
}
public ActionForward toCategoryModify(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO tvo = new GoodsMgr().getGoodsTypeDetail(BaseUtil.toInt(
request.getParameter("goodstype_id")));
request.setAttribute("bean", tvo);
return mapping.findForward("toCategoryModify");
}
public ActionForward doCategoryModify(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo
new GoodsMgr().modifyGoodsType(gvo);
//重新生成首页商品分类列表
this.genIndexCate();
return mapping.findForward("doCategoryModify");
}
public ActionForward doCategoryDelete(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
int r = new GoodsMgr().deleteGoodsType(BaseUtil.toInt(request.
getParameter("goodstype_id")));
request.setAttribute("RESULT", r + "");
//重新生成首页商品分类列表
this.genIndexCate();
return mapping.findForward("doCategoryDelete");
}
//品牌
public ActionForward toBrand(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
Vector r = new GoodsMgr().getBrand();
request.setAttribute("RESULT", r);
return mapping.findForward("toBrand");
}
public ActionForward toBrandAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
return mapping.findForward("toBrandAdd");
}
public ActionForward doBrandAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo
new GoodsMgr().addBrand(gvo);
return mapping.findForward("doBrandAdd");
}
public ActionForward toBrandModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO bvo = new GoodsMgr().getBrandDetail(BaseUtil.toInt(request.
getParameter("brand_id")));
request.setAttribute("bean", bvo);
return mapping.findForward("toBrandModify");
}
public ActionForward doBrandDelete(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
new GoodsMgr().deleteBrand(BaseUtil.toInt(request.getParameter(
"brand_id")));
request.setAttribute("BRAND_ID", request.getParameter("brand_id"));
return mapping.findForward("doBrandDelete");
}
public ActionForward doBrandModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo
new GoodsMgr().modifyBrand(gvo);
return mapping.findForward("doBrandModify");
}
public ActionForward toLogo1Modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO bvo = new GoodsMgr().getBrandDetail(BaseUtil.toInt(request.
getParameter("brand_id")));
request.setAttribute("bean", bvo);
return mapping.findForward("toLogo1Modify");
}
public ActionForward doLogo1Modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -