liyong
8 小时以前 2b382a92207dfabf0eb30e743265df5c7c50e7bc
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package com.ruoyi.basic.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.dto.CustomerDto;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.service.ICustomerService;
import com.ruoyi.basic.vo.CustomerVo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.R;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
 
/**
 * 客户档案Controller
 *
 * @author ruoyi
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/basic/customer")
@AllArgsConstructor
public class CustomerController extends BaseController {
    private ICustomerService customerService;
 
    /**
     * 查询客户档案列表
     */
    @GetMapping("/list")
    public R list(Page<CustomerDto> page, CustomerDto customer) {
        IPage<CustomerVo> customerDtoIPage = customerService.selectCustomerList(page, customer);
        return R.ok(customerDtoIPage);
    }
 
    /**
     * 导出客户档案列表
     */
    @Log(title = "客户档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerDto customer) {
        ExcelUtil<CustomerVo> util = new ExcelUtil<CustomerVo>(CustomerVo.class);
        util.exportExcel(response, customerService.selectCustomerLists(customer), "客户档案数据");
    }
 
    @PostMapping("/downloadTemplate")
    @Log(title = "客户档案-下载模板", businessType = BusinessType.EXPORT)
    public void downloadTemplate(HttpServletResponse response) {
        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
        util.importTemplateExcel(response, "客户档案模板");
    }
 
 
    /**
     * 导入客户档案
     */
    @Log(title = "客户档案", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public R importData(MultipartFile file, Integer type) throws Exception {
 
        return customerService.importData(file, type);
    }
 
    /**
     * 获取客户档案详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id) {
        return R.ok(customerService.selectCustomerDetailById(id));
    }
 
    /**
     * 新增客户档案
     */
    @Log(title = "客户档案", businessType = BusinessType.INSERT)
    @PostMapping("/addCustomer")
    public R add(@RequestBody Customer customer) {
        return R.ok(customerService.insertCustomer(customer));
    }
 
    /**
     * 修改客户档案
     */
    @Log(title = "客户档案", businessType = BusinessType.UPDATE)
    @PostMapping("/updateCustomer")
    public R edit(@RequestBody Customer customer) {
        return R.ok(customerService.updateCustomer(customer));
    }
 
    /**
     * 删除客户档案
     */
    @Log(title = "客户档案", businessType = BusinessType.DELETE)
    @DeleteMapping("/delCustomer")
    public R remove(@RequestBody Long[] ids) {
        if (ids == null || ids.length == 0) {
            return R.fail("请传入要删除的ID");
        }
        return R.ok(customerService.deleteCustomerByIds(ids));
    }
 
    /**
     * 查询客户
     */
    @GetMapping("/customerList")
    public List customerList(Customer customer) {
        return customerService.customerList(customer);
    }
 
 
    /**
     * 分配客户
     */
    @Log(title = "客户档案", businessType = BusinessType.OTHER)
    @PostMapping("/assignCustomer")
    public R assignCustomer(@RequestBody CustomerDto customer) {
        customerService.assignCustomer(customer);
        return R.ok();
    }
 
    /**
     * 回收客户
     */
    @Log(title = "客户档案", businessType = BusinessType.OTHER)
    @PostMapping("/recycleCustomer")
    public R recycleCustomer(@RequestBody CustomerDto customer) {
        customerService.recycleCustomer(customer);
        return R.ok();
    }
 
    /**
     * 共享客户
     */
    @Log(title = "客户档案", businessType = BusinessType.OTHER)
    @PostMapping("/together")
    public R together(@RequestBody CustomerDto customer) {
        customerService.together(customer);
        return R.ok();
    }
 
    /**
     * 私海客户流回公海
     */
    @Log(title = "客户档案", businessType = BusinessType.OTHER)
    @PostMapping("/back")
    public R back(Long id) {
        return R.ok(customerService.back(id));
    }
}