whyclxw
2024-10-31 d17a00b03b2553f16b7957abf97e1481c9a36d58
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.whyc.mapper.CircleInfMapper;
import com.whyc.pojo.CircleInf;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
 
@Service
public class CircleInfService {
 
    @Resource
    private CircleInfMapper mapper;
 
    public int add(CircleInf circleInf){
        return mapper.insert(circleInf);
    }
 
    public void updateByDeviceId(CircleInf circleInf){
        UpdateWrapper<CircleInf> wrapper = new UpdateWrapper<CircleInf>().eq("device_id",circleInf.getDeviceId());
        mapper.update(circleInf,wrapper);
    }
 
    public void deleteByDeviceId(Integer deviceId){
        QueryWrapper<CircleInf> wrapper = new QueryWrapper<CircleInf>().eq("device_id",deviceId);
        mapper.delete(wrapper);
    }
    //获取动环的设备id
    public String getDeviceId() {
        Integer devId = mapper.getMaxDeviceId();
        if(devId==null||devId==0){
            devId = 120*1000000;
        }
        devId+=1;
        return String.valueOf(devId);
    }
}