⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sweetmsgaction.java

📁 cwbbs 云网论坛源码
💻 JAVA
字号:
package com.redmoon.forum.plugin.sweet;import javax.servlet.http.HttpServletRequest;import cn.js.fan.util.ErrMsgException;import javax.servlet.ServletContext;import com.redmoon.forum.plugin.base.IPluginMsgAction;import org.apache.log4j.Logger;import com.redmoon.forum.MsgDb;import cn.js.fan.util.ParamUtil;import cn.js.fan.util.StrUtil;import java.util.Calendar;import com.redmoon.kit.util.FileUpload;import java.io.File;import cn.js.fan.util.ResKeyException;import cn.js.fan.web.Global;public class SweetMsgAction implements IPluginMsgAction {    Logger logger = Logger.getLogger(this.getClass().getName());    public static final String ACTION_APPLY = "apply";    public static final String ACTION_ACCEPT_APPLY = "acceptApply";    public static final String ACTION_DECLINE_APPLY = "declineApply";    public static final String ACTION_APPLY_MARRY = "applymarry";    public static final String ACTION_ACCEPT_MARRY = "acceptApplyMarry";    public static final String ACTION_DECLINE_MARRY = "acceptDeclineMarry";    public SweetMsgAction() {    }        public synchronized boolean editTopic(ServletContext application,                                          HttpServletRequest request,                                          MsgDb md, FileUpload fu) throws            ErrMsgException {                long editid = Long.parseLong(fu.getFieldValue("editid"));        String strsecretLevel = StrUtil.getNullStr(fu.getFieldValue("secretLevel"));                if (strsecretLevel.equals(""))            return true;                int secretLevel = SweetMsgDb.SECRET_LEVEL_FORUM_PUBLIC;        if (StrUtil.isNumeric(strsecretLevel)) {            secretLevel = Integer.parseInt(strsecretLevel);        }        SweetMsgDb sm = new SweetMsgDb();        sm = sm.getSweetMsgDb(editid);        if (!sm.isLoaded()) {            sm.setMsgId(editid);            sm.setScretLevel(secretLevel);            sm.setUserAction(sm.USER_ACTION_GENERAL);            return sm.create();        }        else {            sm.setScretLevel(secretLevel);            return sm.save();        }    }    public boolean AddNew(ServletContext application,                          HttpServletRequest request, MsgDb md, FileUpload fu) throws            ErrMsgException {                SweetDb sd = new SweetDb();        sd.setmsgRootId(md.getId());        sd.setState(sd.STATE_PURSUE);        sd.setName(md.getName());        return sd.create();    }    public boolean AddQuickReply(ServletContext application,                                 HttpServletRequest request, long replyMsgId) throws            ErrMsgException {                int secretLevel = SweetMsgDb.SECRET_LEVEL_FORUM_PUBLIC;        try {            secretLevel = ParamUtil.getInt(request, "secretLevel");        }        catch (Exception e) {            logger.error("AddQuickReply:" + e.getMessage());            return true;        }        SweetMsgDb sm = new SweetMsgDb();        sm.setMsgId(replyMsgId);        sm.setScretLevel(secretLevel);        sm.setUserAction(sm.USER_ACTION_GENERAL);        return sm.create();    }        public boolean delTopic(ServletContext application,                            HttpServletRequest request, MsgDb md) throws ErrMsgException {                if (md.isRootMsg()) {                                    SweetDb sd = new SweetDb();            sd = sd.getSweetDb(md.getId());            sd.del();                        SweetUserInfoDb suid = new SweetUserInfoDb();            suid = suid.getSweetUserInfoDb(sd.getName());            String sPhoto = StrUtil.getNullString(suid.getPhoto());            if (!sPhoto.equals("")) {                String rootpath = Global.getRealPath();                File file = new File(rootpath + sPhoto);                file.delete();            }                        suid.del();        }        return true;    }        public boolean delSingleMsg(long delId) throws            ResKeyException {        SweetMsgDb sm = new SweetMsgDb();        sm = sm.getSweetMsgDb(delId);        return sm.del();    }    public boolean AddReply(ServletContext application,                          HttpServletRequest request, MsgDb md, FileUpload fu) throws            ErrMsgException {        String sweetAction;        sweetAction = StrUtil.getNullString(fu.getFieldValue("sweetAction"));                if (sweetAction.equals(ACTION_APPLY)) {            String strsecretLevel = fu.getFieldValue("secretLevel");            int secretLevel = SweetMsgDb.SECRET_LEVEL_FORUM_PUBLIC;            if (StrUtil.isNumeric(strsecretLevel)) {                secretLevel = Integer.parseInt(strsecretLevel);            }                       SweetMsgDb sm = new SweetMsgDb();           sm.setMsgId(md.getId());           sm.setScretLevel(secretLevel);            sm.setUserAction(sm.USER_ACTION_APPLY);           sm.create();                      SweetUserDb su = new SweetUserDb();           su.setName(md.getName());           su.setState(su.STATE_NORMAL);           su.setType(su.TYPE_APPLIER);           su.setMsgRootId(md.getRootid());           su.create();       }       else if (sweetAction.equals(this.ACTION_ACCEPT_APPLY)) {            SweetUserDb su = new SweetUserDb();                      MsgDb msgDb = md.getMsgDb(md.getReplyid());           String name = msgDb.getName();                      su = su.getSweetUserDb(md.getRootid(), name);           su.setType(su.TYPE_PERSUATER);           su.save();                  }                        else if (sweetAction.equals(ACTION_APPLY_MARRY)) {                                String strsecretLevel = fu.getFieldValue("secretLevel");               int secretLevel = SweetMsgDb.SECRET_LEVEL_FORUM_PUBLIC;               if (StrUtil.isNumeric(strsecretLevel)) {                   secretLevel = Integer.parseInt(strsecretLevel);               }               SweetMsgDb sm = new SweetMsgDb();               sm.setMsgId(md.getId());               sm.setScretLevel(secretLevel);               sm.setUserAction(sm.USER_ACTION_APPLY_MARRY);               sm.create();                              SweetUserDb su = new SweetUserDb();               su = su.getSweetUserDb(md.getRootid(), md.getName());               if (!su.isLoaded()) {                   su.setName(md.getName());                   su.setState(su.STATE_NORMAL);                   su.setType(su.TYPE_APPLIER);                   su.setMsgRootId(md.getRootid());                   su.create();               }        }        else if (sweetAction.equals(this.ACTION_ACCEPT_MARRY)) {             SweetUserDb su = new SweetUserDb();                        MsgDb msgDb = md.getMsgDb(md.getReplyid());            String name = msgDb.getName();                        su = su.getSweetUserDb(md.getRootid(), name);            su.setType(su.TYPE_SPOUSE);            su.save();                        SweetLifeDb sl = new SweetLifeDb();            sl.setMsgRootId(msgDb.getRootid());            sl.setMarryDate(Calendar.getInstance().getTime());            MsgDb rootmsg = md.getMsgDb(msgDb.getRootid());            sl.setOwnerName(rootmsg.getName());            sl.setSpouseName(name);            sl.create();                    }                        else {                        String strsecretLevel = fu.getFieldValue("secretLevel");            int secretLevel = SweetMsgDb.SECRET_LEVEL_FORUM_PUBLIC;            if (StrUtil.isNumeric(strsecretLevel)) {                secretLevel = Integer.parseInt(strsecretLevel);            }            SweetMsgDb sm = new SweetMsgDb();            sm.setMsgId(md.getId());            sm.setScretLevel(secretLevel);            sm.setUserAction(sm.USER_ACTION_GENERAL);            sm.create();        }        return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -