164 lines
6.0 KiB
Java
164 lines
6.0 KiB
Java
|
|
package com.ruoyi.group.controller;
|
|||
|
|
|
|||
|
|
import com.alibaba.fastjson2.JSON;
|
|||
|
|
import com.ruoyi.common.annotation.Log;
|
|||
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|||
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|||
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|||
|
|
import com.ruoyi.common.enums.BusinessType;
|
|||
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|||
|
|
import com.ruoyi.group.domain.dto.CustGroupMemberTemplate;
|
|||
|
|
import com.ruoyi.group.domain.dto.CustGroupQueryDTO;
|
|||
|
|
import com.ruoyi.group.domain.dto.GridImportDTO;
|
|||
|
|
import com.ruoyi.group.domain.entity.CustGroup;
|
|||
|
|
import com.ruoyi.group.domain.vo.CustGroupVO;
|
|||
|
|
import com.ruoyi.group.service.ICustGroupService;
|
|||
|
|
import io.swagger.annotations.Api;
|
|||
|
|
import io.swagger.annotations.ApiOperation;
|
|||
|
|
import org.springframework.http.MediaType;
|
|||
|
|
import org.springframework.web.bind.annotation.*;
|
|||
|
|
import org.springframework.web.multipart.MultipartFile;
|
|||
|
|
|
|||
|
|
import javax.annotation.Resource;
|
|||
|
|
import javax.servlet.http.HttpServletResponse;
|
|||
|
|
import javax.validation.Valid;
|
|||
|
|
import java.util.List;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 客群管理Controller
|
|||
|
|
*
|
|||
|
|
* @author ruoyi
|
|||
|
|
*/
|
|||
|
|
@Api(tags = "客群管理接口")
|
|||
|
|
@RestController
|
|||
|
|
@RequestMapping("/group/cust")
|
|||
|
|
public class CustGroupController extends BaseController {
|
|||
|
|
|
|||
|
|
@Resource
|
|||
|
|
private ICustGroupService custGroupService;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 查询客群列表
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("查询客群列表")
|
|||
|
|
@Log(title = "客群管理-查询客群列表")
|
|||
|
|
@GetMapping("/list")
|
|||
|
|
public TableDataInfo listCustGroup(CustGroupQueryDTO dto) {
|
|||
|
|
startPage();
|
|||
|
|
List<CustGroupVO> list = custGroupService.listCustGroup(dto);
|
|||
|
|
return getDataTable(list);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 获取客群详情
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("获取客群详情")
|
|||
|
|
@Log(title = "客群管理-获取客群详情")
|
|||
|
|
@GetMapping("/{id}")
|
|||
|
|
public AjaxResult getCustGroup(@PathVariable Long id) {
|
|||
|
|
CustGroupVO vo = custGroupService.getCustGroup(id);
|
|||
|
|
return AjaxResult.success(vo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 异步创建客群(网格导入)
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("异步创建客群(网格导入)")
|
|||
|
|
@Log(title = "客群管理-网格导入创建客群", businessType = BusinessType.INSERT)
|
|||
|
|
@PostMapping("/createByGrid")
|
|||
|
|
public AjaxResult createCustGroupByGrid(@RequestBody @Valid GridImportDTO gridImportDTO) {
|
|||
|
|
String id = custGroupService.createCustGroupByGrid(gridImportDTO);
|
|||
|
|
return AjaxResult.success(id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 异步创建客群(模板导入)
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("异步创建客群(模板导入)")
|
|||
|
|
@Log(title = "客群管理-异步创建客群", businessType = BusinessType.INSERT)
|
|||
|
|
@PostMapping(value = "/createByTemplate", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|||
|
|
public AjaxResult createCustGroupByTemplate(@RequestPart("dto") @Valid String dtoJson,
|
|||
|
|
@RequestPart("file") MultipartFile file) {
|
|||
|
|
CustGroup custGroup = JSON.parseObject(dtoJson, CustGroup.class);
|
|||
|
|
return AjaxResult.success(custGroupService.createCustGroupByTemplate(custGroup, file));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 更新客群
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("更新客群")
|
|||
|
|
@Log(title = "客群管理-更新客群", businessType = BusinessType.UPDATE)
|
|||
|
|
@PostMapping("/update")
|
|||
|
|
public AjaxResult updateCustGroup(@RequestBody @Valid CustGroup custGroup) {
|
|||
|
|
String result = custGroupService.updateCustGroup(custGroup);
|
|||
|
|
return AjaxResult.success(result);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 更新客群(网格导入)
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("更新客群(网格导入)")
|
|||
|
|
@Log(title = "客群管理-更新客群(网格导入)", businessType = BusinessType.UPDATE)
|
|||
|
|
@PostMapping("/updateByGrid")
|
|||
|
|
public AjaxResult updateCustGroupByGrid(@RequestBody @Valid GridImportDTO gridImportDTO) {
|
|||
|
|
String result = custGroupService.updateCustGroupByGrid(gridImportDTO);
|
|||
|
|
return AjaxResult.success(result);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 更新客群(模板导入)
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("更新客群(模板导入)")
|
|||
|
|
@Log(title = "客群管理-更新客群(模板导入)", businessType = BusinessType.UPDATE)
|
|||
|
|
@PostMapping(value = "/updateByTemplate", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|||
|
|
public AjaxResult updateCustGroupByTemplate(@RequestPart("dto") @Valid String dtoJson,
|
|||
|
|
@RequestPart("file") MultipartFile file) {
|
|||
|
|
CustGroup custGroup = JSON.parseObject(dtoJson, CustGroup.class);
|
|||
|
|
return AjaxResult.success(custGroupService.updateCustGroupByTemplate(custGroup, file));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 轮询客群创建状态
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("轮询客群创建状态")
|
|||
|
|
@Log(title = "客群管理-轮询客群创建状态")
|
|||
|
|
@GetMapping("/createStatus/{id}")
|
|||
|
|
public AjaxResult getCreateStatus(@PathVariable Long id) {
|
|||
|
|
String status = custGroupService.getCreateStatus(id);
|
|||
|
|
return AjaxResult.success(status);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 客户信息模板下载
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("客户信息模板")
|
|||
|
|
@Log(title = "客群管理-客户信息模板", businessType = BusinessType.EXPORT)
|
|||
|
|
@PostMapping("/download")
|
|||
|
|
public void download(HttpServletResponse response) {
|
|||
|
|
ExcelUtil<CustGroupMemberTemplate> util = new ExcelUtil<>(CustGroupMemberTemplate.class);
|
|||
|
|
util.exportExcel(response, null, "客户信息模板");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 删除客群
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("删除客群")
|
|||
|
|
@Log(title = "客群管理-删除客群", businessType = BusinessType.DELETE)
|
|||
|
|
@PostMapping("/delete")
|
|||
|
|
public AjaxResult deleteCustGroup(@RequestBody List<Long> idList) {
|
|||
|
|
String result = custGroupService.deleteCustGroup(idList);
|
|||
|
|
return AjaxResult.success(result);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 手动移除客群客户
|
|||
|
|
*/
|
|||
|
|
@ApiOperation("手动移除客群客户")
|
|||
|
|
@Log(title = "客群管理-手动移除客户", businessType = BusinessType.DELETE)
|
|||
|
|
@PostMapping("/removeMembers")
|
|||
|
|
public AjaxResult removeMembers(@RequestParam Long groupId, @RequestBody List<Long> memberIds) {
|
|||
|
|
String result = custGroupService.removeMembers(groupId, memberIds);
|
|||
|
|
return AjaxResult.success(result);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|