liusheng
2024-04-22 63ebc0007e9958bd6680c6841a7460b053275790
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
package com.ruoyi.web.controller.project;
 
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.NotRepeatCommit;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.project.domain.BaseAnnextype;
import com.ruoyi.project.service.IBaseAnnextypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.List;
 
/**
 * 捐献附件Controller
 *
 * @author ruoyi
 * @date 2023-11-10
 */
@Slf4j
@Api("捐献附件")
@RestController
@RequestMapping("/project/annextype")
public class BaseAnnextypeController extends BaseController {
    @Autowired
    private IBaseAnnextypeService baseAnnextypeService;
 
    /**
     * 查询捐献附件列表
     */
    @ApiOperation("查询捐献附件列表")
    // @PreAuthorize("@ss.hasPermi('system:annextype:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseAnnextype baseAnnextype) {
        startPage();
        List<BaseAnnextype> list = baseAnnextypeService.queryList(baseAnnextype);
        return getDataTable(list);
    }
 
    /**
     * 导出捐献附件列表
     */
    @ApiOperation("导出捐献附件列表")
    // @PreAuthorize("@ss.hasPermi('system:annextype:export')")
    @Log(title = "捐献附件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BaseAnnextype baseAnnextype) {
        log.info("导出捐献附件列表{}:", baseAnnextype);
        List<BaseAnnextype> list = baseAnnextypeService.queryList(baseAnnextype);
        ExcelUtil<BaseAnnextype> util = new ExcelUtil<BaseAnnextype>(BaseAnnextype.class);
        return util.exportExcel(list, "捐献附件数据");
    }
 
    /**
     * 获取捐献附件详细信息
     */
    @ApiOperation("获取捐献附件详细信息")
    // @PreAuthorize("@ss.hasPermi('system:annextype:query')")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        log.info("获取捐献附件详细信息{}:", id);
 
        return AjaxResult.success(baseAnnextypeService.getById(id));
    }
 
    /**
     * 新增捐献附件
     */
    @ApiOperation("新增捐献附件")
    // @PreAuthorize("@ss.hasPermi('system:annextype:add')")
    @Log(title = "捐献附件", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @RepeatSubmit
    public AjaxResult add(@RequestBody BaseAnnextype baseAnnextype) {
        log.info("新增捐献附件{}:", baseAnnextype);
 
        if (ObjectUtils.isEmpty(baseAnnextype) || StringUtils.isEmpty(baseAnnextype.getDonationcategory()) || StringUtils.isEmpty(baseAnnextype.getAnnextype())) {
            throw new BaseException("请检查捐献类别和附件类型,为空了");
        }
        boolean save = baseAnnextypeService.save(baseAnnextype);
        return AjaxResult.success(baseAnnextype);
    }
 
    /**
     * 修改捐献附件
     */
    @ApiOperation("修改捐献附件")
    // @PreAuthorize("@ss.hasPermi('system:annextype:edit')")
    @Log(title = "捐献附件", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @RepeatSubmit
    public AjaxResult edit(@RequestBody BaseAnnextype baseAnnextype) {
        log.info("修改捐献附件的入参{}:", baseAnnextype);
 
        if (ObjectUtils.isEmpty(baseAnnextype) || baseAnnextype.getId() == null) {
            throw new BaseException("修改的条件为空");
        }
        return toAjax(baseAnnextypeService.updateById(baseAnnextype));
    }
 
    /**
     * 删除捐献附件
     */
    @ApiOperation("删除捐献附件")
    // @PreAuthorize("@ss.hasPermi('system:annextype:remove')")
    @Log(title = "捐献附件", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        log.info("删除捐献附件{}:", ids);
 
        return toAjax(baseAnnextypeService.removeByIds(Arrays.asList(ids)));
    }
}