bulletionaction.java
来自「有简单的网上书店需求及设计流程」· Java 代码 · 共 109 行
JAVA
109 行
package org.wiely.action;
import java.util.List;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;
import org.wiely.service.AdminService;
import org.wiely.service.BookService;
import org.wiely.service.BulletionService;
import org.wiely.vo.Bulletion;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
/**
* the action extends ActionSupport the BulletionAction is the action to
* provides services for adminnistrator and they can update the content of
* bulletion
*
* @param bulletonService
* @param bookService
* @param adminService
*/
@SuppressWarnings("serial")
public class BulletionAction extends ActionSupport implements SessionAware {
protected BulletionService bulletionService;
protected AdminService adminService;
protected BookService bookService;
String content;
@SuppressWarnings("unchecked")
Map session;
public BulletionService getBulletionService() {
return bulletionService;
}
public void setBulletionService(BulletionService bulletionService) {
this.bulletionService = bulletionService;
}
@SuppressWarnings("unchecked")
@Override
public void setSession(Map session) {
this.session = session;
}
public AdminService getAdminService() {
return adminService;
}
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
/**
* @return String
* @throws Exception
* @see provides the all data for index.jsp
* session object content ,newbooks.
*/
@SuppressWarnings("unchecked")
public String execute() throws Exception {
String content = bulletionService.showMess();
List newbooks = bookService.getNewBooks();
Map session = (Map) ActionContext.getContext().getSession();
session.put("content", content);
session.put("newbooks", newbooks);
return SUCCESS;
}
/**
* @see update bulletion by adminid of maxscore.
* @return String
* @throws Exception
*/
public String update() throws Exception {
int adminid = (Integer) session.get("adminid");
if (adminService.isMaxScore(adminid)) {
Bulletion bulletion = new Bulletion();
int bid = bulletionService.queryIdByAdminid(adminid);
bulletion.setBid(bid);
bulletion.setContent(content);
bulletionService.updateBulletion(bulletion);
return SUCCESS;
} else {
return ERROR;
}
}
public BookService getBookService() {
return bookService;
}
public void setBookService(BookService bookService) {
this.bookService = bookService;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?