教育训练处考试制证系统后端
“djh”
2025-03-06 6061c45849de0f3ac6d05fdfa2bac4b09c21179b
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
package com.gkhy.exam.pay.controller;
 
import com.gkhy.exam.pay.dto.rep.NonCategoryCount;
import com.gkhy.exam.pay.dto.req.NonCountCategoryReqDto;
import com.gkhy.exam.pay.entity.NonCoalCategory;
import com.gkhy.exam.pay.service.NonCoalCategoryService;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.stream.Collectors;
 
 
/**
 * 非煤工种类别Controller
 *
 * @author hh
 * @date 2025-01-16
 */
@RestController
@Api(tags = "非煤工种类别管理")
@RequestMapping("/pay/nonCoalCategory")
public class NonCoalCategoryController extends BaseController {
    @Autowired
    private NonCoalCategoryService nonCoalCategoryService;
 
    /**
     * 查询非煤工种类别列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询非煤工种类别列表")
    public TableDataInfo list(NonCoalCategory nonCoalCategory) {
        startPage();
        List<NonCoalCategory> list = nonCoalCategoryService.selectNonCoalCategoryList(nonCoalCategory);
        return getDataTable(list);
    }
 
//    /**
//     * 导出非煤工种类别列表
//     */
//    @PreAuthorize("@ss.hasPermi('exam:category:export')")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, NonCoalCategory nonCoalCategory) {
//        List<NonCoalCategory> list = nonCoalCategoryService.selectNonCoalCategoryList(nonCoalCategory);
//        ExcelUtil<NonCoalCategory> util = new ExcelUtil<NonCoalCategory>(NonCoalCategory.class);
//        util.exportExcel(response, list, "非煤工种类别数据");
//    }
 
    /**
     * 获取非煤工种类别详细信息
     */
 
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取非煤工种类别详细信息", httpMethod = "GET")
    @ApiImplicitParam(name = "id", dataTypeClass = Long.class, value = "id", required = true)
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(nonCoalCategoryService.selectNonCoalCategoryById(id));
    }
 
    /**
     * 新增非煤工种类别
     */
 
    @PostMapping("/add")
    @ApiOperation(value = "新增非煤工种类别")
    public AjaxResult add(@Validated @RequestBody NonCoalCategory nonCoalCategory) {
        return toAjax(nonCoalCategoryService.insertNonCoalCategory(nonCoalCategory));
    }
 
    /**
     * 修改非煤工种类别
     */
 
    @PostMapping("/edit")
    @ApiOperation(value = "修改非煤工种类别")
    public AjaxResult edit(@Validated @RequestBody NonCoalCategory nonCoalCategory) {
        return toAjax(nonCoalCategoryService.updateNonCoalCategory(nonCoalCategory));
    }
 
    /**
     * 删除非煤工种类别
     */
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除非煤工种类别")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(nonCoalCategoryService.deleteNonCoalCategoryByIds(ids));
    }
 
    @GetMapping("/count")
    @ApiOperation(value = "非煤工种缴费统计")
    public TableDataInfo count(NonCountCategoryReqDto countCategoryReqDto){
        List<NonCategoryCount> nonCategoryCounts = nonCoalCategoryService.countCategory(countCategoryReqDto);
        int pageNum = countCategoryReqDto.getPageNum(); // 当前页码
        int pageSize = countCategoryReqDto.getPageSize(); // 每页大小
        List<NonCategoryCount> pagedList = nonCategoryCounts.stream()
                .skip((pageNum - 1) * pageSize) // 跳过前面的数据
                .limit(pageSize) // 限制当前页的数据量
                .collect(Collectors.toList());
 
        // 封装分页结果
        TableDataInfo dataTable = new TableDataInfo();
        dataTable.setCode(HttpStatus.SUCCESS);
        dataTable.setMsg("查询成功");
        dataTable.setRows(pagedList); // 当前页数据
        dataTable.setTotal(nonCategoryCounts.size()); // 总数据量
        return dataTable;
    }
}