zjh
2024-02-28 22c17adc3ec2a25e6656cd69961f49a888d433b3
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.ltkj.web.controller.system;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.hosp.domain.TjSurveyOptions;
import com.ltkj.hosp.domain.TjSurveyQuestion;
import com.ltkj.hosp.domain.TjSurveyTempQues;
import com.ltkj.hosp.service.ITjSurveyQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ltkj.common.annotation.Log;
import com.ltkj.common.core.controller.BaseController;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.enums.BusinessType;
import com.ltkj.hosp.domain.TjSurveyTemplate;
import com.ltkj.hosp.service.ITjSurveyTemplateService;
import com.ltkj.common.utils.poi.ExcelUtil;
import com.ltkj.common.core.page.TableDataInfo;
 
/**
 * 问卷模板Controller
 *
 * @author ltkj_赵佳豪&李格
 * @date 2023-04-07
 */
@RestController
@RequestMapping("/hosp/surveyTemplate")
@Api(tags = "问卷模板")
public class TjSurveyTemplateController extends BaseController {
    @Autowired
    private ITjSurveyTemplateService tjSurveyTemplateService;
 
    @Autowired
    private ITjSurveyQuestionService tjSurveyQuestionService;
 
    /**
     * 查询问卷模板列表
     */
    //@PreAuthorize("@ss.hasPermi('hosp:surveyTemplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TjSurveyTemplate tjSurveyTemplate) {
        startPage();
        List<TjSurveyTemplate> list = tjSurveyTemplateService.selectTjSurveyTemplateList(tjSurveyTemplate);
        return getDataTable(list);
    }
 
    /**
     * 导出问卷模板列表
     */
    //@PreAuthorize("@ss.hasPermi('hosp:surveyTemplate:export')")
    @Log(title = "问卷模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TjSurveyTemplate tjSurveyTemplate) {
        List<TjSurveyTemplate> list = tjSurveyTemplateService.selectTjSurveyTemplateList(tjSurveyTemplate);
        ExcelUtil<TjSurveyTemplate> util = new ExcelUtil<TjSurveyTemplate>(TjSurveyTemplate.class);
        util.exportExcel(response, list, "问卷模板数据");
    }
 
    /**
     * 获取问卷模板详细信息
     */
    //@PreAuthorize("@ss.hasPermi('hosp:surveyTemplate:query')")
    @GetMapping(value = "/{mid}")
    public AjaxResult getInfo(@PathVariable("mid") Long mid) {
        return success(tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid));
    }
 
    /**
     * 获取问卷模板
     */
    @GetMapping("/getQuesByMid")
    @ApiOperation(value = "获取问卷模板信息")
    public AjaxResult getQuesByMid(@RequestParam Long mid) {
        List<TjSurveyQuestion> l1=new ArrayList<>();
        TjSurveyTemplate byId = tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid);
        List<TjSurveyTempQues> tjSurveyTempQuesList = byId.getTjSurveyTempQuesList();
        if (tjSurveyTempQuesList!=null){
            for (TjSurveyTempQues tjSurveyTempQues : tjSurveyTempQuesList) {
                TjSurveyQuestion byId1 = tjSurveyQuestionService.selectTjSurveyQuestionByQid(tjSurveyTempQues.getQid());
                if (byId1!=null){
                    l1.add(byId1);
                }
            }
            return AjaxResult.success(l1);
        }
        return AjaxResult.success("暂无信息");
    }
 
    /**
     * 新增问卷模板
     */
    //@PreAuthorize("@ss.hasPermi('hosp:surveyTemplate:add')")
    @Log(title = "问卷模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TjSurveyTemplate tjSurveyTemplate) {
        return toAjax(tjSurveyTemplateService.insertTjSurveyTemplate(tjSurveyTemplate));
    }
 
    /**
     * 修改问卷模板
     */
    //@PreAuthorize("@ss.hasPermi('hosp:surveyTemplate:edit')")
    @Log(title = "问卷模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TjSurveyTemplate tjSurveyTemplate) {
        return toAjax(tjSurveyTemplateService.updateTjSurveyTemplate(tjSurveyTemplate));
    }
 
    /**
     * 删除问卷模板
     */
    //@PreAuthorize("@ss.hasPermi('hosp:surveyTemplate:remove')")
    @Log(title = "问卷模板", businessType = BusinessType.DELETE)
    @DeleteMapping("/{mids}")
    public AjaxResult remove(@PathVariable Long[] mids) {
        return toAjax(tjSurveyTemplateService.deleteTjSurveyTemplateByMids(mids));
    }
}