jinlin
2023-11-10 cb573b4eee7426d0d614fd59f48c1e8575738b8e
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.zt.life.modules.project.controller;
 
 
import com.zt.common.annotation.LogOperation;
import com.zt.common.constant.Constant;
import com.zt.common.annotation.QueryParam;
import com.zt.common.db.query.QueryFilter;
import com.zt.common.servlet.Result;
import com.zt.common.servlet.PageResult;
import com.zt.common.validator.AssertUtils;
import com.zt.common.validator.ValidatorUtils;
import com.zt.common.validator.group.AddGroup;
import com.zt.common.validator.group.DefaultGroup;
import com.zt.common.validator.group.UpdateGroup;
import com.zt.life.modules.project.dto.SoftwareTestOrderDto;
import com.zt.life.modules.project.model.SoftwareTestOrder;
import com.zt.life.modules.project.model.SoftwareTestOrderMeasured;
import com.zt.life.modules.project.service.ProjectService;
import com.zt.life.modules.project.service.SoftwareTestOrderDeliverableService;
import com.zt.life.modules.project.service.SoftwareTestOrderMeasuredService;
import com.zt.life.modules.project.service.SoftwareTestOrderService;
import com.zt.life.modules.sysBaseInfo.service.TestAgencyInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
 
 
/**
 * software_test_order
 *
 * @author zt generator
 * @since 1.0.0 2023-11-08
 */
@RestController
@RequestMapping("/project/SoftwareTestOrder/")
@Api(tags = "software_test_order")
public class SoftwareTestOrderController {
    @Autowired
    private SoftwareTestOrderService softwareTestOrderService;
 
    @Autowired
    private ProjectService projectService;
    @Autowired
    private SoftwareTestOrderDeliverableService softwareTestOrderDeliverableService;
    @Autowired
    private SoftwareTestOrderMeasuredService softwareTestOrderMeasuredService;
    @Autowired
    private TestAgencyInfoService testAgencyInfoService;
 
    @GetMapping("page")
    @ApiOperation("分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = Constant.Q.PAGE, value = Constant.QV.PAGE, required = true, dataType = Constant.QT.INT),
            @ApiImplicitParam(name = Constant.Q.LIMIT, value = Constant.QV.LIMIT, required = true, dataType = Constant.QT.INT),
            @ApiImplicitParam(name = Constant.Q.ORDER_FIELD, value = Constant.QV.ORDER_FIELD, dataType = Constant.QT.STRING),
            @ApiImplicitParam(name = Constant.Q.ORDER, value = Constant.QV.ORDER, dataType = Constant.QT.STRING),
            @ApiImplicitParam(name = "testBasis", value = "测试依据", dataType = Constant.QT.STRING, format = "test_basis^EQ"),
            @ApiImplicitParam(name = "testType", value = "测试类型", dataType = Constant.QT.STRING, format = "test_type^EQ"),
            @ApiImplicitParam(name = "testStandard", value = "测试标准", dataType = Constant.QT.STRING, format = "test_standard^EQ"),
            @ApiImplicitParam(name = "articleNature", value = "物品性质", dataType = Constant.QT.STRING, format = "article_nature^EQ")})
    public PageResult<SoftwareTestOrder> page(@ApiIgnore @QueryParam QueryFilter queryFilter) {
        return PageResult.ok(softwareTestOrderService.page(queryFilter));
    }
 
    @GetMapping("getDto")
    @ApiOperation("信息")
    public Result<SoftwareTestOrderDto> getDto(Long orderId, Long projectId) {
        SoftwareTestOrderDto data = new SoftwareTestOrderDto();
 
        if (orderId != null) {
            data.setId(orderId);
            SoftwareTestOrder softwareTestOrder = softwareTestOrderService.get(orderId);
            data.setSoftwareTestOrder(softwareTestOrder);
 
            if (projectId == null)
                projectId = softwareTestOrder.getProjectId();
 
            data.setTestAgencyInfo(testAgencyInfoService.get(orderId));
            data.setSoftwareTestOrderDeliverableList(softwareTestOrderDeliverableService.childrenTables(orderId));
            data.setSoftwareTestOrderMeasuredList(softwareTestOrderMeasuredService.childrenTables(orderId));
        } else {
            data.setTestAgencyInfo(testAgencyInfoService.get(10000L));
        }
        if (projectId != null) {
            data.setProjectId(projectId);
            data.setProject(projectService.get(projectId));
        }
 
 
        return Result.ok(data);
    }
 
 
    @PostMapping
    @ApiOperation("新增")
    @LogOperation("新增")
    public Result insert(@RequestBody SoftwareTestOrderDto softwareTestOrderDto) {
        //效验数据
 
        ValidatorUtils.validateEntity(softwareTestOrderDto.getSoftwareTestOrder(), AddGroup.class, DefaultGroup.class);
 
        Boolean result = softwareTestOrderService.save(softwareTestOrderDto);
 
 
        return Result.ok();
    }
 
    @PutMapping
    @ApiOperation("修改")
    @LogOperation("修改")
    public Result update(@RequestBody SoftwareTestOrderDto softwareTestOrderDtor) {
        //效验数据
        ValidatorUtils.validateEntity(softwareTestOrderDtor.getSoftwareTestOrder(), UpdateGroup.class, DefaultGroup.class);
        Boolean result = softwareTestOrderService.save(softwareTestOrderDtor);
        return Result.ok();
    }
 
    @DeleteMapping
    @ApiOperation("删除")
    @LogOperation("删除")
    public Result delete(@RequestBody Long[] ids) {
        //效验数据
        AssertUtils.isArrayEmpty(ids, "id");
        softwareTestOrderService.delete(ids);
 
        return Result.ok();
    }
 
}