AdaKing88
2023-08-23 ae35159387a55199e8ab150ebb97d89d68a235bd
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package org.jeecg.modules.arj.b.controller;
 
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.modules.arj.b.entity.Sbjx;
import org.jeecg.modules.arj.b.service.SbjxService;
import org.jeecg.modules.arj.b.vo.SbjxVo;
import org.jeecg.modules.arj.config.AjaxResult;
import org.jeecg.modules.arj.entity.Head;
import org.jeecg.modules.arj.mapper.HeadMapper;
import org.jeecg.modules.arj.service.HeadService;
import org.jeecg.modules.arj.vo.HanjiVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
 
/*其中org.jeecg.modules.arj.b.service就等于 com.example.demo.service,SbjxService就等于SpiderdataSpiderxrmmwService*/
/*其中org.jeecg.modules.arj.b.entity就等于com.example.demo.entity,Sbjx就等于SpiderdataSpiderxrmmw,一种Java的模板引擎语法*/
 
/**
 * <p>
 * 检修计划表 前端控制器
 * </p>
 *
 * @author hyy
 * @since 2023-05-08
 */
@Api(tags = "B2-检修计划表")
@RestController
@RequestMapping("/b/sbjx")
public class SbjxController {
 
    @Resource
    private SbjxService sbjxService;
 
    @Autowired
    private HeadService headService;
 
    @Autowired
    private HeadMapper headMapper;
 
 
    //新增和修改接口
    @ApiOperation("增加新数据")
    @PostMapping("/add")
    public AjaxResult save(@RequestBody SbjxVo sbjxVo) {
        //新增或者更新
        Head h = headService.insert(sbjxVo.getHead());
        sbjxVo.getSbjxList().stream().forEach(item -> item.setHeadId(h.getId()));
        sbjxService.saveOrUpdateBatch(sbjxVo.getSbjxList());
 
        return AjaxResult.success(h.getId());
    }
    @ApiOperation("通过ID查询单条数据")
    @GetMapping("/id")
    public AjaxResult queryById(String id){
        SbjxVo sbjxVo = new SbjxVo();
        Head head = headService.queryById(id);
 
        if( head == null ) return  AjaxResult.error("访问无数据");
 
 
        sbjxVo.setHead(head);
        sbjxVo.setSbjxList(sbjxService.queryByHeadId(head.getId()));
        return AjaxResult.success(sbjxVo);
 
    }
 
 
 
 
 
    /**
     * 获取最新数据
     *
 
     * @return 实例对象
     */
    @ApiOperation("获取最新数据")
    @PostMapping("/last")
    public AjaxResult getlastRecord(@RequestBody  String leixing){
 
        Head head =  headService.queryLeixingChanxian("B2",null);
        SbjxVo sbjxVo = new SbjxVo();
 
        if( head == null ) return  AjaxResult.error("访问无数据");
        List<Sbjx> sbjxList = sbjxService.queryByHeadId(head.getId());
        sbjxVo.setHead(head);
        sbjxVo.setSbjxList(sbjxList);
        return AjaxResult.success(sbjxVo);
    }
 
}