liyong
5 小时以前 1ca5584d7e3200a9af65a099bd26d3593e2ba702
src/main/java/com/ruoyi/basic/controller/CustomerController.java
@@ -5,17 +5,17 @@
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.AjaxResult;
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 jakarta.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -35,7 +35,7 @@
     */
    @GetMapping("/list")
    public R list(Page<CustomerDto> page, CustomerDto customer) {
        IPage<CustomerDto> customerDtoIPage = customerService.selectCustomerList(page, customer);
        IPage<CustomerVo> customerDtoIPage = customerService.selectCustomerList(page, customer);
        return R.ok(customerDtoIPage);
    }
@@ -44,16 +44,9 @@
     */
    @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 {
            list = customerService.selectCustomerLists(customer);
        }
        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
        util.exportExcel(response, list, "客户档案数据");
    public void export(HttpServletResponse response, CustomerDto customer) {
        ExcelUtil<CustomerVo> util = new ExcelUtil<CustomerVo>(CustomerVo.class);
        util.exportExcel(response, customerService.selectCustomerLists(customer), "客户档案数据");
    }
    @PostMapping("/downloadTemplate")
@@ -69,17 +62,17 @@
     */
    @Log(title = "客户档案", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file) throws Exception {
    public R importData(MultipartFile file, Integer type) throws Exception {
        return customerService.importData(file);
        return customerService.importData(file, type);
    }
    /**
     * 获取客户档案详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(customerService.selectCustomerDetailById(id));
    public R getInfo(@PathVariable("id") Long id) {
        return R.ok(customerService.selectCustomerDetailById(id));
    }
    /**
@@ -87,8 +80,8 @@
     */
    @Log(title = "客户档案", businessType = BusinessType.INSERT)
    @PostMapping("/addCustomer")
    public AjaxResult add(@RequestBody Customer customer) {
        return toAjax(customerService.insertCustomer(customer));
    public R add(@RequestBody Customer customer) {
        return R.ok(customerService.insertCustomer(customer));
    }
    /**
@@ -96,8 +89,8 @@
     */
    @Log(title = "客户档案", businessType = BusinessType.UPDATE)
    @PostMapping("/updateCustomer")
    public AjaxResult edit(@RequestBody Customer customer) {
        return toAjax(customerService.updateCustomer(customer));
    public R edit(@RequestBody Customer customer) {
        return R.ok(customerService.updateCustomer(customer));
    }
    /**
@@ -105,11 +98,11 @@
     */
    @Log(title = "客户档案", businessType = BusinessType.DELETE)
    @DeleteMapping("/delCustomer")
    public AjaxResult remove(@RequestBody Long[] ids) {
    public R remove(@RequestBody Long[] ids) {
        if (ids == null || ids.length == 0) {
            return AjaxResult.error("请传入要删除的ID");
            return R.fail("请传入要删除的ID");
        }
        return toAjax(customerService.deleteCustomerByIds(ids));
        return R.ok(customerService.deleteCustomerByIds(ids));
    }
    /**
@@ -121,4 +114,42 @@
    }
    /**
     * 分配客户
     */
    @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));
    }
}