资源简介
北大青鸟在线投票系统(Vote)这是我小组成员一起做的(SVN),不是和网上那些Vote一样,页面确实差不多的,但代码部分都不一样,保证能够运行的Hibernate+Struts2+MySQL
代码片段和文件信息
package com.bdqn.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.bdqn.biz.ItemBiz;
import com.bdqn.biz.SubjectBiz;
import com.bdqn.bizImpl.ItemBizImpl;
import com.bdqn.bizImpl.SubjectBizImpl;
import com.bdqn.entity.Item;
import com.bdqn.entity.Option;
import com.bdqn.entity.Subject;
import com.bdqn.entity.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class ItemAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private ItemBiz itemBiz = new ItemBizImpl();
private Integer entityId;
private Subject subject;
private Long votes;
private List options;
private Map stat = new HashMap();
private Map statPercent = new HashMap();
public Integer getEntityId() {
return entityId;
}
public void setEntityId(Integer entityId) {
this.entityId = entityId;
}
public Subject getSubject() {
return subject;
}
public void setSubject(Subject subject) {
this.subject = subject;
}
public Long getVotes() {
return votes;
}
public void setVotes(Long votes) {
this.votes = votes;
}
public List getOptions() {
return options;
}
public void setOptions(List options) {
this.options = options;
}
public Map getStat() {
return stat;
}
public void setStat(Map stat) {
this.stat = stat;
}
public Map getStatPercent() {
return statPercent;
}
public void setStatPercent(Map statPercent) {
this.statPercent = statPercent;
}
@SuppressWarnings(“unchecked“)
public String getSubjectById() {
SubjectBiz subjectBiz = new SubjectBizImpl();
subject = subjectBiz.getSubjectById(entityId);
Listject[]> subjectVotes = subjectBiz.getSubjectVoteCount(entityId);
for (object[] subjectVote : subjectVotes) {
if (subjectVote != null) {
votes = (Long) subjectVote[1];
break;
}
}
return “getSubjectByIdSuccess“;
}
// public String save() {
// System.out.println(“entityId:“+entityId);
// for(int i = 0;i // System.out.println(“option.id====“+options.get(i));
// }
//
// public String save() {
// System.out.println(“entityId:“ + entityId);
// for (int i = 0; i < options.size(); i++) {
// System.out.println(“option.id====“ + options.get(i));
// }
public String save() {
int count = 0;
Item item = null;
Option option = null;
for (int i = 0; i < options.size(); i++) {
item = new Item();
item.setUser((User) ActionContext.getContext().getSession()
.get(“loginUser“));
subject = new Subject();
subject.setId(entityId);
item.setSubject(subject);
option = new Option();
option.setId(options.get(i));
item.setOption(option);
count += itemBiz.addItem(item);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3506 2014-01-17 17:00 Vote.sql
目录 0 2014-04-17 16:12 VoteSystem\
文件 3593 2014-01-15 16:28 VoteSystem\.classpath
文件 303 2014-04-09 15:18 VoteSystem\.myme
文件 1753 2014-01-15 16:28 VoteSystem\.project
目录 0 2014-04-17 16:12 VoteSystem\.settings\
文件 500 2014-01-15 16:28 VoteSystem\.settings\.jsdtscope
目录 0 2014-04-17 14:22 VoteSystem\.settings\.svn\
文件 981 2014-01-17 17:23 VoteSystem\.settings\.svn\all-wcprops
文件 1260 2014-01-22 13:32 VoteSystem\.settings\.svn\entries
目录 0 2014-01-15 16:28 VoteSystem\.settings\.svn\prop-ba
目录 0 2014-01-15 16:28 VoteSystem\.settings\.svn\props\
目录 0 2014-04-17 14:22 VoteSystem\.settings\.svn\text-ba
文件 500 2014-01-15 16:28 VoteSystem\.settings\.svn\text-ba
文件 364 2014-01-17 15:35 VoteSystem\.settings\.svn\text-ba
文件 468 2014-01-17 15:35 VoteSystem\.settings\.svn\text-ba
文件 252 2014-01-17 15:35 VoteSystem\.settings\.svn\text-ba
文件 49 2014-01-15 16:28 VoteSystem\.settings\.svn\text-ba
文件 6 2014-01-15 16:28 VoteSystem\.settings\.svn\text-ba
目录 0 2014-04-17 14:22 VoteSystem\.settings\.svn\tmp\
目录 0 2014-01-15 16:28 VoteSystem\.settings\.svn\tmp\prop-ba
目录 0 2014-01-15 16:28 VoteSystem\.settings\.svn\tmp\props\
目录 0 2014-01-17 15:35 VoteSystem\.settings\.svn\tmp\text-ba
文件 364 2014-01-15 16:28 VoteSystem\.settings\org.eclipse.jdt.core.prefs
文件 468 2014-01-15 16:28 VoteSystem\.settings\org.eclipse.wst.common.component
文件 252 2014-01-15 16:28 VoteSystem\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2014-01-15 16:28 VoteSystem\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2014-01-15 16:28 VoteSystem\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2014-04-17 14:22 VoteSystem\.svn\
文件 356 2014-01-22 13:37 VoteSystem\.svn\all-wcprops
文件 713 2014-01-22 13:37 VoteSystem\.svn\entries
............此处省略528个文件信息
评论
共有 条评论