admin
2021-08-02 e89de9319d8f771f8e53cb5f876d06465a580c57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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);
    }
}