photomgr.java
来自「cwbbs 云网论坛源码」· Java 代码 · 共 163 行
JAVA
163 行
package com.redmoon.blog.photo;import javax.servlet.*;import javax.servlet.http.*;import cn.js.fan.cache.jcs.*;import cn.js.fan.util.*;import cn.js.fan.web.*;import com.redmoon.blog.*;import com.redmoon.blog.Config;import com.redmoon.forum.Privilege;import com.redmoon.forum.plugin.*;import com.redmoon.forum.plugin.base.*;import com.redmoon.forum.plugin.score.*;import org.apache.log4j.*;public class PhotoMgr { Logger logger = Logger.getLogger(PhotoMgr.class.getName()); RMCache rmCache; public PhotoMgr() { rmCache = RMCache.getInstance(); } public boolean add(ServletContext application, HttpServletRequest request) throws ErrMsgException { PhotoForm lf = new PhotoForm(); lf.checkAdd(application, request); blogId = lf.getBlogId(); PhotoDb ld = new PhotoDb(); ld.setTitle(lf.getTitle()); ld.setBlogId(lf.getBlogId()); ld.setDirCode(lf.getDirCode()); boolean re = ld.create(lf.fileUpload); return re; } public boolean del(ServletContext application, HttpServletRequest request) throws ErrMsgException { PhotoForm lf = new PhotoForm(); lf.checkDel(request); PhotoDb ld = new PhotoDb(); ld = ld.getPhotoDb(lf.getId()); boolean re = ld.del(Global.getRealPath()); return re; } public boolean move(HttpServletRequest request) throws ErrMsgException { PhotoForm lf = new PhotoForm(); lf.checkMove(request); PhotoDb ld = new PhotoDb(); ld = ld.getPhotoDb(lf.getId()); boolean re = ld.move(lf.getDirection()); return re; } public boolean modify(ServletContext application, HttpServletRequest request) throws ErrMsgException { PhotoForm lf = new PhotoForm(); lf.checkModify(application, request); blogId = lf.getBlogId(); PhotoDb ld = new PhotoDb(); ld = ld.getPhotoDb(lf.getId()); ld.setTitle(lf.getTitle()); ld.setBlogId(lf.getBlogId()); ld.setDirCode(lf.getDirCode()); boolean re = ld.save(lf.getFileUpload()); return re; } public PhotoDb getPhotoDb(int id) { PhotoDb ld = new PhotoDb(); return ld.getPhotoDb(id); } public void setBlogId(long blogId) { this.blogId = blogId; } public long getBlogId() { return blogId; } public boolean dig(HttpServletRequest request) throws ErrMsgException,ResKeyException { if (!Privilege.isUserLogin(request)) throw new ErrMsgException("请先登录!"); long photoId = ParamUtil.getLong(request, "photoId"); PhotoDb pd = new PhotoDb(); pd = pd.getPhotoDb(photoId); long blogId = pd.getBlogId(); UserConfigDb ucd = new UserConfigDb(); ucd = ucd.getUserConfigDb(blogId); if (!ucd.isPhotoDig()) { throw new ErrMsgException("该博客照片不允许被评分!"); } String userName = Privilege.getUser(request); ScoreMgr sm = new ScoreMgr(); ScoreUnit su = sm.getScoreUnit(Gold.code); Config dc = Config.getInstance(); int pay = dc.getIntProperty("digPhotoCost"); int digScoreMax = dc.getIntProperty("digScoreMax"); int digValue = ParamUtil.getInt(request, "digValue"); if (digValue>digScoreMax) { throw new ErrMsgException("照片评分一次加分最高值不能超过" + digScoreMax); } boolean re = su.getScore().pay(userName, IPluginScore.SELLER_SYSTEM, pay); if (re) { pd.setScore(pd.getScore() + digValue); re = pd.save(); } return re; } public boolean undig(HttpServletRequest request) throws ErrMsgException,ResKeyException { if (!Privilege.isUserLogin(request)) throw new ErrMsgException("请先登录!"); long photoId = ParamUtil.getLong(request, "photoId"); PhotoDb pd = new PhotoDb(); pd = pd.getPhotoDb(photoId); long blogId = pd.getBlogId(); UserConfigDb ucd = new UserConfigDb(); ucd = ucd.getUserConfigDb(blogId); if (!ucd.isPhotoDig()) { throw new ErrMsgException("该博客照片不允许被评分!"); } String scoreCode = ParamUtil.get(request, "scoreCode"); String userName = Privilege.getUser(request); ScoreMgr sm = new ScoreMgr(); ScoreUnit su = sm.getScoreUnit(scoreCode); Config dc = Config.getInstance(); int pay = dc.getIntProperty("undigPhotoCost"); int digScoreMax = dc.getIntProperty("undigScoreMax"); int digValue = ParamUtil.getInt(request, "digValue"); if (digValue>digScoreMax) { throw new ErrMsgException("照片评分一次加分最高值不能超过" + digScoreMax); } boolean re = su.getScore().pay(userName, IPluginScore.SELLER_SYSTEM, pay); if (re) { pd.setScore(pd.getScore() - digValue); re = pd.save(); } return re; } long blogId;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?