📄 storagehouseserviceimpl.java
字号:
package com.shunshi.ssh.service;
import java.util.List;
import org.extremecomponents.table.limit.Limit;
import com.shunshi.ssh.dao.IAllInfoDao;
import com.shunshi.ssh.dao.IStoragehouseDao;
import com.shunshi.ssh.entity.Agent;
import com.shunshi.ssh.entity.AllInfo;
import com.shunshi.ssh.entity.Page;
import com.shunshi.ssh.entity.StorageHouse;
import com.shunshi.ssh.exception.AgentDaoException;
import com.shunshi.ssh.exception.StoragehouseDaoException;
import com.shunshi.ssh.exception.StoragehouseServiceException;
public class StoragehouseServiceImpl implements IStoragehouseService {
private IStoragehouseDao dao;
private IAllInfoDao allInfoDao;
public IStoragehouseDao getDao() {
return dao;
}
public IAllInfoDao getAllInfoDao() {
return allInfoDao;
}
public void setAllInfoDao(IAllInfoDao allInfoDao) {
this.allInfoDao = allInfoDao;
}
public void setDao(IStoragehouseDao dao) {
this.dao = dao;
}
public void addStoragehouse(StorageHouse storagehouse) throws StoragehouseServiceException {
try {
dao.add(storagehouse);
} catch (StoragehouseDaoException e) {
throw new StoragehouseServiceException(e.getMessage());
}
}
public void delete(int[] id) throws StoragehouseServiceException {
for(int i:id){
try {
dao.delete(i);
} catch (StoragehouseDaoException e) {
throw new StoragehouseServiceException("删除仓储信息出错");
}
}
}
public List findAll() throws StoragehouseServiceException {
try {
return dao.findAll();
} catch (StoragehouseDaoException e) {
throw new StoragehouseServiceException("查找所有仓储信息出错");
}
}
public StorageHouse findById(int id) throws StoragehouseServiceException {
try {
return dao.findById(id);
} catch (StoragehouseDaoException e) {
throw new StoragehouseServiceException("查找仓储信息出错");
}
}
public List findByUser(int id) throws StoragehouseServiceException {
List l=null;
try {
l= dao.findByUserId(id);
} catch (StoragehouseDaoException e) {
throw new StoragehouseServiceException("查找用户出错");
}
return l;
}
public void update(StorageHouse s) throws StoragehouseServiceException {
try {
dao.updateStoragehouse(s);
} catch (StoragehouseDaoException e) {
throw new StoragehouseServiceException("更新仓储信息出错");
}
}
public void updateState(int id, int state) throws StoragehouseServiceException {
try {
dao.updateState(id, state);
} catch (StoragehouseDaoException e) {
throw new StoragehouseServiceException("更新仓储信息状态出错");
}
}
public Page findByState(int state, Limit size, int totalRows)
throws StoragehouseServiceException {
try{
if (totalRows < 0) {
totalRows = dao.getTotalRowsByState(state).intValue();
}
size.setRowAttributes(totalRows, Page.DEFAULT_PAGE_SIZE);
int[] startAndEnd= new int[]{size.getRowStart(),size.getCurrentRowsDisplayed()};
List l=dao.findByState(state, startAndEnd[0],startAndEnd[1]);
Page page = new Page(size.getRowStart(),totalRows,size.getPage(),l);
return page;
}catch(StoragehouseDaoException e){
throw new StoragehouseServiceException(e.getMessage());
}
}
public AllInfo getAllInfo() throws StoragehouseServiceException {
StorageHouse sh=null;
try {
sh = dao.findByMaxId();
} catch (StoragehouseDaoException e) {
e.printStackTrace();
}
AllInfo info=new AllInfo();
info.setName(sh.getTitle());
info.setType("仓储需求信息");
info.setClassType("storagehouse");
info.setUserId(sh.getUserId().longValue());
info.setBid(sh.getId().longValue());
return info;
}
public void saveAllInfo(AllInfo allInfo)
throws StoragehouseServiceException {
allInfoDao.addInfo(allInfo);
}
public void deleteAllInfo(StorageHouse sh)
throws StoragehouseServiceException {
allInfoDao.deleteObject(sh);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -