package cn.cyj.action;
import java.util.List;
import cn.cyj.entity.Admin;
import cn.cyj.entity.Article;
import cn.cyj.entity.User;
import cn.cyj.service.AdminService;
import cn.cyj.service.ArticleService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;
public class AdminAction implements ModelDriven {
private Admin admin = new Admin();
private AdminService adminService;
private ArticleService articleService;
private Article article = new Article();
private List list;
private List users;
private int articleid;
// 模糊查询的标题
private String searchkey;
// 当前的页码
private int pageNo = 1;
// 每页大小
private int pageSize = 5;
// 只读,用来显示总共几页
private int pageCount;
// 接收复选框的值
private List ck;
private String warn;
//得到用户的列表
public String getUserList(){
users=adminService.getUserList(pageNo pageSize);
int rows=adminService.getUserListNum();
//总页数
pageCount=(int)Math.ceil((double) rows / pageSize);
return “getUserList“;
}
// 管理员登录
public String login() {
admin = adminService.login(admin);
if (admin == null) {
warn = “用户名或密码错误“;
return “login“;
}
ActionContext.getContext().getSession().put(“admin“ admin);
return “manage“;
}
// 显示文章内容
public String show_article() {
article = articleService.getArticle(articleid);
return “show_article“;
}
// 得到未审核的文章
public String getArticlesPage() {
admin = (Admin) ActionContext.getContext().getSession().get(“admin“);
if (admin!=null) {
// 判断是否是还未审核的文章
int isAgree = 0;
list = articleService.getArticlesPage(isAgree searchkey pageNo
pageSize);
int rows = articleService.getArticlesRows(isAgree searchkey);
// 总页数
pageCount = (int) Math.ceil((double) rows / pageSize);
return “getArticlesPage“;
} else{
return “error“;
}
}
// 设置可读
public String enable() {
for (Integer integer : ck) {
Article article = articleService.getArticle(integer);
article.setIsAgree(1);
articleService.updateArticle(article);
}
return “enable_success“;
}
// 设置禁读
public String disable() {
for (Integer i : ck) {
Article article = articleService.getArticle(i);
article.setIsAgree(2);
articleService.updateArticle(article);
}
return “disable_success“;
}
public Admin getAdmin() {
return admin;
}
public void setAdmin(Admin admin) {
this.admin = admin;
}
public ArticleService getArticleService() {
return articleService;
}
public void setArticleService(ArticleService articleService) {
this.articleService = articleService;
}
public Article getArticle() {
return article;
}
public void setArticle(Article article) {
this.article = article;
}
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public List getUsers() {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-02 22:31 endTold\
文件 529 2018-04-09 21:04 endTold\.classpath
目录 0 2018-04-09 21:04 endTold\.myeclipse\
文件 294 2018-05-02 22:32 endTold\.myme
tadata
文件 1750 2018-05-02 22:31 endTold\.project
目录 0 2018-05-02 22:31 endTold\.settings\
文件 500 2018-04-09 21:04 endTold\.settings\.jsdtscope
文件 266 2018-04-10 22:24 endTold\.settings\com.genuitec.eclipse.core.prefs
文件 1009 2018-05-02 22:32 endTold\.settings\com.genuitec.eclipse.j2eedt.core.prefs
文件 364 2018-04-09 21:04 endTold\.settings\org.eclipse.jdt.core.prefs
文件 467 2018-05-02 22:32 endTold\.settings\org.eclipse.wst.common.component
文件 252 2018-04-09 21:04 endTold\.settings\org.eclipse.wst.common.project.facet.core.xml
文件 49 2018-04-09 21:04 endTold\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2018-04-09 21:04 endTold\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2018-05-02 22:31 endTold\src\
文件 5625 2018-05-01 23:04 endTold\src\applicationContext.xml
目录 0 2018-05-02 22:31 endTold\src\cn\
目录 0 2018-05-02 22:31 endTold\src\cn\cyj\
目录 0 2018-05-02 22:31 endTold\src\cn\cyj\action\
文件 4238 2018-05-04 21:43 endTold\src\cn\cyj\action\AdminAction.java
文件 3884 2018-05-07 14:47 endTold\src\cn\cyj\action\ArticleAction.java
文件 694 2018-05-02 10:33 endTold\src\cn\cyj\action\EmailAction.java
文件 2345 2018-04-27 20:30 endTold\src\cn\cyj\action\ImgCodeAction.java
文件 3195 2018-04-23 14:16 endTold\src\cn\cyj\action\MessageAction.java
文件 5560 2018-05-03 18:23 endTold\src\cn\cyj\action\UserAction.java
目录 0 2018-05-08 16:40 endTold\src\cn\cyj\dao\
文件 1614 2018-05-03 20:18 endTold\src\cn\cyj\dao\AdminDao.java
文件 4950 2018-05-07 17:27 endTold\src\cn\cyj\dao\ArticleDao.java
文件 2690 2018-05-02 22:32 endTold\src\cn\cyj\dao\EmailDao.java
文件 3484 2018-04-23 14:43 endTold\src\cn\cyj\dao\MessageDao.java
文件 1678 2018-04-20 23:06 endTold\src\cn\cyj\dao\UserDao.java
............此处省略504个文件信息
评论
共有 条评论