package com.yeshi.buwan.service.imp.search;
|
|
import com.yeshi.buwan.dao.search.SearchSpecialPositionDao;
|
import com.yeshi.buwan.domain.special.SearchSpecialPosition;
|
import com.yeshi.buwan.exception.ParamsException;
|
import com.yeshi.buwan.service.inter.search.SearchSpecialPositionService;
|
import com.yeshi.buwan.util.StringUtil;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.UUID;
|
|
@Service
|
public class SearchSpecialPositionServiceImpl implements SearchSpecialPositionService {
|
|
@Resource
|
private SearchSpecialPositionDao searchSpecialPositionDao;
|
|
@Override
|
public SearchSpecialPosition add(SearchSpecialPosition position) throws ParamsException, Exception {
|
if (position == null || StringUtil.isNullOrEmpty(position.getName()) || StringUtil.isNullOrEmpty(position.getSystemId())) {
|
throw new ParamsException("参数不完整");
|
}
|
if (position.getId() == null) {
|
position.setId(UUID.randomUUID().toString());
|
}
|
if (position.getCreateTime() == null) {
|
position.setCreateTime(new Date());
|
}
|
//查询是否存在
|
SearchSpecialPosition old = searchSpecialPositionDao.get(position.getId());
|
if (old != null)
|
throw new Exception("位置已存在");
|
searchSpecialPositionDao.save(position);
|
return position;
|
}
|
|
@Override
|
public void updateSelective(SearchSpecialPosition position) {
|
if (position == null || position.getId() == null)
|
return;
|
if (position.getUpdateTime() == null) {
|
position.setUpdateTime(new Date());
|
}
|
searchSpecialPositionDao.updateSelective(position);
|
}
|
|
@Override
|
public List<SearchSpecialPosition> list(String systemId, String key, int page, int pageSize) {
|
SearchSpecialPositionDao.DaoQuery daoQuery = new SearchSpecialPositionDao.DaoQuery();
|
daoQuery.key = key;
|
daoQuery.systemId = systemId;
|
daoQuery.start = (page - 1) * pageSize;
|
daoQuery.count = pageSize;
|
return searchSpecialPositionDao.list(daoQuery);
|
}
|
|
@Override
|
public long count(String systemId, String key) {
|
SearchSpecialPositionDao.DaoQuery daoQuery = new SearchSpecialPositionDao.DaoQuery();
|
daoQuery.key = key;
|
daoQuery.systemId = systemId;
|
return searchSpecialPositionDao.count(daoQuery);
|
}
|
|
@Override
|
public void delete(String id) {
|
searchSpecialPositionDao.delete(id);
|
}
|
}
|