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;
|
}*/
|
|
|
}
|