📄 voteutil.java
字号:
package com.easyjf.bbs.business.util;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import com.easyjf.bbs.business.ActiveUser;
import com.easyjf.bbs.business.BBSDir;
import com.easyjf.bbs.business.BBSDoc;
import com.easyjf.bbs.business.Vote;
import com.easyjf.bbs.business.VoteItem;
import com.easyjf.web.ActionContext;
import com.easyjf.web.tools.DbPageList;
import com.easyjf.web.tools.IPageList;
public class VoteUtil {
public static boolean add(String dir,Vote vote,String[] voteitem){
boolean ret=false;
BBSDir d=BBSDir.read(dir);
BBSDoc doc=new BBSDoc();
doc.setTitle(vote.getTitle()+"(投票)");
doc.setIntro(vote.getInfo());
doc.setDirSn(d.getSn());
doc.setInputUser(((ActiveUser)ActionContext.getContext().getSession().getAttribute("bbsuser")).getUserName());
doc.setHasvote(new Integer(1));
doc.setStatus(new Integer(0));
doc.setInputTime(new Date());
ret=doc.save();
System.out.println(doc);
System.out.println(doc.getCid());
vote.setDocid(doc.getCid());
vote.setCid(null);
ret=vote.save();
System.out.println(vote);
for(int i=0;i<voteitem.length;i++){
VoteItem vi=new VoteItem();
vi.setInfo(voteitem[i]);
vi.setVoteid(vote.getCid());
vi.setVotenum(new Integer(0));
ret=vi.save();
}
return ret;
}
public static List resultById(String voteid){
List ret=VoteItem.query(" and voteid='"+voteid+"'");
return ret;
}
public static List resultByTitle(String title){
Vote vote=Vote.readByTitle(title);
List ret=VoteUtil.resultById(vote.getCid());
return ret;
}
public static boolean delById(String id){
boolean ret=false;
Vote vote=Vote.read(id);
List vi=VoteUtil.resultById(id);
for(Iterator it=vi.iterator();it.hasNext();){
VoteItem v=(VoteItem)it.next();
ret=v.del();
}
ret=vote.del();
return ret;
}
public static boolean delByTitle(String title){
boolean ret=false;
Vote vote=Vote.readByTitle(title);
List vi=VoteUtil.resultById(vote.getCid());
for(Iterator it=vi.iterator();it.hasNext();){
VoteItem v=(VoteItem)it.next();
ret=v.del();
}
ret=vote.del();
return ret;
}
public static IPageList queryVotes(String scope, int pageSize, int pageNo) {
DbPageList pList = new DbPageList(Vote.class, scope, null);
pList.doList(pageNo, pageSize);
return pList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -