pageEncoding="utf-8"%>
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
微客服 第/页
评论()
发表评论
您的评论:
dao层
package dfml.daoImpl;
import java.sql.SQLException;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;
import dfml.dao.ClickCommentDao;
import dfml.pojo.ClickComment;
@Component
public class ClickCommentDaoImpl implements ClickCommentDao{
private HibernateTemplate hibernateTemplate;
@Resource
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
//添加一条评论信息
@Override
public boolean addClickComment(ClickComment clickComment) {
boolean isSuccess = false;
try {
hibernateTemplate.save(clickComment);
isSuccess = true;
} catch (Exception e) {
isSuccess = false;
e.printStackTrace();
}
return isSuccess;
}
//分页查找评论信息
@SuppressWarnings("unchecked")
@Override
public List findClickCommentByPage(final int page, final int row) {
List list = this.hibernateTemplate
.executeFind(new HibernateCallback
struts配置
action
package dfml.action;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionSupport;
import dfml.dao.ClickCommentDao;
import dfml.pojo.Activity;
import dfml.pojo.ClickComment;
@Component("clickCommentAction")
@Scope("prototype")
public class ClickCommentAction extends ActionSupport{
private static final long serialVersionUID = 1L;
private ClickCommentDao clickCommentDao;
private Map map;
private String content;// 评论内容
private String repcontent;// 回复评论
private int page;
private int row;
private int rows;
private int id;
public void setId(int id) {
this.id = id;
}
public Map getMap() {
return map;
}
@Resource
public void setClickCommentDao(ClickCommentDao clickCommentDao) {
this.clickCommentDao = clickCommentDao;
}
public void setContent(String content) {
this.content = content;
}
public void setRepcontent(String repcontent) {
this.repcontent = repcontent;
}
public void setPage(int page) {
this.page = page;
}
public void setRow(int row) {
this.row = row;
}
public void setRows(int rows) {
this.rows = rows;
}
//添加评论 用于微信用户
public String addClickComment() {
boolean isSuccess = false;
map = new HashMap();
ClickComment clickComment = new ClickComment();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
clickComment.setTime(format.format(new Date(System.currentTimeMillis())));
clickComment.setContent(content);
try {
isSuccess = clickCommentDao.addClickComment(clickComment);
} catch (Exception e) {
isSuccess = false;
e.printStackTrace();
}
map.put("success", isSuccess);
return "add";
}
//分页查找评论 用户微信用户
public String findClickCommentByPage() {
map = new HashMap();
map.put("list", clickCommentDao.findClickCommentByPage(page, row));
return "findByPage";
}
//查询评论条数 用于微信用户
public String getTotalNum(){
map = new HashMap();
map.put("total", clickCommentDao.getClickCommentCount());
return "total";
}
//回复评论 用于后台管理
public String updateClickComment(){
boolean isSuccess=false;
map=new HashMap();
ClickComment clickComment =clickCommentDao.findClickCommentById(id);
if(clickComment!=null){
clickComment.setRepcontent(repcontent);
isSuccess=clickCommentDao.updateClickComment(clickComment);
}
map.put("success", isSuccess);
return "update";
}
//查询所有评论 用于后台管理
public String findAllClickComment(){
map=new HashMap();
List lists=clickCommentDao.findClickCommentByPage(page, rows);
List listss=clickCommentDao.findAllClickComment();
map.put("rows", lists);
map.put("total", listss.size());
map.put("list", listss);
return "list";
}
//删除评论 用于后台管理
public String deleteClickComment(){
boolean isSuccess=false;
map=new HashMap();
ClickComment clickComment =clickCommentDao.findClickCommentById(id);
if(clickComment!=null){
isSuccess=clickCommentDao.deleteClickComment(clickComment);
}
map.put("success", isSuccess);
return "delete";
}
}
pojo
package dfml.pojo;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
//评论表
@Entity
public class ClickComment implements Serializable{
private static final long serialVersionUID = 1L;
private Integer id;
private String time;// 评论时间
private String content;// 评论内容
private String name;// 评论人
private String repcontent;//回复评论
@Id
@GeneratedValue
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getRepcontent() {
return repcontent;
}
public void setRepcontent(String repcontent) {
this.repcontent = repcontent;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}