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

📄 worksaction.java

📁 在线读书交流平台
💻 JAVA
字号:
package com.olr.control.space;

import java.util.Date;

import com.olr.BO.SpaceBO;
import com.olr.beans.Book;
import com.olr.beans.Chapter;
import com.olr.beans.User;
import com.olr.control.common.PageAction;
import com.olr.util.Constants;
import com.olr.util.Pager;

public  class WorksAction extends PageAction{
	
	private SpaceBO spaceBO;
	//书籍字段信息
	private Integer bookId;
	private String bookname;
	private String writer;
	private Integer userId;
	private Integer status;
	private Integer price;
	private String category;
	private Date updateTime;
	private Integer chapterCount;
	private String discription;
	private String notice;
	private String label;
	private String imagePath;
	//章节字段信息
	private Integer chapterId;
	private String chapterName;
	private Integer chapterNum;
	private String chapterText;
	private Date postdate;
	//页面数据
	private User spaceOwner;
	private Book works;
	private Chapter chapter;
	private Pager worksPager;
	
	//验证用户输入信息
	public  void validate() {
		this.clearErrorsAndMessages();
		String queryString=this.getRequestPath();
		if(queryString.indexOf("works!addWorks")!=-1){
			if(bookname==null||bookname.equals("")){
				this.addFieldError("bookname", "书名不能空");
			}
			if(writer==null||writer.equals("")){
				this.addFieldError("writer", "作者名不能为空");
			}		
		}
		
		
	}
	
	
	
	//初始化分页数据
	public String init(){
		this.clearErrorsAndMessages();
		String spaceOwnerName=(String) this.getSession("spaceOwnerName");
		spaceOwner=this.getSpaceBO().getUser(spaceOwnerName);
		userId=spaceOwner.getUserId();
		super.pageSize=Constants.pageSize;
		super.pageNo=Constants.pageNo;

		super.pager=this.getSpaceBO().getWorksPager(spaceOwner.getUserId(), pageNo, pageSize);
		worksPager=super.pager;
		//this.setSession("worksPager", super.pager);
		return "list";
	}
	//显示所有作品列表
	public  String list() {
		this.clearErrorsAndMessages();
		super.pager=this.getSpaceBO().getWorksPager(spaceOwner.getUserId(), pageNo, pageSize);
		worksPager=super.pager;
		//this.setSession("worksPager", super.pager);
		return "list";
	}
	//修改书籍信息
	public  String editWorks() {
		works=this.getSpaceBO().getWorks(bookId);//初始化works
		return "editWorks";
	}
	//更新书籍信息
	public  String updateWorks() {
		String imagePath=this.getSpaceBO().getWorks(this.getWorks().getBookId()).getImagePath();
		Book nworks =new Book();
		nworks=this.getWorks();
		nworks.setBookname(this.getBookname());
		nworks.setWriter(this.getWriter());
		nworks.setCategory(this.getCategory());
		nworks.setNotice(this.getNotice());
		nworks.setDiscription(this.getDiscription());
		nworks.setLabel(this.getLabel());
		nworks.setStatus(this.getStatus());
		nworks.setPrice(this.getPrice());
		nworks.setUpdateTime(new Date());
		nworks.setImagePath(imagePath);
		this.getSpaceBO().updateWorks(nworks);
		
		return "list";
	}
	//创建新的作品
	public  String newWorks() {
		
		return "addWorks";
	}
	//添加作品
	public String addWorks() {
		Book nworks=new Book();
		nworks.setChapterCount(0);
		nworks.setClickCount(0);
		nworks.setLastChapter("");
		nworks.setStatus(this.getStatus());
		nworks.setNotice(this.getNotice());
		nworks.setRecomCount(0);
	    nworks.setWriter(this.getWriter());
	    nworks.setCategory(this.getCategory());
	    nworks.setBookname(this.getBookname());
	    nworks.setDiscription(this.getDiscription());
	    nworks.setLabel(this.getLabel());
	    nworks.setPrice(this.getPrice());
	    nworks.setUserId(this.userId);
	    nworks.setUpdateTime(new Date());
	    this.getSpaceBO().addWorks(nworks);
	    bookId=this.getSpaceBO().getWorks(bookname).getBookId();
	    this.setWorks(this.spaceBO.getWorks(bookId));
	    Chapter nchapter=new Chapter();
		nchapter.setBookId(bookId);
		nchapter.setChapterNum(this.getWorks().getChapterCount()+1);
		this.setChapter(nchapter);
		return "addChapter";
	}
	//写新的章节
	public  String newChapter() {
		
		Chapter nchapter=new Chapter();
		nchapter.setBookId(bookId);
		this.setWorks(this.spaceBO.getWorks(bookId));
		nchapter.setChapterNum(this.getSpaceBO().getWorks(bookId).getChapterCount()+1);
		this.setChapter(nchapter);
		return "addChapter";
	}
	//添加章节
	public  String addChapter() {
		Chapter nchapter=new Chapter();
		nchapter=this.getChapter();
		nchapter.setChapterName(this.getChapterName());
		nchapter.setChapterText(this.getChapterText());
		nchapter.setPostdate(new Date());
		this.getSpaceBO().addChapter(nchapter);
		return "list";
	}
	//修改章节
	public  String editChapter() {
		chapter=this.getSpaceBO().getChapter(works.getBookId(), chapterNum);
		return "editChapter";
	}
	
