doum
2025-12-11 c83278063eba3316d24553c88ae75c5f711e8d23
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
package com.doumee.api.business;
 
import com.doumee.api.BaseController;
import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageWrap;
import com.doumee.core.model.PageData;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.model.Areas;
import com.doumee.dao.business.model.Fund;
import com.doumee.dao.business.model.FundMonth;
import com.doumee.service.business.FundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author 江蹄蹄
 * @date 2023/03/21 15:48
 */
@Api(tags = "资金明细信息表")
@RestController
@RequestMapping("/business/fund")
public class FundController extends BaseController {
 
    @Autowired
    private FundService fundService;
 
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @RequiresPermissions("business:fund:create")
    public ApiResponse create(@RequestBody Fund fund) {
        return ApiResponse.success(fundService.create(fund));
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("business:fund:delete")
    public ApiResponse deleteById(@PathVariable Integer id) {
        fundService.deleteById(id);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("business:fund:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
        String [] idArray = ids.split(",");
        List<Integer> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(Integer.valueOf(id));
        }
        fundService.deleteByIdInBatch(idList);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("business:fund:update")
    public ApiResponse updateById(@RequestBody Fund fund) {
        fundService.updateById(fund);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("business:fund:query")
    public ApiResponse<PageData<Fund>> findPage (@RequestBody PageWrap<Fund> pageWrap) {
        return ApiResponse.success(fundService.findPage(pageWrap));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("business:fund:exportExcel")
    public void exportExcel (@RequestBody PageWrap<Fund> pageWrap, HttpServletResponse response)throws Exception  {
       List<Fund>  list= fundService.findPage(pageWrap).getRecords();
       for(Fund model:list){
           if(Constants.equalsInteger(model.getType(),Constants.ZERO)){
               model.setStrType("收入");
           }else  if(Constants.equalsInteger(model.getType(),Constants.ONE)){
               model.setStrType("支出");
           }
       }
        ExcelExporter.build(Fund.class).export(list, "资金明细信息"+ DateUtil.getNowLongTime(), response);
    }
 
 
 
    @ApiOperation("导出资金月账单Excel")
    @PostMapping("/exportMonthExcel")
    @RequiresPermissions("business:fund:exportExcel")
    public void exportMonthExcel (@RequestBody Fund pageWrap, HttpServletResponse response)throws Exception  {
        List<Fund>  list= fundService.exportMonthExcel(pageWrap);
        for(Fund model:list){
            FundMonth a = new FundMonth();
            BeanUtils.copyProperties(pageWrap,a);
            if(Constants.equalsInteger(model.getType(),Constants.ZERO)){
                model.setStrType("收入");
            }else  if(Constants.equalsInteger(model.getType(),Constants.ONE)){
                model.setStrType("支出");
            }
        }
        ExcelExporter.build(Fund.class).export(list, "资金月账单信息"+ DateUtil.getNowLongTime(), response);
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:fund:query")
    public ApiResponse findById(@PathVariable Integer id) {
        return ApiResponse.success(fundService.findById(id));
    }
}