heheng
2025-01-13 a27162cb82ef0cabf9b43cbfd1f3eb8c177d1e14
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
package com.gkhy.labRiskManage.api.controller.basic;
 
import cn.hutool.json.JSONObject;
import com.gkhy.labRiskManage.api.controller.basic.dto.repDto.BasicExperimentStuffInsertReqBO;
import com.gkhy.labRiskManage.api.controller.basic.dto.repDto.BasicExperimentStuffQueryReqBO;
import com.gkhy.labRiskManage.api.controller.basic.dto.repDto.BasicExperimentStuffUpdateReqBO;
import com.gkhy.labRiskManage.api.controller.basic.dto.respDto.BasicExperimentSiteListRespDTO;
import com.gkhy.labRiskManage.api.controller.basic.dto.respDto.BasicExperimentStuffListRespDTO;
import com.gkhy.labRiskManage.api.controller.basic.dto.respDto.BasicExperimentStuffQueryRespDTO;
import com.gkhy.labRiskManage.api.controller.common.BaseController;
import com.gkhy.labRiskManage.application.basic.dto.bo.BasicExperimentStuffAppQueryBO;
import com.gkhy.labRiskManage.application.basic.dto.dto.BasicExperimentStuffAppListDTO;
import com.gkhy.labRiskManage.application.basic.dto.dto.BasicExperimentStuffAppQueryDTO;
import com.gkhy.labRiskManage.application.basic.service.BasicAppService;
import com.gkhy.labRiskManage.commons.domain.Result;
import com.gkhy.labRiskManage.commons.domain.SearchResult;
import com.gkhy.labRiskManage.commons.enums.ResultCode;
import com.gkhy.labRiskManage.commons.utils.BeanCopyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * 基础实验耗材管理
 */
@RestController
@RequestMapping("basic")
public class BasicExperimentStuffController extends BaseController {
 
    @Autowired
    private BasicAppService basicAppService;
 
    /**
     * 基础实验耗材管理 - 新增
     */
    @PostMapping("/insert/insertStuff")
    public Result insertBasicExperimentStuff(@RequestBody BasicExperimentStuffInsertReqBO insertReqBO){
 
        Result result = new Result();
        result.setCode(ResultCode.OK);
        result.setMsg("新增成功");
 
        int insertResult = basicAppService.insertBasicExperimentStuff(getCurrentUserId(), insertReqBO);
        if (insertResult < 1){
            result.setCode(ResultCode.NOT_OK);
            result.setMsg("新增失败");
        }
        result.setCount(insertResult);
        return result;
    }
 
    /**
     * 基础实验耗材管理 -分页查询
     */
    @PostMapping("/select/selectStuffPage")
    public SearchResult<BasicExperimentStuffQueryRespDTO> selectBasicExperimentStuffPage(@RequestBody BasicExperimentStuffQueryReqBO queryReqBO){
        SearchResult result = new SearchResult();
        result.setCode(ResultCode.OK);
        result.setMsg("查询成功");
 
        SearchResult<BasicExperimentStuffAppQueryDTO> queryResult = basicAppService.selectBasicExperimentStuffPage(getCurrentUserId(), queryReqBO);
 
        result.setData(BeanCopyUtils.copyStuffQueryRespList(queryResult.getData(), BasicExperimentStuffQueryRespDTO.class));
 
        result.setPageIndex(queryResult.getPageIndex());
        result.setPageSize(queryResult.getPageSize());
        result.setTotal(queryResult.getTotal());
        result.setCount(queryResult.getTotal().intValue());
 
        return result;
    }
 
    /**
     * 基础实验耗材管理 - 修改
     */
    @PostMapping("/update/updateStuff")
    public Result updateBasicExperimentStuff(@RequestBody BasicExperimentStuffUpdateReqBO updateReqBO){
        Result result = new Result();
        result.setCode(ResultCode.OK);
        result.setMsg("修改成功");
 
        int updateResult = basicAppService.updateBasicExperimentStuff(getCurrentUserId(), updateReqBO);
 
        if (updateResult < 1){
            result.setCode(ResultCode.NOT_OK);
            result.setMsg("修改失败");
        }
        result.setCount(updateResult);
        return result;
    }
 
    /**
     * 基础实验耗材管理 - 删除
     */
    @PostMapping("/delete/deleteStuff")
    public Result deleteBasicExperimentStuff(@RequestBody JSONObject jsonObject){
        Result result = new Result();
        result.setCode(ResultCode.OK);
        result.setMsg("查询成功");
 
        int deleteResult = basicAppService.deleteBasicExperimentStuff(getCurrentUserId(), jsonObject.getLong("id"));
 
        if (deleteResult < 1){
            result.setCode(ResultCode.NOT_OK);
            result.setMsg("修改失败");
        }
        result.setCount(deleteResult);
        return result;
    }
 
    /**
     * 基础实验耗材管理 - 列表
     */
    @GetMapping("/select/listStuff")
    public SearchResult<BasicExperimentStuffListRespDTO> listBasicExperimentStuff(){
        SearchResult result = new SearchResult();
        result.setCode(ResultCode.OK);
        result.setMsg("查询成功");
 
        SearchResult<BasicExperimentStuffAppListDTO> listResult= basicAppService.listBasicExperimentStuff(getCurrentUserId());
 
        result.setData(BeanCopyUtils.copyStuffListQueryResp(listResult.getData(), BasicExperimentStuffListRespDTO.class));
        result.setCount(listResult.getCount());
 
        return result;
    }
}