📄 bbsstatbiz.java
字号:
package com.yhbbs.bbs.biz;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import com.yhbbs.article.biz.ArticleBiz;
import com.yhbbs.bbs.dao.BbsStatDaoIm;
import com.yhbbs.bbs.itface.BbsStat;
import com.yhbbs.bbs.itface.dao.BbsStatDao;
import com.yhbbs.forum.biz.ForumBiz;
import com.yhbbs.utils.Constants;
import com.yhbbs.utils.DateUtils;
/**
* <p>Title:系统状态相关操作</p>
* <li> 系统状态的所有相关操作<br>
* <br><b>WebSite: www.yyhweb.com</b>
* <br><b>CopyRight: yyhweb[由由华网]</b>
* @author stephen
* @version YHBBS-2.0
*/
public class BbsStatBiz {
private static Logger bbslog = Logger.getLogger(BbsStatBiz.class);
private static BbsStatDao bbsdao = BbsStatDaoIm.getInstance();
/**
* 判断论坛状态时间是否等于今天时间
*/
public static void theSameDay(){
String curDate = DateUtils.getCurFormatDate(Constants.dateFS);
String bbstime = getBbsTime();
String fbbstime = DateUtils.getStr2Str(Constants.dateFS,bbstime);
if(curDate.equals(fbbstime)){
return ;
}else{
upYesday();
upToday(false);
ForumBiz.upAllFYesdayC();
}
}
/** 返回论坛状态的当前时间
* @return String 论坛时间
*/
public static String getBbsTime(){
try {
return bbsdao.getBbsTime();
}
catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke getBbsTime():\n" + e.toString());
}
return "";
}
/** 取得系统状态
* @return BbsStat 系统状态
*/
public static BbsStat getBbsStat(){
try {
return bbsdao.getBbsStat();
}
catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke getBbsStat():\n" + e.toString());
}
return null;
}
/** 注册一个用户,同时更新最新用户,系统用户总数加一。
* @param userId 新用户Id
* @param userName 新用户名
*/
public static void upRegUser(int userId,String userName){
try {
bbsdao.upNewRegUser(userId, userName);
}
catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke upUserCount():\n" + e.toString());
}
return;
}
/** 发表帖子,判断是主题贴还是回复,系统相关总数加一
* @param flag true:主题贴 false:回复贴
*/
public static void upArtCount(boolean flag){
upToday(true);
upPostCount(flag);
}
/** 发表一个主题帖子,系统主题数加一
* @param flag true:主题帖 false:回复贴
*/
public static void upPostCount(boolean flag) {
try {
if(flag)
bbsdao.upPostCount();
else
bbsdao.upRepCount();
}
catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke upPostCount():\n" + e.toString());
}
return;
}
/** 删除帖子,系统统计数减一
* @param flag true:主题贴 false:回复贴
*/
public static void deleteArticle(boolean flag){
try {
bbsdao.delArticle(flag);
}catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke deleteArticle(boolean flag):\n" + e.toString());
}
return;
}
/** 更新今天发帖总数,同时检查今天发帖是否最多
* @param flag 如果发帖是同一天则加一,否则更新之
*/
public static void upToday(boolean flag) {
int today = 0;
if(!flag)
today = ArticleBiz.getTodayCount();
try {
bbsdao.upToday(flag,today);
upMaxPost();
}
catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke upToday(flag):\n" + e.toString());
}
return;
}
/** 更新昨天发帖总数
*/
public static void upYesday() {
int yesday = ArticleBiz.getYesdayCount();
try {
bbsdao.upYesday(yesday);
}
catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke upYesday():\n" + e.toString());
}
return;
}
/** 更新最大发帖总数
*/
public static void upMaxPost() {
try {
int today = bbsdao.getToday();
int max = bbsdao.getMaxPost();
if(today>max){
bbsdao.upMaxPost(today);
bbslog.info("Today is the day which post article most! ");
}
}catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke upMaxPost(num):\n" + e.toString());
}
return;
}
/** 更新最大在线用户总数
* @param num 在线用户总数
*/
public static void upMaxOnline(int num) {
try {
int max = bbsdao.getMaxOnline();
if(num>max){
bbsdao.upMaxOnline(num);
bbslog.info("Today is the day which most user online at the same time! ");
}
}catch(SQLException e) {
bbslog.error("Throws a SqlException when invoke upMaxOnline(num):\n" + e.toString());
}
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -