📄 bookhelper.java
字号:
package com.eline.wap.resource.client;
import com.eline.wap.common.model.Page;
import com.eline.wap.resource.dao.BookDAO;
import com.eline.wap.resource.dao.ResourceDAOFactory;
import com.eline.wap.resource.exceptions.ResourceDAOSysException;
import com.eline.wap.resource.exceptions.ResourceException;
import com.eline.wap.resource.model.Book;
import com.eline.wap.resource.model.BookChapter;
import com.eline.wap.resource.model.BookCondition;
/**
*
* @author Lucifer
*
*/
public class BookHelper {
private BookDAO dao = null;
/**
*
* @param bookId
* @return
* @throws ResourceException
*/
public Book getBook(int bookId) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
return dao.getBook(bookId);
} catch (ResourceDAOSysException e) {
throw new ResourceException(e.getMessage());
}
}
/**
*
* @param condition
* @param start
* @param count
* @return
* @throws ResourceException
*/
public Page searchBooks(BookCondition condition, int start, int count) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
return dao.searchBooks(condition, start, count);
} catch (ResourceDAOSysException e) {
throw new ResourceException(e.getMessage());
}
}
/**
*
* @param item
* @throws ResourceException
*/
public void createBook(Book item) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
dao.createBook(item);
} catch (ResourceDAOSysException e) {
throw new ResourceException(e.getMessage());
}
}
/**
*
* @param item
* @throws ResourceException
*/
public void updateBook(Book item) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
dao.updateBook(item);
} catch (ResourceDAOSysException e) {
throw new ResourceException(e.getMessage());
}
}
/**
*
* @param bookId
* @throws ResourceException
*/
public void deleteBook(int bookId) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
dao.deleteBook(bookId);
} catch (ResourceDAOSysException e) {
throw new ResourceException(e.getMessage());
}
}
/**
*
* @param item
* @throws ResourceException
*/
public void createBookChapter(BookChapter item) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
dao.createBookChapter(item);
} catch (ResourceDAOSysException e) {
throw new ResourceException("ResourceDAOSysException - create book chapter failure : " + e.getMessage());
}
}
/**
*
* @param item
* @throws ResourceException
*/
public void updateBookChapter(BookChapter item) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
dao.updateBookChapter(item);
} catch (ResourceDAOSysException e) {
throw new ResourceException("ResourceDAOSysException - update book chapter failure : " + e.getMessage());
}
}
public void deleteBookChapter(int chapterId) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
dao.deleteBookChapter(chapterId);
} catch (ResourceDAOSysException e) {
throw new ResourceException("ResourceDAOSysException - delete book chapter failure : " + e.getMessage());
}
}
/**
*
* @param bookId
* @param start
* @param count
* @return
* @throws ResourceException
*/
public Page getBookChapters(int bookId, int start, int count) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
return dao.getBookChapters(bookId, start, count);
} catch (ResourceDAOSysException e) {
throw new ResourceException("ResourceDAOSysException - get book chapters failure : " + e.getMessage());
}
}
/**
*
* @param chapterId
* @return
* @throws ResourceException
*/
public BookChapter getBookChapter(int chapterId/*, int start, int count*/) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
return dao.getBookChapter(chapterId/*, start, count*/);
} catch (ResourceDAOSysException e) {
throw new ResourceException("ResourceDAOSysException - get book chapter failure : " + e.getMessage());
}
}
public void setBookChapterSortOrder(int chapterId, int sortOrder) throws ResourceException {
try {
if (dao == null)
dao = ResourceDAOFactory.getBookDAO();
dao.setBookChapterSortOrder(chapterId, sortOrder);
} catch (ResourceDAOSysException e) {
throw new ResourceException("ResourceDAOSysException - get book chapter failure : " + e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -