📄 catalogserviceimpl.java
字号:
package com.barter.catalog.service.impl;
import java.util.List;
import com.barter.catalog.dao.ICatalogDao;
import com.barter.catalog.dto.CatalogDto;
import com.barter.catalog.service.ICatalogService;
import com.barter.model.Catalog;
import com.barter.util.DateUtil;
import com.sino.framework.exception.DaoException;
import com.sino.framework.exception.ServiceException;
import com.sino.framework.hibernate.HibernateDao;
import com.sino.framework.util.Page;
public class CatalogServiceImpl implements ICatalogService {
private HibernateDao demoDao;
private ICatalogDao catalogDao;
public ICatalogDao getCatalogDao() {
return catalogDao;
}
public void setCatalogDao(ICatalogDao catalogDao) {
this.catalogDao = catalogDao;
}
public HibernateDao getDemoDao() {
return demoDao;
}
public void setDemoDao(HibernateDao demoDao) {
this.demoDao = demoDao;
}
@SuppressWarnings("static-access")
public void saveCatalog(CatalogDto catalogDto) throws ServiceException {
Catalog catalog = new Catalog();
demoDao.copyDto2Entity(catalogDto, catalog);
if(catalogDto.getCreateDated() != null){
catalog.setCreateDate(DateUtil.string2Date(catalogDto.getCreateDated(),"MM-dd-yyyy HH:mm:ss"));
}
demoDao.save(catalog);
}
public <E>List<E> getProjectType(Class<E> entityClass) throws ServiceException, DaoException {
return demoDao.getAll(entityClass);
}
public <E> List<E> getOrg(Class<E> entityClass) throws ServiceException {
return demoDao.getAll(entityClass);
}
public <E> List<E> getCatalog(Class<E> entityClass) throws ServiceException {
return demoDao.getAll(entityClass,"createDate",false);
}
@SuppressWarnings("unchecked")
public void removeCatalogById(Class entityClass,String id) throws ServiceException {
demoDao.removeByPrimaryKey(entityClass, id);
}
@SuppressWarnings({ "unchecked", "static-access" })
public CatalogDto findCatalogById(Class<Catalog> entityClass, String id) throws ServiceException {
Catalog catalog = demoDao.get(entityClass, id);
CatalogDto catalogDto = new CatalogDto();
demoDao.copyEntity2Dto(catalogDto, catalog);
if(catalog.getCreateDate() != null){
catalogDto.setCreateDated(catalog.getCreateDate().toString());
}
if(catalog.getUpdateDate() != null){
catalogDto.setUpdateDated(catalog.getUpdateDate().toString());
}
return catalogDto;
}
@SuppressWarnings("static-access")
public void updateCatalogById(CatalogDto catalogDto) throws ServiceException {
Catalog catalog = demoDao.get(Catalog.class, catalogDto.getId());
catalogDto.setCreateDate(catalog.getCreateDate());
catalogDto.setCreator(catalog.getCreator());
demoDao.copyDto2Entity(catalogDto, catalog);
if(catalogDto.getUpdateDated() != null){
catalog.setUpdateDate(DateUtil.string2Date(catalogDto.getUpdateDated(),"MM-dd-yyyy HH:mm:ss"));
}
demoDao.update(catalog);
}
public CatalogDto findCatalogByIdToView(String id) throws ServiceException {
return catalogDao.findCatalogById(id);
}
public Page getCatalogByName(int pageNo,int pageSize,String name) throws ServiceException {
return catalogDao.getCatalogByName(pageNo, pageSize,name);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -