whyczh
2021-04-07 4992d0ea3fb6adaba4331fda37c43e8f0d00a458
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
package com.whyc.service;
 
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.DeviceConditionDTO;
import com.whyc.dto.Response;
import com.whyc.mapper.DeviceResourceApplyMapper;
import com.whyc.pojo.DeviceResourceApply;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Service
public class DeviceResourceApplyService {
 
    @Resource
    private DeviceResourceApplyMapper mapper;
 
    public Response getAllDeviceStatus(Integer pageNum,Integer pageSize,DeviceConditionDTO deviceConditionDTO) {
        PageHelper.startPage(pageNum,pageSize);
        List<DeviceResourceApply> deviceResourceApplyMapperList =mapper.getAllDeviceStatus(deviceConditionDTO);
        PageInfo<DeviceResourceApply> deviceResourceApplyPageInfo = new PageInfo<>(deviceResourceApplyMapperList);
        return new Response().set(1,deviceResourceApplyPageInfo);
    }
 
    public Response apply(DeviceResourceApply resourceApply) {
        resourceApply.setApplyTime(new Date());
        resourceApply.setStatus(1);
        mapper.insert(resourceApply);
        return new Response().setMsg(1,"提交成功");
    }
 
    public Response getApplyPage(Integer pageNum, Integer pageSize, DeviceConditionDTO condition) {
        PageHelper.startPage(pageNum,pageSize);
        List<DeviceResourceApply> deviceResourceApplies = mapper.getApplyPage(condition);
        PageInfo<DeviceResourceApply> pageInfo = new PageInfo<>(deviceResourceApplies);
        return new Response().set(1,pageInfo);
    }
 
    public Response approve(Integer id, Integer status) {
        DeviceResourceApply apply = new DeviceResourceApply();
        apply.setId(id);
        apply.setStatus(status);
        apply.setApproveTime(new Date());
        mapper.updateById(apply);
        return new Response().setMsg(1,"审批完成");
    }
 
    public Response getApplyInfo(Integer id) {
        DeviceResourceApply apply = mapper.getApplyInfo(id);
        return new Response().set(1,apply);
    }
}