package com.ruoyi.basic.controller;
import com.ruoyi.basic.dto.CustomerPrivateDto;
import com.ruoyi.basic.dto.CustomerPrivatePoolDto;
import com.ruoyi.basic.service.CustomerPrivatePoolService;
import com.ruoyi.basic.service.CustomerPrivateService;
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.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
*
* 客户档案 前端控制器
*
*
* @author 芯导软件(江苏)有限公司
* @since 2026-04-17 10:39:09
*/
@RestController
@Api(tags = "客户(私海)档案")
@RequestMapping("/customerPrivate")
public class CustomerPrivateController {
@Autowired
private CustomerPrivateService customerPrivateService;
@Autowired
private CustomerPrivatePoolService customerPrivatePoolService;
@PostMapping("/add")
public R add(@RequestBody CustomerPrivateDto customerPrivateDto) {
return R.ok(customerPrivateService.add(customerPrivateDto));
}
@DeleteMapping("/delete")
public R delete(@RequestBody List ids) {
return R.ok(customerPrivateService.delete(ids));
}
/**
* 将私海客户扔回公海重新分配
* @param ids
* @return
*/
@PostMapping("/throwCustomer")
@ApiOperation("将私海客户扔回公海重新分配")
public R throwCustomer(@RequestBody List ids) {
return R.ok( customerPrivatePoolService.throwCustomer(ids));
}
/**
* 导入客户档案
*/
@Log(title = "客户档案", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public R importData(MultipartFile file) throws Exception {
return customerPrivateService.importData(file);
}
/**
* 导出客户档案列表
*/
@Log(title = "客户档案", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CustomerPrivatePoolDto customerPrivatePoolDto) {
List ids = customerPrivatePoolDto.getIds();
List list;
if (ids != null && ids.size() > 0) {
list = customerPrivatePoolService.selectCustomerPrivatePoolDtoListByIds(ids);
} else {
list = customerPrivatePoolService.selectCustomerPrivatePoolDtoLists(customerPrivatePoolDto);
}
ExcelUtil util = new ExcelUtil(CustomerPrivatePoolDto.class);
util.exportExcel(response, list, "客户档案数据");
}
@PostMapping("/downloadTemplate")
@Log(title = "客户档案-下载模板", businessType = BusinessType.EXPORT)
public void downloadTemplate(HttpServletResponse response) {
ExcelUtil util = new ExcelUtil(CustomerPrivatePoolDto.class);
util.importTemplateExcel(response, "客户档案模板");
}
}