📄 huankemsgaction.java
字号:
package com.redmoon.forum.plugin.huanke;import javax.servlet.*;import javax.servlet.http.*;import cn.js.fan.util.*;import com.redmoon.forum.*;import com.redmoon.forum.plugin.base.*;import com.redmoon.kit.util.*;import org.apache.log4j.*;import java.sql.Timestamp;public class HuankeMsgAction implements IPluginMsgAction { Logger logger = Logger.getLogger(this.getClass().getName()); public HuankeMsgAction() { } public synchronized boolean editTopic(ServletContext application, HttpServletRequest request, MsgDb md, FileUpload fu) throws ErrMsgException { HuankeGoodsDb hgd = new HuankeGoodsDb(); hgd = hgd.getHuankeGoodsDb(md.getId()); String catalogCode = fu.getFieldValue("catalogCode"); if (catalogCode.equals("") || catalogCode.length() > 50 || catalogCode.equals("not")) { throw new ErrMsgException("物品类别不能为空!"); } String goods = fu.getFieldValue("goods"); if (goods.equals("") || goods.length() > 200) { throw new ErrMsgException("物品名称不能为空或长度超长!"); } String depreciation = fu.getFieldValue("depreciation"); if (depreciation.equals("")) { throw new ErrMsgException("物品新旧程度不能为空!"); } String contact = fu.getFieldValue("contact"); if (contact.equals("") || contact.length() > 100) { throw new ErrMsgException("联系方式不能为空或长度超长!"); } String province = fu.getFieldValue("province"); if (province.equals("") || province.length() > 100) { throw new ErrMsgException("交换的物品地点不能为空或长度超长!"); } String price = fu.getFieldValue("price"); if (price.length() > 20) { throw new ErrMsgException("换品估价长度超长!"); } String exchangeProvince = fu.getFieldValue("exchangeProvince"); if (exchangeProvince.equals("") || exchangeProvince.length() > 255) { throw new ErrMsgException("交换地点不能为空或长度超长!"); } String exchangeCondition = fu.getFieldValue("exchangeCondition"); if (exchangeCondition.equals("") || exchangeCondition.length() > 100) { throw new ErrMsgException(HuankeSkin.LoadString(request, "交换条件不能为空!")); } String exchangeCatalogCode = "", exchangeGoods = ""; if(exchangeCondition.equals("detail")){ exchangeCatalogCode = fu.getFieldValue("exchangeCatalogCode"); if (exchangeCatalogCode.equals("") || exchangeCatalogCode.length() > 50) { throw new ErrMsgException("想交换的物品类型不能为空或长度超长!"); } exchangeGoods = fu.getFieldValue("exchangeGoods"); if (exchangeGoods.equals("") || exchangeGoods.length() > 200) { throw new ErrMsgException("想交换的换品名称不能为空或长度超长!"); } } String exchangeDescription = fu.getFieldValue("exchangeDescription"); Privilege privilege = new Privilege(); String userName = privilege.getUser(request); hgd.setCatalogCode(catalogCode); hgd.setGoods(goods); hgd.setDepreciation(depreciation); hgd.setContact(contact); hgd.setProvince(province); hgd.setPrice(price); hgd.setExchangeProvince(exchangeProvince); hgd.setExchangeCondition(exchangeCondition); hgd.setExchangeGoods(exchangeGoods); hgd.setExchangeDescription(exchangeDescription); hgd.setExchangeCatalogCode(exchangeCatalogCode); try { return hgd.save(); } catch (ResKeyException ex) { return false; } } public boolean AddNew(ServletContext application, HttpServletRequest request, MsgDb md, FileUpload fu) throws ErrMsgException { String catalogCode = fu.getFieldValue("catalogCode"); if (catalogCode.equals("") || catalogCode.length() > 50 || catalogCode.equals("not")) { throw new ErrMsgException("物品类别不能为空!"); } String goods = fu.getFieldValue("goods"); if (goods.equals("") || goods.length() > 200) { throw new ErrMsgException("物品名称不能为空或长度超过200!"); } String depreciation = fu.getFieldValue("depreciation"); if (depreciation.equals("")) { throw new ErrMsgException("物品新旧程度不能为空!"); } String contact = fu.getFieldValue("contact"); if (contact.equals("") || contact.length() > 100) { throw new ErrMsgException("联系方式不能为空或长度超过100!"); } String province = fu.getFieldValue("province"); if (province.equals("") || province.length() > 100) { throw new ErrMsgException("交换的物品地点不能为空或长度超过100!"); } String price = fu.getFieldValue("price"); if (price.length() > 20) { throw new ErrMsgException("换品估价长度超过20!"); } String exchangeProvince = fu.getFieldValue("exchangeProvince"); if (exchangeProvince.equals("") || exchangeProvince.length() > 255) { throw new ErrMsgException("交换地点不能为空或长度超过255!"); } String exchangeCondition = fu.getFieldValue("exchangeCondition"); if (exchangeCondition.equals("") || exchangeCondition.length() > 100) { throw new ErrMsgException(HuankeSkin.LoadString(request, "交换条件不能为空!")); } String exchangeCatalogCode = "", exchangeGoods = "", exchangeDescription = ""; if(exchangeCondition.equals("detail")){ exchangeCatalogCode = fu.getFieldValue("exchangeCatalogCode"); if (exchangeCatalogCode.equals("") || exchangeCatalogCode.length() > 50) { throw new ErrMsgException("想交换的物品类型不能为空或长度超过50!"); } exchangeGoods = fu.getFieldValue("exchangeGoods"); if (exchangeGoods.equals("") || exchangeGoods.length() > 200) { throw new ErrMsgException("想交换的换品名称不能为空或长度超过200!"); } exchangeDescription = fu.getFieldValue("exchangeDescription"); } Privilege privilege = new Privilege(); String userName = privilege.getUser(request); HuankeGoodsDb hgd = new HuankeGoodsDb(); hgd.setMsgRootId(md.getId()); hgd.setCatalogCode(catalogCode); hgd.setGoods(goods); hgd.setDepreciation(depreciation); hgd.setContact(contact); hgd.setProvince(province); hgd.setPrice(price); hgd.setExchangeProvince(exchangeProvince); hgd.setExchangeCondition(exchangeCondition); hgd.setExchangeGoods(exchangeGoods); hgd.setExchangeDescription(exchangeDescription); hgd.setExchangeCatalogCode(exchangeCatalogCode); hgd.setUserName(userName); return hgd.create(); } public boolean AddQuickReply(ServletContext application, HttpServletRequest request, long replyMsgId) throws ErrMsgException { int replyType = ParamUtil.getInt(request, "replyType"); Privilege privilege = new Privilege(); String userName = privilege.getUser(request); HuankeReplyDb hrd = new HuankeReplyDb(); if(replyType == HuankeReplyDb.REPLY_TYPE_EXCHANGE){ String exchangeGoods = ParamUtil.get(request, "exchangeGoods"); if (exchangeGoods.equals("") || exchangeGoods.length() > 200) { throw new ErrMsgException("交换的换品名称不能为空或长度不能超过200!"); } String exchangeDepreciation = ParamUtil.get(request, "exchangeDepreciation"); if (exchangeDepreciation.equals("") || exchangeDepreciation.length() > 20) { throw new ErrMsgException("新旧程度不能为空或长度不能超过20!"); } String exchangeProvince = ParamUtil.get(request, "exchangeProvince"); if (exchangeProvince.equals("") || exchangeProvince.length() > 255) { throw new ErrMsgException("交换地点不能为空或长度不能超过255!"); } String contact = ParamUtil.get(request, "contact"); if (contact.equals("") || contact.length() > 100) { throw new ErrMsgException("联系方式不能为空或长度不能超过100!"); } hrd.setMsgId(replyMsgId); hrd.setReplyType(replyType); hrd.setExchangeGoods(exchangeGoods); hrd.setExchangeDepreciation(exchangeDepreciation); hrd.setExchangeProvince(exchangeProvince); hrd.setContact(contact); hrd.setExchangeUserName(userName); }else{ hrd.setMsgId(replyMsgId); hrd.setReplyType(replyType); hrd.setExchangeUserName(userName); } return hrd.create(); } public boolean delTopic(ServletContext application, HttpServletRequest request, MsgDb md) throws ErrMsgException { return true; } public boolean delSingleMsg(long delId) throws ResKeyException { return true; } public boolean AddReply(ServletContext application, HttpServletRequest request, MsgDb md, FileUpload fu) throws ErrMsgException { int replyType = Integer.parseInt(fu.getFieldValue("replyType")); Privilege privilege = new Privilege(); String userName = privilege.getUser(request); HuankeReplyDb hrd = new HuankeReplyDb(); if(replyType == HuankeReplyDb.REPLY_TYPE_EXCHANGE){ String exchangeGoods = fu.getFieldValue("exchangeGoods"); if (exchangeGoods.equals("") || exchangeGoods.length() > 200) { throw new ErrMsgException("交换的换品名称不能为空或长度不能超过200!"); } String exchangeDepreciation = fu.getFieldValue("exchangeDepreciation"); if (exchangeDepreciation.equals("") || exchangeDepreciation.length() > 20) { throw new ErrMsgException("新旧程度不能为空或长度不能超过20!"); } String exchangeProvince = fu.getFieldValue("exchangeProvince"); if (exchangeProvince.equals("") || exchangeProvince.length() > 255) { throw new ErrMsgException("交换地点不能为空或长度不能超过255!"); } String contact = fu.getFieldValue("contact"); if (contact.equals("") || contact.length() > 100) { throw new ErrMsgException("联系方式不能为空或长度不能超过100!"); } hrd.setMsgId(md.getId()); hrd.setReplyType(replyType); hrd.setExchangeGoods(exchangeGoods); hrd.setExchangeDepreciation(exchangeDepreciation); hrd.setExchangeProvince(exchangeProvince); hrd.setContact(contact); hrd.setExchangeUserName(userName); }else{ hrd.setMsgId(md.getId()); hrd.setReplyType(replyType); hrd.setExchangeUserName(userName); } return hrd.create(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -