yujian
2019-09-03 2ddf5b8a1290123e2d1c05bcc851ec35cd217afc
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.yeshi.fanli.service.impl.homemodule;
 
import java.util.Date;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.yeshi.fanli.dao.mybatis.homemodule.SpecialPlaceMapper;
import com.yeshi.fanli.entity.bus.homemodule.SpecialPlace;
import com.yeshi.fanli.exception.homemodule.SpecialPlaceException;
import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
 
@Service
public class SpecialPlaceImpl implements SpecialPlaceService {
 
    @Resource
    private SpecialPlaceMapper specialPlaceMapper;
    
    
    @Override
    public SpecialPlace selectByPrimaryKey(Long id) {
        return specialPlaceMapper.selectByPrimaryKey(id);
    }
    
    
    @Override
    public void saveObject(SpecialPlace record) throws SpecialPlaceException, Exception{
        
        String placeName = record.getName();
        if (placeName == null || placeName.trim().length() == 0) {
            throw new SpecialPlaceException(1, "位置名称不能为空");
        }
        
        String key = record.getKey();
        if (key == null || key.trim().length() == 0) {
            throw new SpecialPlaceException(1, "位置标识不能为空");
        }
        
        Long id = record.getId();
        if (id == null) {
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            specialPlaceMapper.insert(record);
        } else {
            // 修改
            SpecialPlace resultObj = specialPlaceMapper.selectByPrimaryKey(id);
            if (resultObj == null) {
                throw new SpecialPlaceException(1, "修改内容已不存在");
            }
 
            record.setCreateTime(resultObj.getCreateTime());
            record.setUpdateTime(new Date());
            specialPlaceMapper.updateByPrimaryKey(record);
        }
    }
    
 
    @Override
    @Transactional
    public int deleteByPrimaryKeyList(List<Long> list) throws Exception{
        return specialPlaceMapper.deleteByPrimaryKeyList(list);
    }
 
    
 
    @Override
    public List<SpecialPlace> listQuery(long start, int count, String key) throws Exception {
        return specialPlaceMapper.listQuery(start, count, key);
    }
 
 
    @Override
    public long countQuery(String key) {
        return specialPlaceMapper.countQuery(key);
    }
 
    @Override
    public List<SpecialPlace> getEffectiveList() {
        return specialPlaceMapper.getAll();
    }
    
}