whyclxw
1 天以前 7a8d50965cb69ecc348a6b11d902409628012cd0
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.AlarmInspectionResultMapper;
import com.whyc.pojo.web_site.AlarmInspectionResult;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class AlarmInspectionResultService {
 
    @Resource
    private AlarmInspectionResultMapper mapper;
 
    public void add(AlarmInspectionResult result) {
        mapper.insert(result);
    }
 
    public Response<PageInfo<AlarmInspectionResult>> getPage(Integer pageNum, Integer pageSize, Integer stationId, Integer inspectionType) {
        PageHelper.startPage(pageNum, pageSize);
        QueryWrapper<AlarmInspectionResult> query = Wrappers.query();
        query.eq(stationId  != null,"station_id", stationId);
        query.eq(inspectionType  != null,"inspection_type", inspectionType);
        query.orderByDesc("id");
        List<AlarmInspectionResult> list = mapper.selectList(query);
        PageInfo<AlarmInspectionResult> pageInfo = new PageInfo<>(list);
        return new Response<PageInfo<AlarmInspectionResult>>().set(1, pageInfo);
    }
}