|
@@ -1,14 +1,21 @@
|
|
|
-package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype;
|
|
|
+package cn.iocoder.yudao.module.crm.controller.admin.business;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
|
|
-import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.*;
|
|
|
+import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
|
|
|
+import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;
|
|
|
import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert;
|
|
|
-import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
|
|
|
-import cn.iocoder.yudao.module.crm.service.businessstatustype.CrmBusinessStatusTypeService;
|
|
|
+import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
|
|
+import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
|
|
|
+import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService;
|
|
|
+import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -22,11 +29,13 @@ import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
|
-// TODO @lilleo:这个模块,可以挪到 business 下;这样我打开 business 包下,就知道,噢~原来里面有 business 商机、有 type 状态类型、status 具体状态;
|
|
|
@Tag(name = "管理后台 - 商机状态类型")
|
|
|
@RestController
|
|
|
@RequestMapping("/crm/business-status-type")
|
|
@@ -36,17 +45,23 @@ public class CrmBusinessStatusTypeController {
|
|
|
@Resource
|
|
|
private CrmBusinessStatusTypeService businessStatusTypeService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CrmBusinessStatusService businessStatusService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建商机状态类型")
|
|
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:create')")
|
|
|
- public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeCreateReqVO createReqVO) {
|
|
|
+ public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO createReqVO) {
|
|
|
return success(businessStatusTypeService.createBusinessStatusType(createReqVO));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "更新商机状态类型")
|
|
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:update')")
|
|
|
- public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeUpdateReqVO updateReqVO) {
|
|
|
+ public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO updateReqVO) {
|
|
|
businessStatusTypeService.updateBusinessStatusType(updateReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
@@ -66,45 +81,58 @@ public class CrmBusinessStatusTypeController {
|
|
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
|
|
public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
|
|
|
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
|
|
|
- return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType));
|
|
|
- }
|
|
|
-
|
|
|
- // TODO @lilleo:这个接口,暂时用不到,可以考虑先删除掉
|
|
|
- @GetMapping("/list")
|
|
|
- @Operation(summary = "获得商机状态类型列表")
|
|
|
- @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
|
|
- @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
|
|
- public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList(@RequestParam("ids") Collection<Long> ids) {
|
|
|
- List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(ids);
|
|
|
- return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list));
|
|
|
+ //处理状态回显
|
|
|
+ CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
|
|
+ queryVO.setTypeId(id);
|
|
|
+ List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
|
|
+ return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType, statusList));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
@Operation(summary = "获得商机状态类型分页")
|
|
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
|
|
- public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageVO) {
|
|
|
- PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageVO);
|
|
|
- return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult));
|
|
|
+ public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) {
|
|
|
+ PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
|
|
|
+ //处理部门回显
|
|
|
+ Set<Long> deptIds = pageResult.getList().stream()
|
|
|
+ .map(CrmBusinessStatusTypeDO::getDeptIds)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .flatMap(Collection::stream)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ List<DeptRespDTO> deptList = deptApi.getDeptList(deptIds);
|
|
|
+ return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
|
@Operation(summary = "导出商机状态类型 Excel")
|
|
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:export')")
|
|
|
@OperateLog(type = EXPORT)
|
|
|
- public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypeExportReqVO exportReqVO,
|
|
|
+ public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypePageReqVO pageReqVO,
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
- List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(exportReqVO);
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO).getList();
|
|
|
// 导出 Excel
|
|
|
- List<CrmBusinessStatusTypeExcelVO> datas = CrmBusinessStatusTypeConvert.INSTANCE.convertList02(list);
|
|
|
- ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeExcelVO.class, datas);
|
|
|
+ ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeRespVO.class,
|
|
|
+ BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get-simple-list")
|
|
|
@Operation(summary = "获得商机状态类型列表")
|
|
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
|
|
public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList() {
|
|
|
- List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
|
- return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list));
|
|
|
+ CrmBusinessStatusTypeQueryVO queryVO = new CrmBusinessStatusTypeQueryVO();
|
|
|
+ queryVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
|
+ List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.selectList(queryVO);
|
|
|
+ return success(BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/get-status-list")
|
|
|
+ @Operation(summary = "获得商机状态列表")
|
|
|
+ @PreAuthorize("@ss.hasPermission('crm:business-status:query')")
|
|
|
+ public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusListByTypeId(@RequestParam("typeId") Long typeId) {
|
|
|
+ CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
|
|
+ queryVO.setTypeId(typeId);
|
|
|
+ List<CrmBusinessStatusDO> list = businessStatusService.selectList(queryVO);
|
|
|
+ return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
|
|
|
+ }
|
|
|
}
|