	public String updateChapter(){
		Chapter nchapter =new Chapter();
		nchapter=this.getChapter();
		nchapter.setChapterName(chapterName);
		nchapter.setChapterText(chapterText);
		nchapter.setPostdate(new Date());
		this.getSpaceBO().updateChapter(nchapter);
		return "list";
	}
	
	public SpaceBO getSpaceBO() {
		return spaceBO;
	}
	public void setSpaceBO(SpaceBO spaceBO) {
		this.spaceBO = spaceBO;
	}
	public Integer getBookId() {
		return bookId;
	}
	public void setBookId(Integer bookId) {
		this.bookId = bookId;
	}
	public String getBookname() {
		return bookname;
	}
	public void setBookname(String bookname) {
		this.bookname = bookname;
	}
	public String getWriter() {
		return writer;
	}
	public void setWriter(String writer) {
		this.writer = writer;
	}
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Integer getPrice() {
		return price;
	}
	public void setPrice(Integer price) {
		this.price = price;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	public Integer getChapterCount() {
		return chapterCount;
	}
	public void setChapterCount(Integer chapterCount) {
		this.chapterCount = chapterCount;
	}

	public String getDiscription() {
		return discription;
	}
	public void setDiscription(String discription) {
		this.discription = discription;
	}
	public String getNotice() {
		return notice;
	}
	public void setNotice(String notice) {
		this.notice = notice;
	}
	public String getLabel() {
		return label;
	}
	public void setLabel(String label) {
		this.label = label;
	}
	public Integer getChapterId() {
		return chapterId;
	}
	public void setChapterId(Integer chapterId) {
		this.chapterId = chapterId;
	}
	public String getChapterName() {
		return chapterName;
	}
	public void setChapterName(String chapterName) {
		this.chapterName = chapterName;
	}
	public Integer getChapterNum() {
		return chapterNum;
	}
	public void setChapterNum(Integer chapterNum) {
		this.chapterNum = chapterNum;
	}
	public String getChapterText() {
		return chapterText;
	}
	public void setChapterText(String chapterText) {
		this.chapterText = chapterText;
	}
	public Date getPostdate() {
		return postdate;
	}
	public void setPostdate(Date postdate) {
		this.postdate = postdate;
	}



	public String getImagePath() {
		return imagePath;
	}



	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}



	public User getSpaceOwner() {
		return spaceOwner;
	}



	public void setSpaceOwner(User spaceOwner) {
		this.spaceOwner = spaceOwner;
	}



	public Book getWorks() {
		return works;
	}



	public void setWorks(Book works) {
		this.works = works;
	}



	public Chapter getChapter() {
		return chapter;
	}



	public void setChapter(Chapter chapter) {
		this.chapter = chapter;
	}
	
	
	
	
	
	
}

⌨️ 快捷键说明

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