111
k94314517
2023-08-18 82c525da4e13329733ecbd9bca30124f0eb91081
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
package doumeemes.api.ext;
 
import doumeemes.api.BaseController;
import doumeemes.core.annotation.excel.ExcelExporter;
import doumeemes.core.annotation.pr.PreventRepeat;
import doumeemes.core.model.ApiResponse;
import doumeemes.core.model.PageWrap;
import doumeemes.core.model.PageData;
import doumeemes.dao.business.model.Customer;
import doumeemes.dao.ext.dto.QueryCustomerExtDTO;
import doumeemes.dao.ext.vo.CustomerExtListVO;
import doumeemes.service.business.CustomerService;
import doumeemes.service.ext.CustomerExtService;
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 2022/04/20 10:59
 */
@RestController
@RequestMapping("/ext/customerExt")
@Api(tags = "客户信息接口")
public class CustomerExtController extends BaseController {
 
    @Autowired
    private CustomerExtService customerExtService;
    
    @Autowired
    private CustomerService customerService;
 
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @RequiresPermissions("ext:customerext:create")
    public ApiResponse create(@RequestBody Customer customer) {
        return ApiResponse.success(customerService.create(customer));
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("ext:customerext:delete")
    public ApiResponse deleteById(@PathVariable Integer id) {
        customerService.deleteById(id);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("ext:customerext:delete")
    public ApiResponse deleteByIds(@RequestParam String ids) {
        String [] idArray = ids.split(",");
        List<Integer> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(Integer.valueOf(id));
        }
        customerService.deleteByIdInBatch(idList);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("ext:customerext:update")
    public ApiResponse updateById(@RequestBody Customer customer) {
        customerService.updateById(customer);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("ext:customerext:query")
    public ApiResponse<PageData<CustomerExtListVO>> findPage (@RequestBody PageWrap<QueryCustomerExtDTO> pageWrap) {
        return ApiResponse.success(customerExtService.findPage(pageWrap));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("ext:customerext:exportExcel")
    public void exportExcel (@RequestBody PageWrap<QueryCustomerExtDTO> pageWrap, HttpServletResponse response) {
        ExcelExporter.build(CustomerExtListVO.class).export(customerExtService.findPage(pageWrap).getRecords(), "客户信息", response);
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("ext:customerext:query")
    public ApiResponse findById(@PathVariable Integer id) {
        return ApiResponse.success(customerService.findById(id));
    }
}