📄 commentmanageaction.java
字号:
/**
* 版权声明 EasyJF, 版权所有 违者必究
* 版本号 0.1
*创建者:张钰
* 时 间:2006-4-6
* 描 述:创建
*/
package com.easyjf.news.action;
import java.util.ArrayList;
import java.util.List;
import com.easyjf.news.logic.impl.CommentServiceImpl;
import com.easyjf.news.model.Comment;
import com.easyjf.news.model.Constants;
import com.easyjf.news.model.User;
import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.AbstractCmdAction;
public class CommentManageAction extends AbstractCmdAction {
CommentServiceImpl commdao = CommentServiceImpl.getInstance();
User user = (User) ActionContext.getContext().getSession().getAttribute(
Constants.SESSION_USER);
int popedom;
public Page doInit(WebForm form, Module module) {
// TODO Auto-generated method stub
return doShowComm(form, module);
}
public Page doShowComm(WebForm form, Module module) {
if (user != null) {
popedom = user.getPopedom();
if (popedom == 3) {
List commList = commdao.getComment();
int rows = commList.size();// 分页开始
int pageSize = 30;
int currentPage = 1;
int frontPage=1;
int nextPage = 2;
List firstComm = new ArrayList();
int totalPage = (int) Math.ceil((float) (rows)
/ (float) (pageSize));
firstComm = commdao.getCommBySql(
"id!='' order by date desc", null, 0, pageSize);
form.addResult("rows", rows);
form.addResult("pageSize", pageSize);
form.addResult("frontPage",frontPage);
form.addResult("currentPage", currentPage);
form.addResult("nextPage", nextPage);
form.addResult("totalPage", totalPage);
form.addResult("commList", firstComm);
return module.findPage("manage_comment");
} else {
return module.findPage("noright");
}
} else {
return module.findPage("login");
}
}
public Page doPage(WebForm form, Module module) {
List allNews = commdao.getComment();
int rows = allNews.size();
int pageSize = 30;
int paraPage = CommUtil.null2Int(form.get("page"));
int frontPage = paraPage - 1;
int nextPage = paraPage + 1;
int totalPage = (int) Math.ceil((float) rows / (float) pageSize);
int begin = (paraPage - 1) * pageSize + 1;
int end = rows - begin + 1;
List commList = new ArrayList();
if (frontPage <= 0) {
form.addResult("msg", "这是第一页了!");
form.addResult("frontPage", 1);
} else {
form.addResult("frontPage", frontPage);
}
if (nextPage > totalPage) {
form.addResult("msg", "这是最后一页了!");
form.addResult("nextPage", totalPage);
} else {
form.addResult("nextPage", nextPage);
}
if (end < pageSize) {
commList = commdao.getCommBySql("id!=''", null, begin - 1,
end);
} else {
commList = commdao.getCommBySql("id!=''", null, begin - 1,
pageSize);
}
form.addResult("currentPage", paraPage);
form.addResult("totalPage", totalPage);
form.addResult("rows", rows);
form.addResult("commList", commList);
return module.findPage("manage_comment");
}
public Page doDelComm(WebForm form,Module module){
if (user != null) {
popedom = user.getPopedom();
if (popedom == 3) {
String id=(String)form.get("id");
Comment comm=commdao.getCommentById(id);
if(commdao.delComment(comm)){
form.addResult("msg","删除成功!");
return module.findPage("manage_comment");
}else{
form.addResult("msg","删除失败!");
return module.findPage("manage_comment");
}
} else {
return module.findPage("noright");
}
} else {
return module.findPage("login");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -