js写的评论分页(还不错)(2)

分页标题#e#


<package extends="json-default" namespace="https://www.jb51.net/">
<action method="addClickComment">
<result type="json">
<param>map</param>
</result>
</action>
<action method="findClickCommentByPage">
<result type="json">
<param>map</param>
</result>
</action>
<action method="getTotalNum">
<result type="json">
<param>map</param>
</result>
</action>
<action method="updateClickComment">
<result type="json">
<param>map</param>
</result>
</action>
<action method="findAllClickComment">
<result type="json">
<param>map</param>
</result>
</action>
<action method="deleteClickComment">
<result type="json">
<param>map</param>
</result>
</action>


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<String, Object> 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<String, Object> 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<String, Object>();
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<String, Object>();
map.put("list", clickCommentDao.findClickCommentByPage(page, row));
return "findByPage";
}
//查询评论条数 用于微信用户
public String getTotalNum(){
map = new HashMap<String, Object>();
map.put("total", clickCommentDao.getClickCommentCount());
return "total";
}
//回复评论 用于后台管理
public String updateClickComment(){
boolean isSuccess=false;
map=new HashMap<String, Object>();
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<String, Object>();
List<ClickComment> lists=clickCommentDao.findClickCommentByPage(page, rows);
List<ClickComment> 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<String, Object>();
ClickComment clickComment =clickCommentDao.findClickCommentById(id);
if(clickComment!=null){
isSuccess=clickCommentDao.deleteClickComment(clickComment);
}
map.put("success", isSuccess);
return "delete";
}


}


pojo

复制代码 代码如下:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdwgyj.html