工业级运维app手机api
xufenglei
2017-11-14 91e5d3d85c737b96b2c4a1994e2b861cc083453c
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
package com.moral.monitor.service.impl;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
 
import com.moral.monitor.dao.EquipmentMapper;
import com.moral.monitor.entity.Equipment;
import com.moral.monitor.entity.EquipmentExample;
import com.moral.monitor.service.EquipmentService;
 
/**
 * @author fengxiang
 * @Time:2017年10月31日 上午10:15:58
 * @version 1.0
 */
@Service
public class EquipmentServiceImpl implements EquipmentService {
    @Resource
    private EquipmentMapper mapper;
    //根据example条件查询
    public List<Equipment> queryListByExample(EquipmentExample example){
         return mapper.selectByExample(example);
    }
    
    public long queryCountByExample(EquipmentExample example) {
        return mapper.countByExample(example);
    }
    
    public void updateByMac(Equipment equipment) {
        if(StringUtils.isEmpty(equipment.getMac())) {
            throw new RuntimeException("equipment.mac cannot be null");
        }
        EquipmentExample example = new EquipmentExample();
        example.or().andMacEqualTo(equipment.getMac());
        mapper.updateByExampleSelective(equipment, example);
    }
    public void insertRecord(Equipment equipment) {
        mapper.insertSelective(equipment);
    }
}