📄 articledaoim.java
字号:
package com.yhbbs.article.dao;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yhbbs.article.itface.Article;
import com.yhbbs.article.itface.ArticleDao;
import com.yhbbs.article.itface.ArticleDto;
import com.yhbbs.article.itface.Content;
import com.yhbbs.data.AppSqlMap;
/**
* <p>Title:论坛帖子数据存取模块Bean</p>
* <li> 论坛帖子相关存取和管理操作
* <li> 注:本论坛将帖子内容作为一个单独的对象处理,故在处理帖子时应该注意该帖子内容的相关处理<br>
* <br><b>WebSite: www.yyhweb.com</b>
* <br><b>CopyRight: yyhweb[由由华网]</b>
* @author stephen
* @version YHBBS-2.0
*/
public class ArticleDaoIm implements ArticleDao {
private static ArticleDao articledao = new ArticleDaoIm();
private SqlMapClient sqlMapClient;
/**
* Constructor Method
*/
public ArticleDaoIm() {
sqlMapClient = AppSqlMap.getInstance();
}
/**
* @return get the Instance of ArticleDaoIm
*/
public static ArticleDao getInstance(){
return articledao;
}
private int getInt(Object ob){
if(ob!=null)
return Integer.parseInt(ob.toString());
else
return 0;
}
/**
* @return 获得昨天此刻时间
*/
public Date getYesterdayDate() {
return new Date(System.currentTimeMillis()-0x5265c00L);
}
public String getArtTitle(int articleId) throws SQLException{
Object ob = sqlMapClient.queryForObject("getArtTitle",articleId);
if(ob!=null)
return ob.toString();
else
return "";
}
public Date getArtPostTime(int articleId) throws SQLException{
Object ob = sqlMapClient.queryForObject("getArtPostTime",articleId);
if(ob!=null)
return (Date) ob;
else
return new Date();
}
public int getReplayParentId(int articleId) throws SQLException{
return getInt(sqlMapClient.queryForObject("getReplayParentId",articleId));
}
public int getArtUserId(int articleId) throws SQLException{
return getInt(sqlMapClient.queryForObject("getArtUserId",articleId));
}
public ArticleDto getArticle(int articleId) throws SQLException{
return (ArticleDto)sqlMapClient.queryForObject("getArticle",articleId);
}
public Content getContent(int id) throws SQLException {
return (Content)sqlMapClient.queryForObject("getContent",id);
}
public Article getArtContent(int id) throws SQLException {
return (Article)sqlMapClient.queryForObject("getArtContent",id);
}
public boolean addArticle(Article article) throws SQLException {
return getInt(sqlMapClient.insert("addArticle",article))==0;
}
public boolean addContent(Content content) throws SQLException {
return getInt(sqlMapClient.insert("addContent",content))==0;
}
public void replayArt(HashMap userMap) throws SQLException {
sqlMapClient.update("replayArt",userMap);
}
public boolean delArticle(int artId,boolean flag) throws SQLException {
int art = 0,con = 0;
if(flag){
art = sqlMapClient.delete("artDelete",artId);
con = sqlMapClient.delete("conDelete",artId);
}else{ // 先取得主体Id,删除回复帖,最后更新主体贴的回复数
int pId = getInt(sqlMapClient.queryForObject("getReplayParentId", artId));
art = sqlMapClient.delete("replayDelete",artId);
con = sqlMapClient.delete("rconDelete",artId);
sqlMapClient.update("upArtReplayNum", pId);
}
if(art>0 && con>0)
return true;
else
return false;
}
public boolean editArticle(Article article) throws SQLException {
return getInt(sqlMapClient.update("editArticle",article))>0;
}
public boolean editContent(Content content) throws SQLException {
return getInt(sqlMapClient.update("editContent",content))>0;
}
public boolean moveArticle(HashMap moveMap) throws SQLException {
return getInt(sqlMapClient.update("moveArticle",moveMap))>0;
}
public void setArtTop(HashMap topMap) throws SQLException {
sqlMapClient.update("setArtTop",topMap);
}
public void setElite(int artId,boolean flag) throws SQLException {
if(flag)
sqlMapClient.update("setElite",artId);
else
sqlMapClient.update("celElite",artId);
}
public void setCommend(int artId,boolean flag) throws SQLException {
if(flag)
sqlMapClient.update("setCommend",artId);
else
sqlMapClient.update("celCommend",artId);
}
public void setLock(int artId,boolean flag) throws SQLException {
if(flag)
sqlMapClient.update("setLock",artId);
else
sqlMapClient.update("celLock",artId);
}
public int getMaxArtId() throws SQLException {
return getInt(sqlMapClient.queryForObject("getArticleMaxId",null));
}
public int getMaxArtId(int forumid) throws SQLException {
return getInt(sqlMapClient.queryForObject("getMaxArtId",forumid));
}
public int getMaxReplayId(int articleid) throws SQLException {
return getInt(sqlMapClient.queryForObject("getMaxReplayId",articleid));
}
public List getAllTop() throws SQLException {
return (List)sqlMapClient.queryForList("getAllTop",null);
}
public List getClassTop(int classid) throws SQLException {
return (List)sqlMapClient.queryForList("getClassTop",classid);
}
public List getForumTop(int forumid) throws SQLException {
return (List)sqlMapClient.queryForList("getForumTop",forumid);
}
public int getForumEliteC(int forumId) throws SQLException {
return getInt(sqlMapClient.queryForObject("getForumEliteC",forumId));
}
public List getForumElite(HashMap forumpage) throws SQLException {
return (List)sqlMapClient.queryForList("getForumElite",forumpage);
}
public List getForumArt(HashMap forumpage) throws SQLException {
return (List)sqlMapClient.queryForList("getForumArt",forumpage);
}
public Article getForumLastArt(int forumId) throws SQLException {
return (Article)sqlMapClient.queryForObject("getForumLastArt",forumId);
}
public int getForumNoTopC(int forumId) throws SQLException {
return getInt(sqlMapClient.queryForObject("getForumNoTopC",forumId));
}
public int getForumArtC(int forumId) throws SQLException {
return getInt(sqlMapClient.queryForObject("getForumArtC",forumId));
}
public int getTodayCount() throws SQLException {
return getInt(sqlMapClient.queryForObject("getTodayCount",null));
}
public int getYesdayCount() throws SQLException {
return getInt(sqlMapClient.queryForObject("getYesdayCount",null));
}
public int getForumYesdayC(int forumId) throws SQLException {
return getInt(sqlMapClient.queryForObject("getForumYesdayC",forumId));
}
public List getNewArticle(int size) throws SQLException {
return (List)sqlMapClient.queryForList("getNewArticle",size);
}
public List getEliteArticle(int size) throws SQLException {
return (List)sqlMapClient.queryForList("getEliteArticle",size);
}
public List getComArticle(int size) throws SQLException {
return (List)sqlMapClient.queryForList("getComArticle",size);
}
public int getArtReplayC(int articleId) throws SQLException {
return getInt(sqlMapClient.queryForObject("getArtReplayC",articleId));
}
public List getArtReplay(HashMap artrp) throws SQLException {
return (List)sqlMapClient.queryForList("getArtReplay",artrp);
}
public void addOneHitTime(int articleid) throws SQLException {
sqlMapClient.update("addOneHitTime",articleid);
}
public boolean isUserRepArt(HashMap isuserrpart) throws SQLException {
return getInt(sqlMapClient.queryForObject("isUserRepArt",isuserrpart))>0;
}
public int getUserArtcount(int userId,int i) throws SQLException {
if(i==0)
return getInt(sqlMapClient.queryForObject("getUserArtcount",userId));
else
return getInt(sqlMapClient.queryForObject("getUserRepcount",userId));
}
public List getUserArt(HashMap artpage,int i) throws SQLException {
if(i==0)
return (List)sqlMapClient.queryForList("getUserArt",artpage);
else
return (List)sqlMapClient.queryForList("getUserReplay",artpage);
}
// for search index
public List getArtForSearchIndex() throws SQLException {
return (List)sqlMapClient.queryForList("getArtForSearchIndex",null);
}
// 后台管理使用
public boolean moveForum(int forumId, int classId) throws SQLException {
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("forumId", forumId);
map.put("classId", classId);
return sqlMapClient.update("moveForumArt",map)>0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -