whycxzp
2023-05-12 d3465e119e5795a3addee8e3d3ae0ecc8a99fcc4
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
package com.whyc.service;
 
import com.whyc.dto.Response;
import com.whyc.dto.interfaceC.DataC;
import com.whyc.dto.interfaceC.PointC;
import com.whyc.mapper.InterfaceCDataMapper;
import com.whyc.mapper.InterfaceCPointMapper;
import com.whyc.pojo.InterfaceCData;
import com.whyc.pojo.InterfaceCPoint;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@Service
public class DataService {
 
    @Resource
    private InterfaceCDataMapper interfaceCDataMapper;
 
    @Resource
    private InterfaceCPointMapper interfaceCPointMapper;
 
    public void add(InterfaceCData data) {
        Date now = new Date();
        data.setCreate_time(now);
        interfaceCDataMapper.insert(data);
        List<InterfaceCPoint> points = data.getPoints();
        points.stream().forEach(point->{point.setCreate_time(now);point.setData_id(data.getId());});
        interfaceCPointMapper.insertBatchSomeColumn(points);
 
    }
 
    public Response getDataList() {
        List<InterfaceCData> dataList = interfaceCDataMapper.getDataList();
        return new Response().set(1,dataList);
    }
}