75 lines
2.2 KiB
Java
75 lines
2.2 KiB
Java
|
|
package com.whdc.zhdbaqapi.service.impl;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||
|
|
import com.whdc.zhdbaqapi.constant.Constants;
|
||
|
|
import com.whdc.zhdbaqapi.mapper.DeviceInfoMapper;
|
||
|
|
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||
|
|
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
|
||
|
|
import com.whdc.zhdbaqapi.service.IDeviceInfoService;
|
||
|
|
import org.springframework.cache.annotation.CacheEvict;
|
||
|
|
import org.springframework.cache.annotation.Cacheable;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
import java.io.Serializable;
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @author 李赛
|
||
|
|
* @date 2022-07-21 23:47
|
||
|
|
*/
|
||
|
|
@Service
|
||
|
|
public class DeviceInfoServiceimpl extends ServiceImpl<DeviceInfoMapper, DeviceInfo> implements IDeviceInfoService {
|
||
|
|
@Override
|
||
|
|
public DeviceInfo get(Integer id) {
|
||
|
|
return baseMapper.selectById(id);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
@CacheEvict(Constants.CACHE_NAME)
|
||
|
|
public boolean restore(Integer id) {
|
||
|
|
DeviceInfo entity = baseMapper.selectById(id);
|
||
|
|
entity.setDel(0);
|
||
|
|
return super.updateById(entity);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public List<DeviceInfo> list(String stationCode) {
|
||
|
|
return baseMapper.list(stationCode);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
@Cacheable(Constants.CACHE_NAME)
|
||
|
|
public List<DeviceInfo> listAll() {
|
||
|
|
return baseMapper.listAll();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public IPage<DeviceInfo> page(FindDeviceDto findDto) {
|
||
|
|
return baseMapper.page(findDto.getPage(), findDto);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
@CacheEvict(Constants.CACHE_NAME)
|
||
|
|
public boolean save(DeviceInfo entity) {
|
||
|
|
entity.setCreateDate(new Date());
|
||
|
|
return super.save(entity);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
@CacheEvict(Constants.CACHE_NAME)
|
||
|
|
public boolean updateById(DeviceInfo entity) {
|
||
|
|
entity.setModificationTime(new Date());
|
||
|
|
return super.updateById(entity);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
@CacheEvict(Constants.CACHE_NAME)
|
||
|
|
public boolean removeById(Serializable id) {
|
||
|
|
DeviceInfo entity = baseMapper.selectById(id);
|
||
|
|
entity.setDel(1);
|
||
|
|
return super.updateById(entity);
|
||
|
|
}
|
||
|
|
}
|