⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managerbooktypeaction.java

📁 图书管理系统
💻 JAVA
字号:
package com.web.action;import static com.common.BeanFactory.getBean;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.ServletActionContext;import com.bean.Type;import com.opensymphony.xwork2.ActionSupport;import com.service.BooksService;public class ManagerBookTypeAction extends ActionSupport{	private String typename;	private String typeid;	private int currentPage = 1;	private int pageCount;	private int messageCount;	private List<Type> subType;	public String getTypeid() {		return typeid;	}	public void setTypeid(String typeid) {		this.typeid = typeid;	}	public String getTypename() {		return typename;	}	public void setTypename(String typename) {		this.typename = typename;	}	public int getCurrentPage() {		return currentPage;	}	public void setCurrentPage(int currentPage) {		this.currentPage = currentPage;	}	public int getPageCount() {		return pageCount;	}	public void setPageCount(int pageCount) {		this.pageCount = pageCount;	}	public int getMessageCount() {		return messageCount;	}	public void setMessageCount(int messageCount) {		this.messageCount = messageCount;	}	public List<Type> getSubType() {		return subType;	}	public void setSubType(List<Type> subType) {		this.subType = subType;	}		public String bookType() throws Exception{		HttpServletRequest request = ServletActionContext.getRequest();		BooksService service = (BooksService)getBean("booksService");		if("".equals(typeid)||typeid==null)			typeid = "0";		Integer booktypeid = Integer.parseInt(typeid);		List<Type> list = service.findBookType(booktypeid, typename);		if(list==null)			return "success";		request.setAttribute("typeList", list);		separatePage(list);		return "success";	}		public String editorType() throws Exception {		HttpServletRequest request = ServletActionContext.getRequest();		BooksService service = (BooksService)getBean("booksService");		if("".equals(typeid)||typeid==null)			typeid = "0";		Integer booktypeid = Integer.parseInt(typeid);		Type bookType = (Type)service.findBookType(booktypeid, typename).get(0);		request.setAttribute("bookType", bookType);		return "success";	}		public String updateType() throws Exception{		HttpServletRequest request = ServletActionContext.getRequest();		BooksService service = (BooksService)getBean("booksService");		if("".equals(typeid)||typeid==null)			typeid = "0";		Integer booktypeid = Integer.parseInt(typeid);		System.out.println(typeid+"/"+typename);		List list = service.findBookType(booktypeid, typename);		if(list!=null){			request.setAttribute("typemessage", "图书分类名称已经存在");			return "failure";		}		Type bookType = (Type)service.findBookType(booktypeid, null).get(0);		bookType.setName(typename);		service.saveOrUpdateBookType(bookType);		return "success";	}		public String addType() throws Exception{		HttpServletRequest request = ServletActionContext.getRequest();		BooksService service = (BooksService)getBean("booksService");		if("".equals(typeid)||typeid==null)			typeid = "0";		Integer booktypeid = Integer.parseInt(typeid);		List list = service.findBookType(booktypeid, typename);		if(list!=null){			request.setAttribute("typemessage", "编号已经存在");			return "failure";		}		Type bookType = new Type();		bookType.setName(typename);		service.saveOrUpdateBookType(bookType);		return "success";	}		private void separatePage(List<Type> list){		if(list.isEmpty()){			messageCount = 0;			return;		}		messageCount = list.size();		if(list.size()%4==0)			pageCount = list.size()/4;		else			pageCount = list.size()/4 + 1;		if(list.size()>currentPage*4)			subType = list.subList((currentPage-1)*4, currentPage*4);		else			subType = list.subList((currentPage-1)*4, list.size());	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -