CategoryService.java~6~
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:2k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- package com.chinacannel.xlchemical.service;
- import com.chinacannel.common.TranUtil;
- import com.chinacannel.common.CommonDAO;
- import org.apache.commons.logging.LogFactory;
- import org.apache.commons.logging.Log;
- import com.chinacannel.common.DAOException;
- import com.chinacannel.entity.Category;
- import java.util.List;
- public class CategoryService extends TranUtil {
- private CommonDAO dao = new CommonDAO();
- private static Log log = LogFactory.getLog(CategoryService.class);
- public Category GetCategoryById(Long Id) {
- try {
- return (Category) dao.loadObject(Id, Category.class);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- }
- public boolean AddCategory(Category cat) {
- try {
- return dao.createObject(cat);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public boolean UpdateCategory(Category cat) {
- try {
- return dao.updateObject(cat);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public List getCategoryListByStyle(String key) {
- try {
- return dao.loadObjectListBySQL(
- "from Category as cat where cat.cat_Key='" + Key + "'");
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- }
- public boolean DeleteCategory(Category cat) {
- try {
- return dao.removeObject(cat);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- }