whycrzg
2021-03-29 0e4534e51dbea1eb0b95d61cc7d0206022ead4a1
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whyc.dto.Response;
import com.whyc.dto.DeviceTypeDTO;
import com.whyc.mapper.DeviceInfMapper;
import com.whyc.pojo.DeviceInf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;
 
@Service
@Slf4j
public class DeviceInfService {
 
    @Resource
    private DeviceInfMapper mapper;
 
    public Response<List<DeviceTypeDTO>> getAll() {
        /*QueryWrapper<DeviceInf> query = Wrappers.query();
        query.select("system_id","system_name","GROUP_concat(device_id,\"-\",device_name) as deviceName").groupBy("system_id");
        List<DeviceInf> deviceInfs = mapper.selectList(query);*/
        List<DeviceTypeDTO> systemList = mapper.getAll();
        System.out.println(System.getProperty("user.timezone"));
        log.info("当前系统时区:{}",System.getProperty("user.timezone"));
 
        return new Response<List<DeviceTypeDTO>>().set(1,systemList);
    }
 
    public DeviceInf getOneByDeviceId(Integer deviceId){
        QueryWrapper<DeviceInf> queryWrapper = Wrappers.query();
        queryWrapper.eq("device_id",deviceId);
        DeviceInf deviceInf = mapper.selectOne(queryWrapper);
        return deviceInf;
    }
 
    public Response<List<DeviceInf>> getListBySystemId(Integer systemId){
        QueryWrapper<DeviceInf> queryWrapper = Wrappers.query();
        queryWrapper.eq("system_id",systemId);
        List<DeviceInf> list = mapper.selectList(queryWrapper);
        return new Response<List<DeviceInf>>().set(1,list);
    }
 
    public void update(DeviceInf deviceInf) {
        UpdateWrapper<DeviceInf> updateWrapper = Wrappers.update();
        updateWrapper.eq("device_id", deviceInf.getDeviceId());
        mapper.update(deviceInf,updateWrapper);
    }
 
   /* public Response update(@NotNull @NotNull DeviceInf deviceInf){
        UpdateWrapper<DeviceInf> updateWrapper = Wrappers.update();
        updateWrapper.eq("device_id",deviceInf.getDeviceId());
        Response res = new Response();
        if(mapper.update(deviceInf,updateWrapper)>0){
            res.set(1,deviceInf,"加载默认参数成功!");
        }
 
        return res;
    }*/
 
 
}