jinlin
2024-01-31 9025b9cf7ec8610003d445a31d93e35e7bd73c2e
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.zt.life.modules.qaAuditReport.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.configAuditReport.dto.ConfigAuditDto;
import com.zt.life.modules.project.model.ProjectUserName;
import com.zt.life.modules.project.service.ProjectService;
import com.zt.life.modules.qaAuditReport.dto.QaAuditReportDto;
import com.zt.life.modules.qaAuditReport.model.QaAuditReport;
import com.zt.life.modules.qaAuditReport.service.QaAuditReportService;
import com.zt.life.sys.dto.OssDto;
import com.zt.life.sys.service.SysOssConfigService;
import com.zt.modules.coderule.service.SysCodeRuleService;
import com.zt.modules.sys.service.SysUserService;
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;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
/**
 * qa_audit_report
 *
 * @author zt generator 
 * @since 1.0.0 2023-12-29
 */
@RestController
@RequestMapping("/qaAuditReport/QaAuditReport/")
@Api(tags="qa_audit_report")
public class QaAuditReportController {
    @Autowired
    private QaAuditReportService qaAuditReportService;
 
    @Autowired
    private ProjectService projectService;
 
    @Autowired
    private SysCodeRuleService sysCodeRuleService;
 
    @Autowired
    private SysOssConfigService sysOssConfigService;
 
    @Autowired
    private SysUserService sysUserService;
 
    @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 = "code", value = "编号", dataType = Constant.QT.STRING, format = "a.code^LK"),
        @ApiImplicitParam(name = "softwareName", value = "项目名称", dataType = Constant.QT.STRING, format = "p.software_name^LK"),
        @ApiImplicitParam(name = "softwareIdentity", value = "项目标识", dataType = Constant.QT.STRING, format = "p.software_identity^LK")
    })
    public PageResult<QaAuditReport> page(@ApiIgnore @QueryParam QueryFilter queryFilter){
        return PageResult.ok(qaAuditReportService.page(queryFilter));
    }
 
    @GetMapping("getDto")
    @ApiOperation("信息")
    public Result<QaAuditReportDto> getDto(Long projectId, Long reportId) {
        QaAuditReportDto data =qaAuditReportService.getDto(projectId, reportId);
        if (reportId!=null) {
            OssDto ossDto = sysOssConfigService.getOssByBusiType(reportId, "qa_audit_report");
            if (ossDto != null) {
                data.setFiles(ossDto);
            }
        }
        return Result.ok(data);
    }
 
    @PostMapping
    @ApiOperation("新增")
    @LogOperation("新增")
    public Result insert(@RequestBody QaAuditReportDto qaAuditReportDto){
        //效验数据
        ValidatorUtils.validateEntity(qaAuditReportDto, AddGroup.class, DefaultGroup.class);
        Map<String, String> map = new HashMap<>();
        map.put("funCode", "qa_audit_report");
        map.put("projectId",qaAuditReportDto.getProjectId().toString());
        qaAuditReportDto.getAuditReport().setCode(sysCodeRuleService.getNewCode(map));
        Boolean result = qaAuditReportService.save(qaAuditReportDto);
        return Result.ok();
    }
 
    @PutMapping
    @ApiOperation("修改")
    @LogOperation("修改")
    public Result update(@RequestBody QaAuditReportDto qaAuditReportDto){
        //效验数据
        ValidatorUtils.validateEntity(qaAuditReportDto, UpdateGroup.class, DefaultGroup.class);
        Boolean result = qaAuditReportService.save(qaAuditReportDto);
        return Result.ok();
    }
 
 
    @DeleteMapping("deleteQaReport")
    @ApiOperation("删除")
    @LogOperation("删除")
    public Result delete(@RequestBody Long[] ids){
        //效验数据
        AssertUtils.isArrayEmpty(ids, "id");
        qaAuditReportService.delete(ids);
        projectService.deleteItem(ids,"qa_audit_report_incongruent","report_id");
 
        return Result.ok();
    }
 
    @GetMapping("exportQaReport")
    @ApiOperation("打印QA审核报告")
    @LogOperation("打印QA审核报告")
    public void exportQaReport(Long id, HttpServletRequest request, HttpServletResponse response) {
        qaAuditReportService.exportQaReport(id, request, response);
    }
 
    @GetMapping("getNameById")
    @ApiOperation("用户名")
    public Result<ProjectUserName> getNameById(String projectLeaderId, String projectTestersId, String projectConfigerId) {
        ProjectUserName name =new ProjectUserName();
        if (projectLeaderId.length()>10||projectTestersId.length()>10||projectConfigerId.length()>10){
            name.setProjectLeaderName(sysUserService.getNames(projectLeaderId));
            name.setProjectTestersName(sysUserService.getNames(projectTestersId));
            name.setProjectConfigerName(sysUserService.getNames(projectConfigerId));
        }
        return  Result.ok(name);
    }
}