mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
!789 完善数据权限,新增权限关联、场景分页查询,新增权限关联批量查询
Merge pull request !789 from puhui999/develop
This commit is contained in:
commit
8f578a9a82
2
pom.xml
2
pom.xml
@ -21,7 +21,7 @@
|
||||
<!-- <module>yudao-module-mp</module>-->
|
||||
<!-- <module>yudao-module-pay</module>-->
|
||||
<!-- <module>yudao-module-mall</module>-->
|
||||
<!-- <module>yudao-module-crm</module>-->
|
||||
<module>yudao-module-crm</module>
|
||||
<!-- 示例项目 -->
|
||||
<!-- <module>yudao-example</module>-->
|
||||
</modules>
|
||||
|
@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.interfaces.MPJBaseJoin;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -40,6 +41,18 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
||||
return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
|
||||
}
|
||||
|
||||
default <D> PageResult<D> selectJoinPage(PageParam pageParam, Class<D> clazz, MPJLambdaWrapper<T> lambdaWrapper) {
|
||||
// 特殊:不分页,直接查询全部
|
||||
if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageNo())) {
|
||||
List<D> list = selectJoinList(clazz, lambdaWrapper);
|
||||
return new PageResult<>(list, (long) list.size());
|
||||
}
|
||||
|
||||
IPage<D> mpPage = MyBatisUtils.buildPage(pageParam);
|
||||
mpPage = selectJoinPage(mpPage, clazz, lambdaWrapper);
|
||||
return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
|
||||
}
|
||||
|
||||
default <DTO> PageResult<DTO> selectJoinPage(PageParam pageParam, Class<DTO> resultTypeClass, MPJBaseJoin<T> joinQueryWrapper) {
|
||||
IPage<DTO> mpPage = MyBatisUtils.buildPage(pageParam);
|
||||
selectJoinPage(mpPage, resultTypeClass, joinQueryWrapper);
|
||||
|
@ -7,7 +7,6 @@ import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// TODO @puhui999:这个枚举,要不改成 CrmSceneTypeEnum
|
||||
/**
|
||||
* CRM 列表检索场景
|
||||
*
|
||||
@ -15,14 +14,14 @@ import java.util.Arrays;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CrmSceneEnum implements IntArrayValuable {
|
||||
public enum CrmSceneTypeEnum implements IntArrayValuable {
|
||||
|
||||
OWNER(1, "我负责的"),
|
||||
FOLLOW(2, "我关注的"),
|
||||
// TODO @puhui999:还有一个我参与的
|
||||
SUBORDINATE(3, "下属负责的");
|
||||
INVOLVED(3, "我参与的"),
|
||||
SUBORDINATE(4, "下属负责的");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray();
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneTypeEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 场景类型
|
||||
@ -41,6 +40,10 @@ public enum CrmSceneEnum implements IntArrayValuable {
|
||||
return ObjUtil.equal(FOLLOW.getType(), type);
|
||||
}
|
||||
|
||||
public static boolean isInvolved(Integer type) {
|
||||
return ObjUtil.equal(INVOLVED.getType(), type);
|
||||
}
|
||||
|
||||
public static boolean isSubordinate(Integer type) {
|
||||
return ObjUtil.equal(SUBORDINATE.getType(), type);
|
||||
}
|
@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
||||
@ -22,13 +21,13 @@ import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -36,6 +35,7 @@ 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.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@ -102,7 +102,7 @@ public class CrmBusinessController {
|
||||
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||
Set<Long> customerIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds, getLoginUserId());
|
||||
// 处理商机状态类型名称回显
|
||||
Set<Long> statusTypeIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
@ -120,14 +120,14 @@ public class CrmBusinessController {
|
||||
|
||||
@GetMapping("/page-by-customer")
|
||||
@Operation(summary = "获得商机分页,基于指定客户")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) {
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) {
|
||||
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO);
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO, getLoginUserId());
|
||||
// 处理客户名称回显
|
||||
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||
Set<Long> customerIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds, getLoginUserId());
|
||||
// 处理商机状态类型名称回显
|
||||
Set<Long> statusTypeIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
@ -143,20 +143,13 @@ public class CrmBusinessController {
|
||||
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
|
||||
}
|
||||
|
||||
@GetMapping("/pool-page")
|
||||
@Operation(summary = "获得商机公海分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:query')")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPoolPage(@Valid CrmBusinessPageReqVO pageVO) {
|
||||
// TODO puhui999: 等数据权限完善后再实现
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出商机 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId());
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class,
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -18,4 +20,14 @@ public class CrmBusinessPageReqVO extends PageParam {
|
||||
@Schema(description = "客户编号", example = "10795")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -11,18 +11,20 @@ import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 线索")
|
||||
@RestController
|
||||
@ -70,7 +72,7 @@ public class CrmClueController {
|
||||
@Operation(summary = "获得线索分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:query')")
|
||||
public CommonResult<PageResult<CrmClueRespVO>> getCluePage(@Valid CrmCluePageReqVO pageVO) {
|
||||
PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO);
|
||||
PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO, getLoginUserId());
|
||||
return success(CrmClueConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@ -78,9 +80,9 @@ public class CrmClueController {
|
||||
@Operation(summary = "导出线索 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportClueExcel(@Valid CrmClueExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<CrmClueDO> list = clueService.getClueList(exportReqVO);
|
||||
public void exportClueExcel(@Valid CrmCluePageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
List<CrmClueDO> list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList();
|
||||
// 导出 Excel
|
||||
List<CrmClueExcelVO> datas = CrmClueConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas);
|
||||
|
@ -1,52 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 线索 Excel 导出 Request VO,参数和 CrmCluePageReqVO 是一致的")
|
||||
@Data
|
||||
public class CrmClueExportReqVO {
|
||||
|
||||
@Schema(description = "转化状态", example = "true")
|
||||
private Boolean transformStatus;
|
||||
|
||||
@Schema(description = "跟进状态", example = "true")
|
||||
private Boolean followUpStatus;
|
||||
|
||||
@Schema(description = "线索名称", example = "线索xxx")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "客户id", example = "520")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] contactNextTime;
|
||||
|
||||
@Schema(description = "电话", example = "18000000000")
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "手机号", example = "18000000000")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地址", example = "北京市海淀区")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "27199")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] contactLastTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -21,4 +23,14 @@ public class CrmCluePageReqVO extends PageParam {
|
||||
@Schema(description = "手机号", example = "18000000000")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
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.number.NumberUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
@ -22,14 +21,14 @@ import com.google.common.collect.Lists;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -38,6 +37,7 @@ import java.util.stream.Stream;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
@ -95,9 +95,11 @@ public class CrmContactController {
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList(
|
||||
NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
// 2. 获取客户信息
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(Collections.singletonList(contact.getCustomerId()));
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(
|
||||
Collections.singletonList(contact.getCustomerId()), getLoginUserId());
|
||||
// 3. 直属上级
|
||||
List<CrmContactDO> parentContactList = contactService.getContactList(Collections.singletonList(contact.getParentId()));
|
||||
List<CrmContactDO> parentContactList = contactService.getContactList(
|
||||
Collections.singletonList(contact.getParentId()), getLoginUserId());
|
||||
return success(ContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList));
|
||||
}
|
||||
|
||||
@ -105,7 +107,9 @@ public class CrmContactController {
|
||||
@Operation(summary = "获得联系人列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||
public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() {
|
||||
List<CrmContactDO> list = contactService.getContactList();
|
||||
CrmContactPageReqVO pageReqVO = new CrmContactPageReqVO();
|
||||
pageReqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
List<CrmContactDO> list = contactService.getContactPage(pageReqVO, getLoginUserId()).getList();
|
||||
return success(ContactConvert.INSTANCE.convertAllList(list));
|
||||
}
|
||||
|
||||
@ -113,7 +117,7 @@ public class CrmContactController {
|
||||
@Operation(summary = "获得联系人分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||
public CommonResult<PageResult<CrmContactRespVO>> getContactPage(@Valid CrmContactPageReqVO pageVO) {
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO);
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO, getLoginUserId());
|
||||
return success(convertDetailContactPage(pageResult));
|
||||
}
|
||||
|
||||
@ -121,7 +125,7 @@ public class CrmContactController {
|
||||
@Operation(summary = "获得联系人分页,基于指定客户")
|
||||
public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) {
|
||||
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomer(pageVO);
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO, getLoginUserId());
|
||||
return success(convertDetailContactPage(pageResult));
|
||||
}
|
||||
|
||||
@ -131,8 +135,8 @@ public class CrmContactController {
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportContactExcel(@Valid CrmContactPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageNo(PageParam.PAGE_SIZE_NONE);
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO);
|
||||
exportReqVO.setPageNo(PAGE_SIZE_NONE);
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO, getLoginUserId());
|
||||
ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class,
|
||||
convertDetailContactPage(pageResult).getList());
|
||||
}
|
||||
@ -150,13 +154,13 @@ public class CrmContactController {
|
||||
}
|
||||
// 1. 获取客户列表
|
||||
List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList(
|
||||
convertSet(contactList, CrmContactDO::getCustomerId));
|
||||
convertSet(contactList, CrmContactDO::getCustomerId), getLoginUserId());
|
||||
// 2. 获取创建人、负责人列表
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList,
|
||||
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
// 3. 直属上级
|
||||
List<CrmContactDO> parentContactList = contactService.getContactList(
|
||||
convertSet(contactList, CrmContactDO::getParentId));
|
||||
convertSet(contactList, CrmContactDO::getParentId), getLoginUserId());
|
||||
return ContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -33,4 +35,14 @@ public class CrmContactPageReqVO extends PageParam {
|
||||
@Schema(description = "微信", example = "zzZ98373")
|
||||
private String wechat;
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -87,7 +87,7 @@ public class CrmContractController {
|
||||
@Operation(summary = "获得合同分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contract:query')")
|
||||
public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO);
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId());
|
||||
return success(convertDetailContractPage(pageResult));
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class CrmContractController {
|
||||
@Operation(summary = "获得联系人分页,基于指定客户")
|
||||
public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
|
||||
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO);
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO, getLoginUserId());
|
||||
return success(convertDetailContractPage(pageResult));
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public class CrmContractController {
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO);
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO, getLoginUserId());
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class,
|
||||
ContractConvert.INSTANCE.convertList02(pageResult.getList()));
|
||||
@ -124,7 +124,7 @@ public class CrmContractController {
|
||||
}
|
||||
// 1. 获取客户列表
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(
|
||||
convertSet(contactList, CrmContractDO::getCustomerId));
|
||||
convertSet(contactList, CrmContractDO::getCustomerId), getLoginUserId());
|
||||
// 2. 获取创建人、负责人列表
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList,
|
||||
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -24,4 +26,14 @@ public class CrmContractPageReqVO extends PageParam {
|
||||
@Schema(description = "商机编号", example = "10864")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.framework.vo.CrmBasePageReqVO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -10,7 +12,7 @@ import lombok.ToString;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerPageReqVO extends CrmBasePageReqVO {
|
||||
public class CrmCustomerPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "客户名称", example = "赵六")
|
||||
private String name;
|
||||
@ -27,4 +29,14 @@ public class CrmCustomerPageReqVO extends CrmBasePageReqVO {
|
||||
@Schema(description = "客户来源", example = "1")
|
||||
private Integer source;
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -39,6 +39,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 回款")
|
||||
@RestController
|
||||
@ -111,7 +112,7 @@ public class CrmReceivableController {
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(exportReqVO);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class,
|
||||
@ -131,7 +132,7 @@ public class CrmReceivableController {
|
||||
}
|
||||
// 1. 获取客户列表
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(
|
||||
convertSet(receivableList, CrmReceivableDO::getCustomerId));
|
||||
convertSet(receivableList, CrmReceivableDO::getCustomerId), getLoginUserId());
|
||||
// 2. 获取创建人、负责人列表
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList,
|
||||
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
|
@ -25,13 +25,13 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -41,6 +41,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 回款计划")
|
||||
@RestController
|
||||
@ -115,7 +116,7 @@ public class CrmReceivablePlanController {
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportReceivablePlanExcel(@Valid CrmReceivablePlanPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(exportReqVO);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanRespVO.class,
|
||||
@ -135,7 +136,7 @@ public class CrmReceivablePlanController {
|
||||
}
|
||||
// 1. 获取客户列表
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(
|
||||
convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId));
|
||||
convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId), getLoginUserId());
|
||||
// 2. 获取创建人、负责人列表
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList,
|
||||
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -19,4 +21,14 @@ public class CrmReceivablePlanPageReqVO extends PageParam {
|
||||
@Schema(description = "合同名称", example = "3473")
|
||||
private Long contractId;
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -21,4 +23,14 @@ public class CrmReceivablePageReqVO extends PageParam {
|
||||
@Schema(description = "客户编号", example = "4963")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
/**
|
||||
* 提供 RESTful API 给前端:
|
||||
* 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目
|
||||
* 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分
|
||||
*/
|
||||
package cn.iocoder.yudao.module.crm.controller;
|
@ -39,8 +39,7 @@ public interface CrmBusinessConvert {
|
||||
List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list);
|
||||
|
||||
@Mappings({
|
||||
@Mapping(target = "bizId", source = "reqVO.id"),
|
||||
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
|
||||
@Mapping(target = "bizId", source = "reqVO.id")
|
||||
})
|
||||
CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId);
|
||||
|
||||
|
@ -55,8 +55,7 @@ public interface CrmCustomerConvert {
|
||||
List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list);
|
||||
|
||||
@Mappings({
|
||||
@Mapping(target = "bizId", source = "reqVO.id"),
|
||||
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
|
||||
@Mapping(target = "bizId", source = "reqVO.id")
|
||||
})
|
||||
CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId);
|
||||
|
||||
|
@ -97,4 +97,11 @@ public class CrmBusinessDO extends BaseDO {
|
||||
*/
|
||||
private Integer followUpStatus;
|
||||
|
||||
/**
|
||||
* 负责人的用户编号
|
||||
*
|
||||
* 关联 AdminUserDO 的 id 字段
|
||||
*/
|
||||
private Long ownerUserId;
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,13 @@ public class CrmClueDO extends BaseDO {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 负责人的用户编号
|
||||
*
|
||||
* 关联 AdminUserDO 的 id 字段
|
||||
*/
|
||||
private Long ownerUserId;
|
||||
|
||||
// TODO 芋艿:客户级别;
|
||||
// TODO 芋艿:线索来源;
|
||||
// TODO 芋艿:客户行业;
|
||||
|
@ -2,13 +2,16 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商机 Mapper
|
||||
@ -18,18 +21,29 @@ import java.util.Collection;
|
||||
@Mapper
|
||||
public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
|
||||
|
||||
default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO reqVO, Collection<Long> ids) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessDO>()
|
||||
.in(CrmBusinessDO::getId, ids)
|
||||
.likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
|
||||
.orderByDesc(CrmBusinessDO::getId));
|
||||
default int updateOwnerUserIdById(Long id, Long ownerUserId) {
|
||||
return update(new LambdaUpdateWrapper<CrmBusinessDO>()
|
||||
.eq(CrmBusinessDO::getId, id)
|
||||
.set(CrmBusinessDO::getOwnerUserId, ownerUserId));
|
||||
}
|
||||
|
||||
default PageResult<CrmBusinessDO> selectPageByCustomer(CrmContractPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessDO>()
|
||||
.eq(CrmBusinessDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
|
||||
.likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
|
||||
.orderByDesc(CrmBusinessDO::getId));
|
||||
default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) {
|
||||
MPJLambdaWrapperX<CrmBusinessDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId,
|
||||
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||
mpjLambdaWrapperX.selectAll(CrmBusinessDO.class)
|
||||
.eqIfPresent(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号
|
||||
.likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName())
|
||||
.orderByDesc(CrmBusinessDO::getId);
|
||||
return selectJoinPage(pageReqVO, CrmBusinessDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||
MPJLambdaWrapperX<CrmBusinessDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId);
|
||||
return selectJoinList(CrmBusinessDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,12 +2,15 @@ package cn.iocoder.yudao.module.crm.dal.mysql.clue;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -18,27 +21,30 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface CrmClueMapper extends BaseMapperX<CrmClueDO> {
|
||||
|
||||
default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmClueDO>()
|
||||
.likeIfPresent(CrmClueDO::getName, reqVO.getName())
|
||||
.likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone())
|
||||
.likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile())
|
||||
.orderByDesc(CrmClueDO::getId));
|
||||
default int updateOwnerUserIdById(Long id, Long ownerUserId) {
|
||||
return update(new LambdaUpdateWrapper<CrmClueDO>()
|
||||
.eq(CrmClueDO::getId, id)
|
||||
.set(CrmClueDO::getOwnerUserId, ownerUserId));
|
||||
}
|
||||
|
||||
default List<CrmClueDO> selectList(CrmClueExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmClueDO>()
|
||||
.eqIfPresent(CrmClueDO::getTransformStatus, reqVO.getTransformStatus())
|
||||
.eqIfPresent(CrmClueDO::getFollowUpStatus, reqVO.getFollowUpStatus())
|
||||
.likeIfPresent(CrmClueDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmClueDO::getCustomerId, reqVO.getCustomerId())
|
||||
.betweenIfPresent(CrmClueDO::getContactNextTime, reqVO.getContactNextTime())
|
||||
.likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone())
|
||||
.likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile())
|
||||
.likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress())
|
||||
.betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime())
|
||||
.betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(CrmClueDO::getId));
|
||||
default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO pageReqVO, Long userId) {
|
||||
MPJLambdaWrapperX<CrmClueDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_LEADS.getType(), CrmClueDO::getId,
|
||||
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||
mpjLambdaWrapperX.selectAll(CrmClueDO.class)
|
||||
.likeIfPresent(CrmClueDO::getName, pageReqVO.getName())
|
||||
.likeIfPresent(CrmClueDO::getTelephone, pageReqVO.getTelephone())
|
||||
.likeIfPresent(CrmClueDO::getMobile, pageReqVO.getMobile())
|
||||
.orderByDesc(CrmClueDO::getId);
|
||||
return selectJoinPage(pageReqVO, CrmClueDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
default List<CrmClueDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||
MPJLambdaWrapperX<CrmClueDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_LEADS.getType(), ids, userId);
|
||||
return selectJoinList(CrmClueDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,17 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contact;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CRM 联系人 Mapper
|
||||
*
|
||||
@ -15,29 +21,34 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
|
||||
|
||||
// TODO @puhui999:数据权限
|
||||
default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactDO>()
|
||||
.eqIfPresent(CrmContactDO::getMobile, reqVO.getMobile())
|
||||
.eqIfPresent(CrmContactDO::getTelephone, reqVO.getTelephone())
|
||||
.eqIfPresent(CrmContactDO::getEmail, reqVO.getEmail())
|
||||
.eqIfPresent(CrmContactDO::getCustomerId, reqVO.getCustomerId())
|
||||
.likeIfPresent(CrmContactDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmContactDO::getQq, reqVO.getQq())
|
||||
.eqIfPresent(CrmContactDO::getWechat, reqVO.getWechat())
|
||||
.orderByDesc(CrmContactDO::getId));
|
||||
default int updateOwnerUserIdById(Long id, Long ownerUserId) {
|
||||
return update(new LambdaUpdateWrapper<CrmContactDO>()
|
||||
.eq(CrmContactDO::getId, id)
|
||||
.set(CrmContactDO::getOwnerUserId, ownerUserId));
|
||||
}
|
||||
|
||||
default PageResult<CrmContactDO> selectPageByCustomer(CrmContactPageReqVO pageVO) {
|
||||
return selectPage(pageVO, new LambdaQueryWrapperX<CrmContactDO>()
|
||||
.eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) // 必须传递
|
||||
.likeIfPresent(CrmContactDO::getName, pageVO.getName())
|
||||
.eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile())
|
||||
.eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone())
|
||||
.eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail())
|
||||
.eqIfPresent(CrmContactDO::getQq, pageVO.getQq())
|
||||
.eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat())
|
||||
.orderByDesc(CrmContactDO::getId));
|
||||
default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) {
|
||||
MPJLambdaWrapperX<CrmContactDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId,
|
||||
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||
mpjLambdaWrapperX.selectAll(CrmContactDO.class)
|
||||
.eqIfPresent(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号
|
||||
.likeIfPresent(CrmContactDO::getName, pageReqVO.getName())
|
||||
.eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile())
|
||||
.eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone())
|
||||
.eqIfPresent(CrmContactDO::getEmail, pageReqVO.getEmail())
|
||||
.eqIfPresent(CrmContactDO::getQq, pageReqVO.getQq())
|
||||
.eqIfPresent(CrmContactDO::getWechat, pageReqVO.getWechat())
|
||||
.orderByDesc(CrmContactDO::getId);
|
||||
return selectJoinPage(pageReqVO, CrmContactDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||
MPJLambdaWrapperX<CrmContactDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId);
|
||||
return selectJoinList(CrmContactDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,17 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contract;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CRM 合同 Mapper
|
||||
*
|
||||
@ -15,22 +21,32 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
||||
|
||||
default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>()
|
||||
.likeIfPresent(CrmContractDO::getNo, reqVO.getNo())
|
||||
.likeIfPresent(CrmContractDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmContractDO::getCustomerId, reqVO.getCustomerId())
|
||||
.eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId())
|
||||
.orderByDesc(CrmContractDO::getId));
|
||||
default int updateOwnerUserIdById(Long id, Long ownerUserId) {
|
||||
return update(new LambdaUpdateWrapper<CrmContractDO>()
|
||||
.eq(CrmContractDO::getId, id)
|
||||
.set(CrmContractDO::getOwnerUserId, ownerUserId));
|
||||
}
|
||||
|
||||
default PageResult<CrmContractDO> selectPageByCustomer(CrmContractPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>()
|
||||
.eq(CrmContractDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
|
||||
.likeIfPresent(CrmContractDO::getNo, reqVO.getNo())
|
||||
.likeIfPresent(CrmContractDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId())
|
||||
.orderByDesc(CrmContractDO::getId));
|
||||
default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO pageReqVO, Long userId) {
|
||||
MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContractDO::getId,
|
||||
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||
mpjLambdaWrapperX.selectAll(CrmContractDO.class)
|
||||
.eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId())
|
||||
.likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo())
|
||||
.likeIfPresent(CrmContractDO::getName, pageReqVO.getName())
|
||||
.eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId())
|
||||
.eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId())
|
||||
.orderByDesc(CrmContractDO::getId);
|
||||
return selectJoinPage(pageReqVO, CrmContractDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||
MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId);
|
||||
return selectJoinList(CrmContractDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.customer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.util.CrmQueryPageUtils;
|
||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -30,35 +27,25 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
||||
.set(CrmCustomerDO::getOwnerUserId, ownerUserId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户分页
|
||||
*
|
||||
* @param pageReqVO 请求
|
||||
* @param userId 用户编号
|
||||
* @param subordinateIds 下属用户编号
|
||||
* @param isAdmin 是否为管理
|
||||
* @return 客户分页数据
|
||||
*/
|
||||
default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId, Collection<Long> subordinateIds, Boolean isAdmin) {
|
||||
IPage<CrmCustomerDO> mpPage = MyBatisUtils.buildPage(pageReqVO);
|
||||
default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId) {
|
||||
MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryPageUtils.builderQuery(mpjLambdaWrapperX, pageReqVO, userId,
|
||||
CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, subordinateIds, isAdmin);
|
||||
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId,
|
||||
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||
mpjLambdaWrapperX.selectAll(CrmCustomerDO.class)
|
||||
.likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName())
|
||||
.eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile())
|
||||
.eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId())
|
||||
.eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel())
|
||||
.eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource());
|
||||
// 特殊:不分页,直接查询全部
|
||||
// TODO @puhui999:下面这个,封装一个方法;从 56 到 61 这里哈;
|
||||
if (PageParam.PAGE_SIZE_NONE.equals(pageReqVO.getPageNo())) {
|
||||
List<CrmCustomerDO> list = selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX);
|
||||
return new PageResult<>(list, (long) list.size());
|
||||
}
|
||||
mpPage = selectJoinPage(mpPage, CrmCustomerDO.class, mpjLambdaWrapperX);
|
||||
return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
|
||||
return selectJoinPage(pageReqVO, CrmCustomerDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||
MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId);
|
||||
return selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,9 +35,8 @@ public @interface CrmPermission {
|
||||
|
||||
/**
|
||||
* 数据编号,通过 Spring EL 表达式获取
|
||||
* TODO 数据权限完成后去除 default ""
|
||||
*/
|
||||
String bizId() default "";
|
||||
String bizId();
|
||||
|
||||
/**
|
||||
* 操作所需权限级别
|
||||
|
@ -1,25 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.framework.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 分页 Base Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CrmBasePageReqVO extends PageParam {
|
||||
|
||||
/**
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneEnum.class)
|
||||
private Integer sceneType;
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
@ -5,11 +5,10 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,7 +56,7 @@ public interface CrmBusinessService {
|
||||
* @param ids 编号
|
||||
* @return 商机列表
|
||||
*/
|
||||
List<CrmBusinessDO> getBusinessList(Collection<Long> ids);
|
||||
List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 获得商机分页
|
||||
@ -76,9 +75,10 @@ public interface CrmBusinessService {
|
||||
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param userId 用户编号
|
||||
* @return 联系人分页
|
||||
*/
|
||||
PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO);
|
||||
PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 商机转移
|
||||
|
@ -3,28 +3,28 @@ package cn.iocoder.yudao.module.crm.service.business;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
@ -38,6 +38,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
|
||||
@Resource
|
||||
private CrmBusinessMapper businessMapper;
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
|
||||
@Resource
|
||||
private CrmPermissionService crmPermissionService;
|
||||
@ -71,12 +73,14 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, level = CrmPermissionLevelEnum.WRITE)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void deleteBusiness(Long id) {
|
||||
// 校验存在
|
||||
validateBusinessExists(id);
|
||||
// 删除
|
||||
businessMapper.deleteById(id);
|
||||
// 删除数据权限
|
||||
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_BUSINESS.getType(), id);
|
||||
}
|
||||
|
||||
private CrmBusinessDO validateBusinessExists(Long id) {
|
||||
@ -88,38 +92,30 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS,bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmBusinessDO getBusiness(Long id) {
|
||||
return businessMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmBusinessDO> getBusinessList(Collection<Long> ids) {
|
||||
public List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return businessMapper.selectBatchIds(ids);
|
||||
return businessMapper.selectBatchIds(ids, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) {
|
||||
// 1. 获取当前用户能看的分页数据
|
||||
// TODO @puhui999:如果业务的数据量比较大,in 太多可能有性能问题噢;看看是不是搞成 join 连表了;可以微信讨论下;
|
||||
List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId(
|
||||
CrmBizTypeEnum.CRM_BUSINESS.getType(), userId);
|
||||
Set<Long> ids = convertSet(permissions, CrmPermissionDO::getBizId);
|
||||
if (CollUtil.isEmpty(ids)) { // 没得说明没有什么给他看的
|
||||
return PageResult.empty();
|
||||
}
|
||||
|
||||
// 2. 获取商机分页数据
|
||||
return businessMapper.selectPage(pageReqVO, ids);
|
||||
return businessMapper.selectPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
|
||||
public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO) {
|
||||
return businessMapper.selectPageByCustomer(pageReqVO);
|
||||
public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId) {
|
||||
// 校验客户存在
|
||||
customerService.validateCustomer(pageReqVO.getCustomerId());
|
||||
|
||||
return businessMapper.selectPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,10 +124,13 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
// 1 校验商机是否存在
|
||||
validateBusinessExists(reqVO.getId());
|
||||
|
||||
// 2. 数据权限转移
|
||||
// 2.1 数据权限转移
|
||||
crmPermissionService.transferPermission(
|
||||
CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()));
|
||||
|
||||
// 2.2 设置新的负责人
|
||||
businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
||||
// 3. TODO 记录转移日志
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
package cn.iocoder.yudao.module.crm.service.clue;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 线索 Service 接口
|
||||
@ -49,22 +53,15 @@ public interface CrmClueService {
|
||||
* @param ids 编号
|
||||
* @return 线索列表
|
||||
*/
|
||||
List<CrmClueDO> getClueList(Collection<Long> ids);
|
||||
List<CrmClueDO> getClueList(Collection<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 获得线索分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param userId 用户编号
|
||||
* @return 线索分页
|
||||
*/
|
||||
PageResult<CrmClueDO> getCluePage(CrmCluePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得线索列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 线索列表
|
||||
*/
|
||||
List<CrmClueDO> getClueList(CrmClueExportReqVO exportReqVO);
|
||||
PageResult<CrmClueDO> getCluePage(CrmCluePageReqVO pageReqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -4,23 +4,25 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 线索 Service 实现类
|
||||
@ -35,6 +37,8 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
private CrmClueMapper clueMapper;
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
@Resource
|
||||
private CrmPermissionService crmPermissionService;
|
||||
|
||||
@Override
|
||||
public Long createClue(CrmClueCreateReqVO createReqVO) {
|
||||
@ -48,6 +52,7 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public void updateClue(CrmClueUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateClueExists(updateReqVO.getId());
|
||||
@ -60,11 +65,14 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void deleteClue(Long id) {
|
||||
// 校验存在
|
||||
validateClueExists(id);
|
||||
// 删除
|
||||
clueMapper.deleteById(id);
|
||||
// 删除数据权限
|
||||
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_LEADS.getType(), id);
|
||||
}
|
||||
|
||||
private void validateClueExists(Long id) {
|
||||
@ -74,26 +82,22 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmClueDO getClue(Long id) {
|
||||
return clueMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmClueDO> getClueList(Collection<Long> ids) {
|
||||
public List<CrmClueDO> getClueList(Collection<Long> ids, Long userId) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return clueMapper.selectBatchIds(ids);
|
||||
return clueMapper.selectBatchIds(ids, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmClueDO> getCluePage(CrmCluePageReqVO pageReqVO) {
|
||||
return clueMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmClueDO> getClueList(CrmClueExportReqVO exportReqVO) {
|
||||
return clueMapper.selectList(exportReqVO);
|
||||
public PageResult<CrmClueDO> getCluePage(CrmCluePageReqVO pageReqVO, Long userId) {
|
||||
return clueMapper.selectPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateR
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -22,7 +21,7 @@ public interface CrmContactService {
|
||||
* 创建联系人
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @param userId 用户编号
|
||||
* @param userId 用户编号
|
||||
* @return 编号
|
||||
*/
|
||||
Long createContact(@Valid CrmContactCreateReqVO createReqVO, Long userId);
|
||||
@ -52,10 +51,11 @@ public interface CrmContactService {
|
||||
/**
|
||||
* 获得联系人列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @param ids 编号
|
||||
* @param userId 用户编号
|
||||
* @return 联系人列表
|
||||
*/
|
||||
List<CrmContactDO> getContactList(Collection<Long> ids);
|
||||
List<CrmContactDO> getContactList(Collection<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 获得联系人分页
|
||||
@ -63,25 +63,20 @@ public interface CrmContactService {
|
||||
* 数据权限:基于 {@link CrmContactDO}
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param userId 用户编号
|
||||
* @return 联系人分页
|
||||
*/
|
||||
PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO);
|
||||
PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 获得联系人分页,基于指定客户
|
||||
* 获得联系人分页
|
||||
*
|
||||
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
||||
* 数据权限:基于 {@link CrmContactDO}
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param pageVO 分页查询
|
||||
* @param userId 用户编号
|
||||
* @return 联系人分页
|
||||
*/
|
||||
PageResult<CrmContactDO> getContactPageByCustomer(CrmContactPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取所有联系人列表
|
||||
*
|
||||
* @return 所有联系人列表
|
||||
*/
|
||||
List<CrmContactDO> getContactList();
|
||||
PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -10,18 +10,18 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateR
|
||||
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -82,7 +82,7 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
*
|
||||
* @param saveReqVO 新增/修改请求 VO
|
||||
*/
|
||||
private void validateRelationDataExists(CrmContactBaseVO saveReqVO){
|
||||
private void validateRelationDataExists(CrmContactBaseVO saveReqVO) {
|
||||
// 1. 校验客户
|
||||
if (saveReqVO.getCustomerId() != null && customerService.getCustomer(saveReqVO.getCustomerId()) == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
@ -98,12 +98,14 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void deleteContact(Long id) {
|
||||
// 校验存在
|
||||
validateContactExists(id);
|
||||
// 删除
|
||||
contactMapper.deleteById(id);
|
||||
// 删除数据权限
|
||||
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id);
|
||||
}
|
||||
|
||||
private void validateContactExists(Long id) {
|
||||
@ -112,7 +114,6 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 芋艿:是否要做数据权限的校验???
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmContactDO getContact(Long id) {
|
||||
@ -120,28 +121,24 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmContactDO> getContactList(Collection<Long> ids) {
|
||||
public List<CrmContactDO> getContactList(Collection<Long> ids, Long userId) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return contactMapper.selectBatchIds(ids);
|
||||
return contactMapper.selectBatchIds(ids, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO) {
|
||||
// TODO puhui999:后面要改成,基于数据权限的查询
|
||||
return contactMapper.selectPage(pageReqVO);
|
||||
public PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO, Long userId) {
|
||||
return contactMapper.selectPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
|
||||
public PageResult<CrmContactDO> getContactPageByCustomer(CrmContactPageReqVO pageReqVO) {
|
||||
return contactMapper.selectPageByCustomer(pageReqVO);
|
||||
}
|
||||
public PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId) {
|
||||
// 校验用户存在
|
||||
customerService.validateCustomer(pageVO.getCustomerId());
|
||||
|
||||
@Override
|
||||
public List<CrmContactDO> getContactList() {
|
||||
return contactMapper.selectList();
|
||||
return contactMapper.selectPage(pageVO, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,14 +12,18 @@ import cn.iocoder.yudao.module.crm.convert.contactbusinessslink.CrmContactBusine
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_BUSINESS_LINK_NOT_EXISTS;
|
||||
|
||||
// TODO @puhui999:数据权限的校验;每个操作;
|
||||
@ -54,6 +58,7 @@ public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLink
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public void updateContactBusinessLink(CrmContactBusinessLinkSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateContactBusinessLinkExists(updateReqVO.getId());
|
||||
@ -80,6 +85,7 @@ public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLink
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmContactBusinessLinkDO getContactBusinessLink(Long id) {
|
||||
return contactBusinessLinkMapper.selectById(id);
|
||||
}
|
||||
@ -90,7 +96,7 @@ public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLink
|
||||
crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId());
|
||||
PageResult<CrmContactBusinessLinkDO> businessLinkDOS = contactBusinessLinkMapper.selectPageByContact(crmContactBusinessLinkPageReqVO);
|
||||
List<CrmBusinessDO> businessDOS = crmBusinessService.getBusinessList(CollectionUtils.convertList(businessLinkDOS.getList(),
|
||||
CrmContactBusinessLinkDO::getBusinessId));
|
||||
CrmContactBusinessLinkDO::getBusinessId), getLoginUserId());
|
||||
PageResult<CrmBusinessRespVO> pageResult = new PageResult<CrmBusinessRespVO>();
|
||||
pageResult.setList(CrmBusinessConvert.INSTANCE.convert(businessDOS));
|
||||
pageResult.setTotal(businessLinkDOS.getTotal());
|
||||
|
@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.crm.service.contract;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -64,9 +64,10 @@ public interface CrmContractService {
|
||||
* 数据权限:基于 {@link CrmContractDO} 读取
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param userId 用户编号
|
||||
* @return 合同分页
|
||||
*/
|
||||
PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO);
|
||||
PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 获得合同分页,基于指定客户
|
||||
@ -74,9 +75,12 @@ public interface CrmContractService {
|
||||
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param userId 用户编号
|
||||
* @return 联系人分页
|
||||
*/
|
||||
PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO);
|
||||
default PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO, Long userId) {
|
||||
return getContractPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 合同转移
|
||||
|
@ -5,8 +5,8 @@ import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
|
||||
@ -15,11 +15,11 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -56,7 +56,7 @@ public class CrmContractServiceImpl implements CrmContractService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public void updateContract(CrmContractUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateContractExists(updateReqVO.getId());
|
||||
@ -67,12 +67,14 @@ public class CrmContractServiceImpl implements CrmContractService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void deleteContract(Long id) {
|
||||
// 校验存在
|
||||
validateContractExists(id);
|
||||
// 删除
|
||||
contractMapper.deleteById(id);
|
||||
// 删除数据权限
|
||||
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTRACT.getType(), id);
|
||||
}
|
||||
|
||||
private CrmContractDO validateContractExists(Long id) {
|
||||
@ -83,7 +85,6 @@ public class CrmContractServiceImpl implements CrmContractService {
|
||||
return contract;
|
||||
}
|
||||
|
||||
// TODO 芋艿:是否要做数据权限的校验???
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmContractDO getContract(Long id) {
|
||||
@ -99,27 +100,24 @@ public class CrmContractServiceImpl implements CrmContractService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO) {
|
||||
return contractMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
|
||||
public PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO) {
|
||||
return contractMapper.selectPageByCustomer(pageReqVO);
|
||||
public PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO, Long userId) {
|
||||
return contractMapper.selectPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void transferContract(CrmContractTransferReqVO reqVO, Long userId) {
|
||||
// 1 校验合同是否存在
|
||||
// 1. 校验合同是否存在
|
||||
validateContractExists(reqVO.getId());
|
||||
|
||||
// 2. 数据权限转移
|
||||
// 2.1 数据权限转移
|
||||
crmPermissionService.transferPermission(
|
||||
ContractConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()));
|
||||
// 2.2 设置负责人
|
||||
contractMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
||||
// 3. TODO 记录转移日志
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageR
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -56,7 +56,7 @@ public interface CrmCustomerService {
|
||||
* @return 客户列表
|
||||
* @author ljlleo
|
||||
*/
|
||||
List<CrmCustomerDO> getCustomerList(Collection<Long> ids);
|
||||
List<CrmCustomerDO> getCustomerList(Collection<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 获得客户分页
|
||||
@ -71,9 +71,8 @@ public interface CrmCustomerService {
|
||||
* 校验客户是否存在
|
||||
*
|
||||
* @param customerId 客户 id
|
||||
* @return 客户
|
||||
*/
|
||||
CrmCustomerDO validateCustomer(Long customerId);
|
||||
void validateCustomer(Long customerId);
|
||||
|
||||
/**
|
||||
* 客户转移
|
||||
|
@ -15,11 +15,11 @@ import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -78,6 +78,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
|
||||
// 删除
|
||||
customerMapper.deleteById(id);
|
||||
// 删除数据权限
|
||||
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id);
|
||||
}
|
||||
|
||||
private void validateCustomerExists(Long id) {
|
||||
@ -93,32 +95,34 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmCustomerDO> getCustomerList(Collection<Long> ids) {
|
||||
public List<CrmCustomerDO> getCustomerList(Collection<Long> ids, Long userId) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return customerMapper.selectBatchIds(ids);
|
||||
return customerMapper.selectBatchIds(ids, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) {
|
||||
boolean admin = false; // TODO 如果是管理员
|
||||
return customerMapper.selectPage(pageReqVO, userId, adminUserApi.getSubordinateIds(userId), admin);
|
||||
return customerMapper.selectPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验客户是否存在
|
||||
*
|
||||
* @param customerId 客户 id
|
||||
* @return 客户
|
||||
*/
|
||||
@Override
|
||||
public CrmCustomerDO validateCustomer(Long customerId) {
|
||||
CrmCustomerDO customer = getCustomer(customerId);
|
||||
public void validateCustomer(Long customerId) {
|
||||
// TODO puhui999: 不返回客户不走校验应该可行
|
||||
// 校验客户是否存在
|
||||
if (customerId == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
CrmCustomerDO customer = customerMapper.selectById(customerId);
|
||||
if (Objects.isNull(customer)) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
return customer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,9 +132,11 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
// 1. 校验客户是否存在
|
||||
validateCustomer(reqVO.getId());
|
||||
|
||||
// 2. 数据权限转移
|
||||
// 2.1 数据权限转移
|
||||
crmPermissionService.transferPermission(
|
||||
CrmCustomerConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()));
|
||||
// 2.2 转移后重新设置负责人
|
||||
customerMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
||||
// 3. TODO 记录转移日志
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,10 +57,18 @@ public interface CrmPermissionService {
|
||||
*/
|
||||
void deletePermission(Integer bizType, Long bizId, Integer level);
|
||||
|
||||
/**
|
||||
* 删除数据权限
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
|
||||
*/
|
||||
void deletePermission(Integer bizType, Long bizId);
|
||||
|
||||
/**
|
||||
* 批量删除数据权限
|
||||
*
|
||||
* @param ids 权限编号
|
||||
* @param ids 权限编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void deletePermissionBatch(Collection<Long> ids, Long userId);
|
||||
|
@ -11,11 +11,11 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -137,6 +137,17 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
|
||||
crmPermissionMapper.deleteBatchIds(convertSet(permissions, CrmPermissionDO::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePermission(Integer bizType, Long bizId) {
|
||||
List<CrmPermissionDO> permissionList = crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId);
|
||||
if (CollUtil.isEmpty(permissionList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 删除数据权限
|
||||
crmPermissionMapper.deleteBatchIds(convertSet(permissionList, CrmPermissionDO::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePermissionBatch(Collection<Long> ids, Long userId) {
|
||||
List<CrmPermissionDO> permissions = crmPermissionMapper.selectBatchIds(ids);
|
||||
|
@ -1,66 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.vo.CrmBasePageReqVO;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* CRM 分页查询工具类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public class CrmQueryPageUtils {
|
||||
|
||||
// TODO @puhui999:是不是弱化 CrmBasePageReqVO,把 sceneType 作为参数传入。默认其实 pool 不一定要传递的
|
||||
/**
|
||||
* 构造 CRM 数据类型数据分页查询条件
|
||||
*
|
||||
* @param queryMapper 连表查询对象
|
||||
* @param reqVO 查询条件
|
||||
* @param userId 用户编号
|
||||
* @param bizType 数据类型 {@link CrmBizTypeEnum}
|
||||
* @param bizId 数据编号
|
||||
* @param subordinateIds 下属用户编号,可为空
|
||||
*/
|
||||
public static <T extends MPJLambdaWrapper<?>, V extends CrmBasePageReqVO, S> void builderQuery(
|
||||
T queryMapper, V reqVO, Long userId,
|
||||
Integer bizType, SFunction<S, ?> bizId,
|
||||
@Nullable Collection<Long> subordinateIds, // TODO @puhui999:subordinateIds 可以优化成 subordinateUserIds
|
||||
Boolean isAdmin) {
|
||||
// TODO @puhui999:是不是特殊处理,让这个 util 有状态,这样 isAdmin 直接从这里读取;subordinateIds 也是;这样,可以简化参数;
|
||||
// 1. 构建数据权限连表条件
|
||||
if (ObjUtil.notEqual(isAdmin, Boolean.TRUE)) { // 管理员不需要数据权限
|
||||
queryMapper.innerJoin(CrmPermissionDO.class, on ->
|
||||
on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId)
|
||||
.eq(CrmPermissionDO::getUserId, userId));
|
||||
}
|
||||
// 2. 拼接公海的查询条件
|
||||
if (ObjUtil.equal(reqVO.getPool(), Boolean.TRUE)) { // 情况一:公海
|
||||
queryMapper.isNull("owner_user_id");
|
||||
} else { // 情况二:不是公海
|
||||
queryMapper.isNotNull("owner_user_id");
|
||||
}
|
||||
// 3. 拼接场景的查询条件
|
||||
// TODO @puhui999::1 处的数据权限,应该和 3 处的场景是结合的?
|
||||
// null 时:一种处理
|
||||
// 1:一种条件;
|
||||
// 2:一种条件;
|
||||
// 3:一种条件;
|
||||
if (CrmSceneEnum.isOwner(reqVO.getSceneType())) { // 场景一:我负责的数据
|
||||
queryMapper.eq("owner_user_id", userId);
|
||||
}
|
||||
// TODO puhui999: 这里有一个疑问:如果下属负责的数据权限中没有自己的话还能看吗?回复:不能
|
||||
if (CrmSceneEnum.isSubordinate(reqVO.getSceneType()) && CollUtil.isNotEmpty(subordinateIds)) { // 场景三:下属负责的数据
|
||||
queryMapper.in("owner_user_id", subordinateIds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package cn.iocoder.yudao.module.crm.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
/**
|
||||
* CRM 分页查询工具类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public class CrmQueryWrapperUtils {
|
||||
|
||||
/**
|
||||
* 构造 CRM 数据类型数据分页查询条件
|
||||
*
|
||||
* @param queryMapper 连表查询对象
|
||||
* @param bizType 数据类型 {@link CrmBizTypeEnum}
|
||||
* @param bizId 数据编号
|
||||
* @param userId 用户编号
|
||||
* @param sceneType 场景类型
|
||||
* @param pool 公海
|
||||
*/
|
||||
public static <T extends MPJLambdaWrapper<?>, S> void builderPageQuery(
|
||||
T queryMapper, Integer bizType, SFunction<S, ?> bizId, Long userId, Integer sceneType, Boolean pool) {
|
||||
// 1. 构建数据权限连表条件
|
||||
if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限
|
||||
queryMapper.innerJoin(CrmPermissionDO.class, on ->
|
||||
on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId)
|
||||
.eq(CrmPermissionDO::getUserId, userId));
|
||||
}
|
||||
// 1.2 场景一:我负责的数据
|
||||
if (CrmSceneTypeEnum.isOwner(sceneType)) {
|
||||
queryMapper.eq("owner_user_id", userId);
|
||||
}
|
||||
// 1.3 场景一:我参与的数据
|
||||
if (CrmSceneTypeEnum.isInvolved(sceneType)) {
|
||||
queryMapper.ne("owner_user_id", userId);
|
||||
}
|
||||
// 1.4 场景二:下属负责的数据
|
||||
if (CrmSceneTypeEnum.isSubordinate(sceneType)) {
|
||||
List<AdminUserRespDTO> subordinateUsers = getAdminUserApi().getUserListBySubordinate(userId);
|
||||
if (CollUtil.isNotEmpty(subordinateUsers)) {
|
||||
queryMapper.in("owner_user_id", convertSet(subordinateUsers, AdminUserRespDTO::getId));
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 拼接公海的查询条件
|
||||
if (ObjUtil.equal(pool, Boolean.TRUE)) { // 情况一:公海
|
||||
queryMapper.isNull("owner_user_id");
|
||||
} else { // 情况二:不是公海
|
||||
queryMapper.isNotNull("owner_user_id");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造 CRM 数据类型批量数据查询条件
|
||||
*
|
||||
* @param queryMapper 连表查询对象
|
||||
* @param bizType 数据类型 {@link CrmBizTypeEnum}
|
||||
* @param bizIds 数据编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
public static <T extends MPJLambdaWrapper<?>, S> void builderListQueryBatch(
|
||||
T queryMapper, Integer bizType, Collection<Long> bizIds, Long userId) {
|
||||
// 1. 构建数据权限连表条件
|
||||
if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限
|
||||
queryMapper.innerJoin(CrmPermissionDO.class, on ->
|
||||
on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds)
|
||||
.in(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId));
|
||||
}
|
||||
}
|
||||
|
||||
private static AdminUserApi getAdminUserApi() {
|
||||
return SpringUtil.getBean(AdminUserApi.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否是管理员
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 是/否
|
||||
*/
|
||||
private static boolean validateAdminUser(Long userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -3,19 +3,18 @@ package cn.iocoder.yudao.module.crm.service.clue;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
@ -25,6 +24,7 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXIS
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
// TODO 芋艿:单测后续补;
|
||||
|
||||
/**
|
||||
* {@link CrmClueServiceImpl} 的单元测试类
|
||||
*
|
||||
@ -90,8 +90,8 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
// 调用
|
||||
clueService.deleteClue(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(clueMapper.selectById(id));
|
||||
// 校验数据不存在了
|
||||
assertNull(clueMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -106,110 +106,102 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetCluePage() {
|
||||
// mock 数据
|
||||
CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到
|
||||
o.setTransformStatus(null);
|
||||
o.setFollowUpStatus(null);
|
||||
o.setName(null);
|
||||
o.setCustomerId(null);
|
||||
o.setContactNextTime(null);
|
||||
o.setTelephone(null);
|
||||
o.setMobile(null);
|
||||
o.setAddress(null);
|
||||
o.setContactLastTime(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
clueMapper.insert(dbClue);
|
||||
// 测试 transformStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null)));
|
||||
// 测试 followUpStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null)));
|
||||
// 测试 name 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null)));
|
||||
// 测试 customerId 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null)));
|
||||
// 测试 contactNextTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null)));
|
||||
// 测试 telephone 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null)));
|
||||
// 测试 mobile 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null)));
|
||||
// 测试 address 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null)));
|
||||
// 测试 contactLastTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null)));
|
||||
// 测试 createTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
CrmCluePageReqVO reqVO = new CrmCluePageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setTelephone(null);
|
||||
reqVO.setMobile(null);
|
||||
// mock 数据
|
||||
CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到
|
||||
o.setTransformStatus(null);
|
||||
o.setFollowUpStatus(null);
|
||||
o.setName(null);
|
||||
o.setCustomerId(null);
|
||||
o.setContactNextTime(null);
|
||||
o.setTelephone(null);
|
||||
o.setMobile(null);
|
||||
o.setAddress(null);
|
||||
o.setContactLastTime(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
clueMapper.insert(dbClue);
|
||||
// 测试 transformStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null)));
|
||||
// 测试 followUpStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null)));
|
||||
// 测试 name 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null)));
|
||||
// 测试 customerId 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null)));
|
||||
// 测试 contactNextTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null)));
|
||||
// 测试 telephone 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null)));
|
||||
// 测试 mobile 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null)));
|
||||
// 测试 address 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null)));
|
||||
// 测试 contactLastTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null)));
|
||||
// 测试 createTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
CrmCluePageReqVO reqVO = new CrmCluePageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setTelephone(null);
|
||||
reqVO.setMobile(null);
|
||||
|
||||
// 调用
|
||||
PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbClue, pageResult.getList().get(0));
|
||||
// 调用
|
||||
PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO, 1L);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbClue, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetClueList() {
|
||||
// mock 数据
|
||||
CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到
|
||||
o.setTransformStatus(null);
|
||||
o.setFollowUpStatus(null);
|
||||
o.setName(null);
|
||||
o.setCustomerId(null);
|
||||
o.setContactNextTime(null);
|
||||
o.setTelephone(null);
|
||||
o.setMobile(null);
|
||||
o.setAddress(null);
|
||||
o.setContactLastTime(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
clueMapper.insert(dbClue);
|
||||
// 测试 transformStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null)));
|
||||
// 测试 followUpStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null)));
|
||||
// 测试 name 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null)));
|
||||
// 测试 customerId 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null)));
|
||||
// 测试 contactNextTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null)));
|
||||
// 测试 telephone 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null)));
|
||||
// 测试 mobile 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null)));
|
||||
// 测试 address 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null)));
|
||||
// 测试 contactLastTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null)));
|
||||
// 测试 createTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
CrmClueExportReqVO reqVO = new CrmClueExportReqVO();
|
||||
reqVO.setTransformStatus(null);
|
||||
reqVO.setFollowUpStatus(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setCustomerId(null);
|
||||
reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setTelephone(null);
|
||||
reqVO.setMobile(null);
|
||||
reqVO.setAddress(null);
|
||||
reqVO.setOwnerUserId(null);
|
||||
reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
List<CrmClueDO> list = clueService.getClueList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbClue, list.get(0));
|
||||
// mock 数据
|
||||
CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到
|
||||
o.setTransformStatus(null);
|
||||
o.setFollowUpStatus(null);
|
||||
o.setName(null);
|
||||
o.setCustomerId(null);
|
||||
o.setContactNextTime(null);
|
||||
o.setTelephone(null);
|
||||
o.setMobile(null);
|
||||
o.setAddress(null);
|
||||
o.setContactLastTime(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
clueMapper.insert(dbClue);
|
||||
// 测试 transformStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null)));
|
||||
// 测试 followUpStatus 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null)));
|
||||
// 测试 name 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null)));
|
||||
// 测试 customerId 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null)));
|
||||
// 测试 contactNextTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null)));
|
||||
// 测试 telephone 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null)));
|
||||
// 测试 mobile 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null)));
|
||||
// 测试 address 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null)));
|
||||
// 测试 contactLastTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null)));
|
||||
// 测试 createTime 不匹配
|
||||
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
CrmCluePageReqVO reqVO = new CrmCluePageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setTelephone(null);
|
||||
reqVO.setMobile(null);
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
// 调用
|
||||
List<CrmClueDO> list = clueService.getCluePage(reqVO, 1L).getList();
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbClue, list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageR
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
@ -127,7 +126,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
|
||||
reqVO.setNo(null);
|
||||
|
||||
// 调用
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO);
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO, getLoginUserId());
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
|
@ -77,7 +77,6 @@ export function export${simpleClassName}Excel(params) {
|
||||
// ==================== 子表($subTable.classComment) ====================
|
||||
## 情况一:MASTER_ERP 时,需要分查询页子表
|
||||
#if ( $table.templateType == 11 )
|
||||
|
||||
// 获得${subTable.classComment}分页
|
||||
export function get${subSimpleClassName}Page(params) {
|
||||
return request({
|
||||
@ -89,20 +88,18 @@ export function export${simpleClassName}Excel(params) {
|
||||
## 情况二:非 MASTER_ERP 时,需要列表查询子表
|
||||
#else
|
||||
#if ( $subTable.subJoinMany )
|
||||
|
||||
// 获得${subTable.classComment}列表
|
||||
export function get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaField}) {
|
||||
return request({
|
||||
url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField},
|
||||
url: '${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=' + ${subJoinColumn.javaField},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
#else
|
||||
|
||||
// 获得${subTable.classComment}
|
||||
export function get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField}) {
|
||||
return request({
|
||||
url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField},
|
||||
url: '${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=' + ${subJoinColumn.javaField},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@ -113,7 +110,7 @@ export function export${simpleClassName}Excel(params) {
|
||||
// 新增${subTable.classComment}
|
||||
export function create${subSimpleClassName}(data) {
|
||||
return request({
|
||||
url: `${baseURL}/${subSimpleClassName_strikeCase}/create`,
|
||||
url: '${baseURL}/${subSimpleClassName_strikeCase}/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
@ -122,7 +119,7 @@ export function export${simpleClassName}Excel(params) {
|
||||
// 修改${subTable.classComment}
|
||||
export function update${subSimpleClassName}(data) {
|
||||
return request({
|
||||
url: `${baseURL}/${subSimpleClassName_strikeCase}/update`,
|
||||
url: '${baseURL}/${subSimpleClassName_strikeCase}/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
@ -131,7 +128,7 @@ export function export${simpleClassName}Excel(params) {
|
||||
// 删除${subTable.classComment}
|
||||
export function delete${subSimpleClassName}(id) {
|
||||
return request({
|
||||
url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id,
|
||||
url: '${baseURL}/${subSimpleClassName_strikeCase}/delete?id=' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
@ -139,7 +136,7 @@ export function export${simpleClassName}Excel(params) {
|
||||
// 获得${subTable.classComment}
|
||||
export function get${subSimpleClassName}(id) {
|
||||
return request({
|
||||
url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id,
|
||||
url: '${baseURL}/${subSimpleClassName_strikeCase}/get?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Admin 用户 API 接口
|
||||
@ -27,10 +26,10 @@ public interface AdminUserApi {
|
||||
/**
|
||||
* 通过用户 ID 查询用户下属
|
||||
*
|
||||
* @param id 用户编号
|
||||
* @return 用户下属用户编号列表
|
||||
* @param userId 用户编号
|
||||
* @return 用户下属用户列表
|
||||
*/
|
||||
Set<Long> getSubordinateIds(Long id);
|
||||
List<AdminUserRespDTO> getUserListBySubordinate(Long userId);
|
||||
|
||||
/**
|
||||
* 通过用户 ID 查询用户们
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.api.user;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
@ -7,13 +8,13 @@ import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
@ -37,21 +38,32 @@ public class AdminUserApiImpl implements AdminUserApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getSubordinateIds(Long id) {
|
||||
AdminUserDO user = userService.getUser(id);
|
||||
public List<AdminUserRespDTO> getUserListBySubordinate(Long userId) {
|
||||
// 1. 获取用户信息
|
||||
AdminUserDO user = userService.getUser(userId);
|
||||
if (user == null) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Set<Long> subordinateIds = null; // 下属用户编号
|
||||
// 2.1 获取用户负责的部门
|
||||
ArrayList<Long> deptIds = new ArrayList<>();
|
||||
DeptDO dept = deptService.getDept(user.getDeptId());
|
||||
// TODO @puhui999:需要递归查询到子部门;并且要排除到自己噢。
|
||||
// TODO @puhui999:保持 if return 原则,这里其实要判断不等于,则返回 null;最好返回 空集合,上面也是
|
||||
if (ObjUtil.equal(dept.getLeaderUserId(), id)) { // 校验是否是该部门的负责人
|
||||
List<AdminUserDO> users = userService.getUserListByDeptIds(Collections.singletonList(dept.getId()));
|
||||
subordinateIds = convertSet(users, AdminUserDO::getId);
|
||||
if (dept == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return subordinateIds;
|
||||
if (ObjUtil.notEqual(dept.getLeaderUserId(), userId)) { // 校验为负责人
|
||||
return Collections.emptyList();
|
||||
}
|
||||
deptIds.add(dept.getId()); // 加入此部门
|
||||
// 2.2 获取所有子部门
|
||||
List<DeptDO> childDeptList = deptService.getChildDeptList(dept.getId());
|
||||
if (CollUtil.isNotEmpty(childDeptList)) {
|
||||
deptIds.addAll(convertSet(childDeptList, DeptDO::getId));
|
||||
}
|
||||
// 2.3 获取用户信息
|
||||
List<AdminUserDO> users = userService.getUserListByDeptIds(deptIds);
|
||||
users.removeIf(item -> ObjUtil.equal(item.getId(), userId)); // 排除自己
|
||||
return BeanUtils.toBean(users, AdminUserRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,11 +92,11 @@
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- CRM 相关模块。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-crm-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-crm-biz</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- spring boot 配置所需依赖 -->
|
||||
<dependency>
|
||||
|
Loading…
Reference in New Issue
Block a user