huminmin
16 小时以前 271f4a25576ac6c2c8f2c4eb4c9782d6eef85124
src/main/java/com/ruoyi/basic/controller/CustomerController.java
@@ -1,25 +1,23 @@
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.dto.CustomerDto;
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.PutMapping;
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.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.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * 客户档案Controller
@@ -37,10 +35,9 @@
     * 查询客户档案列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Customer customer) {
        startPage();
        List<Customer> list = customerService.selectCustomerList(customer);
        return getDataTable(list);
    public R list(Page<CustomerDto> page, CustomerDto customer) {
        IPage<CustomerVo> customerDtoIPage = customerService.selectCustomerList(page, customer);
        return R.ok(customerDtoIPage);
    }
    /**
@@ -48,17 +45,27 @@
     */
    @Log(title = "客户档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Customer customer) {
        Long[] ids = customer.getIds();
        List<Customer> list;
        if (ids != null && ids.length > 0) {
            list = customerService.selectCustomerListByIds(ids);
        } else {
    public void export(HttpServletResponse response, CustomerDto customer) {
        ExcelUtil<CustomerVo> util = new ExcelUtil<CustomerVo>(CustomerVo.class);
        util.exportExcel(response, customerService.selectCustomerLists(customer), "客户档案数据");
    }
            list = customerService.selectCustomerList(customer);
        }
    @PostMapping("/downloadTemplate")
    @Log(title = "客户档案-下载模板", businessType = BusinessType.EXPORT)
    public void downloadTemplate(HttpServletResponse response) {
        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
        util.exportExcel(response, list, "客户档案数据");
        util.importTemplateExcel(response, "客户档案模板");
    }
    /**
     * 导入客户档案
     */
    @Log(title = "客户档案", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, Integer type) throws Exception {
        return customerService.importData(file, type);
    }
    /**
@@ -66,7 +73,7 @@
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(customerService.selectCustomerById(id));
        return success(customerService.selectCustomerDetailById(id));
    }
    /**
@@ -91,8 +98,50 @@
     * 删除客户档案
     */
    @Log(title = "客户档案", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
    @DeleteMapping("/delCustomer")
    public AjaxResult remove(@RequestBody Long[] ids) {
        if (ids == null || ids.length == 0) {
            return AjaxResult.error("请传入要删除的ID");
        }
        return toAjax(customerService.deleteCustomerByIds(ids));
    }
}
    /**
     * 查询客户
     */
    @GetMapping("/customerList")
    public List customerList(Customer customer) {
        return customerService.customerList(customer);
    }
    /**
     * 分配客户
     */
    @Log(title = "客户档案", businessType = BusinessType.OTHER)
    @PostMapping("/assignCustomer")
    public AjaxResult assignCustomer(@RequestBody CustomerDto customer) {
        customerService.assignCustomer(customer);
        return AjaxResult.success();
    }
    /**
     * 回收客户
     */
    @Log(title = "客户档案", businessType = BusinessType.OTHER)
    @PostMapping("/recycleCustomer")
    public AjaxResult recycleCustomer(@RequestBody CustomerDto customer) {
        customerService.recycleCustomer(customer);
        return AjaxResult.success();
    }
    /**
     * 共享客户
     */
    @Log(title = "客户档案", businessType = BusinessType.OTHER)
    @PostMapping("/together")
    public AjaxResult together(@RequestBody CustomerDto customer) {
        customerService.together(customer);
        return AjaxResult.success();
    }
}