huminmin
2026-05-21 fb602920a002f6ad0f9d7c68ecdabcda0980fe0c
src/main/java/com/ruoyi/basic/controller/CustomerController.java
@@ -1,24 +1,22 @@
package com.ruoyi.basic.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.service.ICustomerService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * 客户档案Controller
@@ -29,22 +27,24 @@
@RestController
@RequestMapping("/basic/customer")
@AllArgsConstructor
@Api(tags = "客户档案")
public class CustomerController extends BaseController {
    private ICustomerService customerService;
    /**
     * 查询客户档案列表
     */
    @ApiOperation("查询客户档案列表")
    @GetMapping("/list")
    public TableDataInfo list(Customer customer) {
        startPage();
        List<Customer> list = customerService.selectCustomerList(customer);
        return getDataTable(list);
    @Log(title = "客户档案")
    public IPage<Customer> list(Page<Customer> page, Customer customer) {
        return customerService.selectCustomerList(page, customer);
    }
    /**
     * 导出客户档案列表
     */
    @ApiOperation("导出客户档案列表")
    @Log(title = "客户档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Customer customer) {
@@ -53,24 +53,45 @@
        if (ids != null && ids.length > 0) {
            list = customerService.selectCustomerListByIds(ids);
        } else {
            list = customerService.selectCustomerList(customer);
            list = customerService.selectCustomerLists(customer);
        }
        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
        util.exportExcel(response, list, "客户档案数据");
    }
    @PostMapping("/downloadTemplate")
    @ApiOperation("下载客户档案模板")
    @Log(title = "客户档案-下载模板", businessType = BusinessType.EXPORT)
    public void downloadTemplate(HttpServletResponse response) {
        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
        util.importTemplateExcel(response, "客户档案模板");
    }
    /**
     * 导入客户档案
     */
    @ApiOperation("导入客户档案")
    @Log(title = "客户档案", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file) throws Exception {
        return customerService.importData(file);
    }
    /**
     * 获取客户档案详细信息
     */
    @ApiOperation("获取客户档案详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(customerService.selectCustomerById(id));
        return success(customerService.selectCustomerDetailById(id));
    }
    /**
     * 新增客户档案
     */
    @ApiOperation("新增客户档案")
    @Log(title = "客户档案", businessType = BusinessType.INSERT)
    @PostMapping("/addCustomer")
    public AjaxResult add(@RequestBody Customer customer) {
@@ -80,6 +101,7 @@
    /**
     * 修改客户档案
     */
    @ApiOperation("修改客户档案")
    @Log(title = "客户档案", businessType = BusinessType.UPDATE)
    @PostMapping("/updateCustomer")
    public AjaxResult edit(@RequestBody Customer customer) {
@@ -91,6 +113,7 @@
     */
    @Log(title = "客户档案", businessType = BusinessType.DELETE)
    @DeleteMapping("/delCustomer")
    @ApiOperation("删除客户档案")
    public AjaxResult remove(@RequestBody Long[] ids) {
        if (ids == null || ids.length == 0) {
            return AjaxResult.error("请传入要删除的ID");
@@ -101,8 +124,9 @@
    /**
     * 查询客户
     */
    @ApiOperation("查询客户档案列表")
    @GetMapping("/customerList")
    public List customerList(Customer customer) {
       return  customerService.customerList(customer);
        return customerService.customerList(customer);
    }
}