📄 threadsservice.java
字号:
package cn.jsprun.service.posts;
import java.util.List;
import java.util.Map;
import cn.jsprun.dao.posts.ThreadsDao;
import cn.jsprun.dao.posts.ThreadsmodDao;
import cn.jsprun.domain.Threads;
import cn.jsprun.domain.Threadsmod;
import cn.jsprun.struts.form.posts.ThreadsForm;
import cn.jsprun.utils.*;
public class ThreadsService {
public boolean addThread(Threads thread)
{
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).addThread(thread);
}
public Threads getThreadsById(Integer tid){
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).findByTid(tid);
}
public String accountTid(List<Map<String,String>> list) {
if (list == null || list.size() <= 0)
return null;
StringBuffer sb = new StringBuffer("");
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i).get("tid"));
sb.append(",");
}
return sb.toString();
}
public void totype(Integer typeid, String sbtid) {
((ThreadsDao)BeanFactory.getBean("threadsDao")).totype(typeid, sbtid);
}
public void toforum(Integer fid, String sbtid) {
((ThreadsDao)BeanFactory.getBean("threadsDao")).toforum(fid, sbtid);
}
public void donotupdatemember(Boolean b, String sbtid) {
((ThreadsDao)BeanFactory.getBean("threadsDao")).donotupdatemember(b, sbtid);
}
public void sticklevel(Integer displayorder, String sbtid) {
((ThreadsDao)BeanFactory.getBean("threadsDao")).sticklevel(displayorder, sbtid);
}
public void adddigest(Integer digest, String sbtid) {
((ThreadsDao)BeanFactory.getBean("threadsDao")).adddigest(digest, sbtid);
}
public void status(Integer status, String sbtid) {
((ThreadsDao)BeanFactory.getBean("threadsDao")).status(status, sbtid);
}
public void deleteattach(String sbtid) {
((ThreadsDao)BeanFactory.getBean("threadsDao")).deleteattach(sbtid);
}
public List<Threads>findThreadsByHql(String hql,int start,int maxrow){
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).findThreadsByHql(hql, start, maxrow);
}
public Threads findByTid(Integer id){
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).findByTid(id);
}
public int findThreadCountByHql(String hql) {
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).findThreadCountByHql(hql);
}
public List<Threads>findThreadsByHqlInnerJoin(String hql,int start,int maxrow){
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).findThreadsByHqlTwo(hql, start, maxrow);
}
public List<Threadsmod>findByThreadsmodBytid(int tid){
return ((ThreadsmodDao)BeanFactory.getBean("threadsmodDao")).findByThreadsBytid(tid);
}
public Threadsmod findByThreadsmodBytidTop1(int tid){
return ((ThreadsmodDao)BeanFactory.getBean("threadsmodDao")).findByThreadsBytidTop1(tid);
}
public boolean updateThreads(Threads thread){
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).updateThreads(thread);
}
public List<Threads> getThreadsByThreadIdList(List<Integer> threadIdList){
return ((ThreadsDao)BeanFactory.getBean("threadsDao")).getThreadsByThreadIdList(threadIdList);
}
public String batchsql(ThreadsForm tf,int timeoffset){
StringBuffer sql = new StringBuffer("from jrun_threads t left join jrun_forums f on t.fid=f.fid where t.displayorder>=0 and ");
String and = "";
if (tf.getKeywords() != null && !tf.getKeywords().equals("")) {
sql.append(and);
and = " and ";
String[] keywords = tf.getKeywords().split(",");
sql.append("( t.subject like '%"+keywords[0]+"%'");
if(keywords.length>1){
for (int i = 1; i < keywords.length; i++) {
sql.append(" or t.subject like '%" + keywords[i] + "%' ");
}
}
sql.append(")");
}
if (tf.getUsers() != null && !tf.getUsers().equals("")) {
String cins ="" ;
if (!tf.getCins()) {
cins = " binary ";
} else {
cins = "";
}
sql.append(and);
and = " and ";
String[] userNames = tf.getUsers().split(",");
sql.append("(" +cins + " t.author ='" + userNames[0] + "' ");
if(userNames.length>1){
for (int i = 1; i < userNames.length; i++) {
sql.append(" or "+cins+"t.author = '" + userNames[i] + "' ");
}
}
sql.append(")");
}
if (tf.getEndtime() != null && !tf.getEndtime().equals("") && Common.datecheck(tf.getEndtime())) {
int endtime = Common.dataToInteger(tf.getEndtime(),"yyyy-MM-dd")-timeoffset;
sql.append(and);
and = " and ";
sql.append("t.dateline<="+endtime);
}
if (tf.getStarttime() != null && !tf.getStarttime().equals("") && Common.datecheck(tf.getStarttime())) {
int endtime = Common.dataToInteger(tf.getStarttime(),"yyyy-MM-dd")-timeoffset;
sql.append(and);
and = " and ";
sql.append("t.dateline>="+endtime);
}
if (tf.getInforum() != -1 && tf.getInforum() > 0) {
sql.append(and);
and = " and ";
sql.append("t.fid = "+tf.getInforum());
}
if (tf.getIntype() != -1 && tf.getIntype() > 0) {
sql.append(and);
and = " and ";
sql.append("t.typeid = "+tf.getIntype());
}
if (tf.getViewsless() != -1 && tf.getViewsless() > 0 && tf.getViewsless() != null) {
sql.append(and);
and = " and ";
sql.append("t.views<="+tf.getViewsless());
}
if (tf.getViewsmore() != -1 && tf.getViewsmore() > 0 && tf.getViewsmore() != null) {
sql.append(and);
and = " and ";
sql.append("t.views>="+tf.getViewsmore());
}
if (tf.getRepliesless() != -1 && tf.getRepliesless() > 0) {
sql.append(and);
and = " and ";
sql.append("t.replies<="+tf.getRepliesless());
}
if (tf.getRepliesmore() != -1 && tf.getRepliesmore() > 0) {
sql.append(and);
and = " and ";
sql.append("t.replies>="+tf.getRepliesmore());
}
if (tf.getReadpermmore() != -1 && tf.getReadpermmore() >= 0) {
sql.append(and);
and = " and ";
sql.append("t.readperm>="+tf.getReadpermmore());
}
if (tf.getPricemore() != -1 && tf.getPricemore() > 0) {
sql.append(and);
and = " and ";
sql.append("t.price>="+tf.getPricemore());
}
if (tf.getNoreplydays() != -1 && tf.getNoreplydays() > 0) {
sql.append(and);
and = " and ";
int time = Common.time();
time = time-tf.getNoreplydays()*86400;
sql.append("t.lastpost<"+time);
}
if (tf.getSpecialthread() != -1 && tf.getSpecialthread() > 0) {
Integer[] ins = tf.getSpecial();
sql.append(and);
and = " and ";
if (tf.getSpecialthread() == 1 && ins!=null) {
String insinfo = "";
for(int p:ins){
insinfo +=","+p;
}
insinfo = insinfo.substring(1);
sql.append("t.special in ( "+insinfo+" )");
}
if (tf.getSpecialthread() == 2 && ins!=null) {
String insinfo = "";
for(int p:ins){
insinfo +=","+p;
}
insinfo = insinfo.substring(1);
sql.append("t.special not in ( "+insinfo+" )");
}
}
if (tf.getSticky() != -1 && tf.getSticky() > 0) {
sql.append(and);
and = " and ";
if (tf.getSticky() == 1) {
sql.append("t.displayorder>0");
}
if (tf.getSticky() == 2) {
sql.append("t.displayorder<=0");
}
}
if (tf.getDigest() != -1 && tf.getDigest() > 0) {
sql.append(and);
and = " and ";
if (tf.getDigest() == 1) {
sql.append("t.digest>0");
}
if (tf.getDigest() == 2) {
sql.append("t.digest<=0");
}
}
if (tf.getBlog() != -1 && tf.getBlog() > 0) {
sql.append(and);
and = " and ";
if (tf.getBlog() == 1) {
sql.append("t.blog>0");
}
if (tf.getBlog() == 2) {
sql.append("t.blog<=0");
}
}
if (tf.getAttach() != -1 && tf.getAttach() > 0) {
sql.append(and);
and = " and ";
if (tf.getAttach() == 1) {
sql.append("t.attachment=1");
}
if (tf.getAttach() == 2) {
sql.append("t.attachment=0");
}
}
if (tf.getRate() != -1 && tf.getRate() > 0) {
sql.append(and);
and = " and ";
if (tf.getRate() == 1) {
sql.append("t.rate<>0");
}
if (tf.getRate() == 2) {
sql.append("t.rate=0");
}
}
if (tf.getHighlight() != -1 && tf.getHighlight() > 0) {
sql.append(and);
and = " and ";
if (tf.getHighlight() == 1) {
sql.append("t.highlight>0");
}
if (tf.getHighlight() == 2) {
sql.append("t.highlight<=0");
}
}
sql.append(" order by t.displayorder desc ");
return sql.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -