jiaosong
2023-10-13 947f4fc58f3a7f4c4cb12062afcf851b439a53f1
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
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.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.model.Refund;
import com.doumee.dao.business.model.RefundPlatExportVO;
import com.doumee.dao.business.vo.GoodsorderExportVO;
import com.doumee.service.business.RefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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/09/27 18:06
 */
@Api(tags = "退款信息表")
@RestController
@RequestMapping("/business/refund")
public class RefundController extends BaseController {
 
    @Autowired
    private RefundService refundService;
 
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @RequiresPermissions("business:refund:create")
    public ApiResponse create(@RequestBody Refund refund) {
        return ApiResponse.success(refundService.create(refund));
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("business:refund:delete")
    public ApiResponse deleteById(@PathVariable String id) {
        refundService.deleteById(id);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("business:refund:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
        String [] idArray = ids.split(",");
        List<String> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(id);
        }
        refundService.deleteByIdInBatch(idList);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("business:refund:update")
    public ApiResponse updateById(@RequestBody Refund refund) {
        refundService.updateById(refund);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("business:refund:query")
    public ApiResponse<PageData<Refund>> findPage (@RequestBody PageWrap<Refund> pageWrap) {
        return ApiResponse.success(refundService.findPage(pageWrap));
    }
    @ApiOperation("后台结算记录")
    @PostMapping("/findPlatPage")
    @RequiresPermissions("business:refund:query")
    public ApiResponse<PageData<Refund>> findPlatPage (@RequestBody PageWrap<Refund> pageWrap) {
        return ApiResponse.success(refundService.findPlatPage(pageWrap));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("business:refund:exportExcel")
    public void exportExcel (@RequestBody PageWrap<Refund> pageWrap, HttpServletResponse response) {
        ExcelExporter.build(Refund.class).export(refundService.findPage(pageWrap).getRecords(), "退款信息表", response);
    }
 
    @ApiOperation("导出后台结算记录Excel")
    @PostMapping("/exportPlatExcel")
    @RequiresPermissions("business:refund:exportExcel")
    public void exportPlatExcel (@RequestBody PageWrap<Refund> pageWrap, HttpServletResponse response) {
        ExcelExporter.build(RefundPlatExportVO.class).exportWithFirstAndEnd(refundService.findPlatExportPage(pageWrap.getModel()), "后台结算记录_"+System.currentTimeMillis(),"后台结算记录_"+ DateUtil.getPlusTime2(DateUtil.getCurrentDate()),null, response);
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:refund:query")
    public ApiResponse findById(@PathVariable String id) {
        return ApiResponse.success(refundService.findById(id));
    }
}