package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.DeviceMaintainMapper;
|
import com.whyc.pojo.DeviceMaintain;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class DeviceMaintainService {
|
|
@Resource
|
private DeviceMaintainMapper mapper;
|
|
public Response get(Integer deviceId) {
|
QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
|
wrapper.eq("status",1).eq("device_id",deviceId);
|
DeviceMaintain deviceMaintain = mapper.selectOne(wrapper);
|
return new Response().set(1,deviceMaintain);
|
}
|
|
public Response add(DeviceMaintain deviceMaintain) {
|
mapper.insert(deviceMaintain);
|
return new Response().set(1,"创建成功");
|
}
|
|
public Response update(DeviceMaintain deviceMaintain) {
|
mapper.updateById(deviceMaintain);
|
return new Response().set(1,"修改成功");
|
}
|
|
public Response confirm(DeviceMaintain deviceMaintain) {
|
//确认维护,维护状态更新为0
|
deviceMaintain.setStatus(0);
|
deviceMaintain.setActualTime(new Date());
|
mapper.updateById(deviceMaintain);
|
return new Response().set(1,"确认成功");
|
}
|
|
public Response getRecord(Integer deviceId) {
|
QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
|
wrapper.select("actual_time","actual_owner2","content").eq("status",0).eq("device_id",deviceId);
|
List<DeviceMaintain> deviceMaintains = mapper.selectList(wrapper);
|
return new Response().set(1,deviceMaintains);
|
}
|
|
public Response getPage(Integer pageNum, Integer pageSize) {
|
QueryWrapper<Object> wrapper = Wrappers.query();
|
return null;
|
}
|
}
|