📄 courseserviceimp.java
字号:
package com.tech.service.imp;
import java.util.List;
import com.common.dao.DaoSupport;
import com.common.exception.BusinessException;
import com.common.util.BeanUtils;
import com.tech.model.Course;
import com.tech.service.CourseService;
public class CourseServiceImp implements CourseService {
private DaoSupport<Course,Long> courseDao;
public void setCourseDao(DaoSupport<Course, Long> courseDao) {
this.courseDao = courseDao;
}
@Override
public Course getEntity(Long id) throws BusinessException {
try{
return courseDao.getEntity(id);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("CourseServiceImp 不能获取主键为:" + id
+ "的数据" + e.toString());
}
}
@Override
public boolean isExists(Course t, List<String> names)
throws BusinessException {
try{
return courseDao.isExists(t,names);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("查找异常:" + e.getMessage());
}
}
@Override
public Course loadEntity(Long id) throws BusinessException {
try{
return courseDao.loadEntity(id);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("CourseServiceImp 不能获取主键为:" + id
+ "的数据" + e.toString());
}
}
@Override
public void removeEntity(Course entity) throws BusinessException {
try{
courseDao.removeEntity(entity);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("删除异常:"
+ e.getMessage());
}
}
@Override
public void removeEntity(Course[] array) throws BusinessException {
try{
courseDao.removeEntity(array);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("删除异常:"
+ e.getMessage());
}
}
@Override
public void saveEntity(Course entity) throws BusinessException {
try{
courseDao.saveEntity(entity);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("添加异常:"
+ e.getMessage());
}
}
@Override
public void saveEntity(Course[] array) throws BusinessException {
try{
courseDao.saveEntity(array);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("添加异常:"
+ e.getMessage());
}
}
@Override
public void updateEntity(Course entity) throws BusinessException {
try{
Course entityLoad = courseDao.getEntity(entity.getId());
// 拷贝不需要更新的字段内容
BeanUtils.copyProperties(entityLoad,entity);
courseDao.updateEntity(entityLoad);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("更新异常:"
+ e.getMessage());
}
}
@Override
public void updateEntity(Course[] array) throws BusinessException {
try{
courseDao.updateEntity(array);
} catch (Exception e){
e.printStackTrace();
throw new BusinessException("更新异常:"
+ e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -