mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-20 19:20:32 +08:00
!702 CRM【商机】【联系人】【合同】新增 transfer 接口
Merge pull request !702 from puhui999/feature/crm
This commit is contained in:
commit
f73b857551
@ -11,12 +11,16 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 合同管理 1-020-000-000 ==========
|
||||
ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在");
|
||||
ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限");
|
||||
ErrorCode CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_000_002, "合同转移失败,原因:负责人不存在");
|
||||
|
||||
// ========== 线索管理 1-020-001-000 ==========
|
||||
ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在");
|
||||
|
||||
// ========== 商机管理 1-020-002-000 ==========
|
||||
ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在");
|
||||
ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限");
|
||||
ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机转移失败,原因:负责人不存在");
|
||||
|
||||
// TODO @lilleo:商机状态、商机类型,都单独错误码段
|
||||
|
||||
@ -25,6 +29,8 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 联系人管理 1-020-003-000 ==========
|
||||
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
|
||||
ErrorCode CONTACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_003_001, "联系人转移失败,原因:没有转移权限");
|
||||
ErrorCode CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_003_002, "联系人转移失败,原因:负责人不存在");
|
||||
|
||||
// TODO @liuhongfeng:错误码分段;
|
||||
ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在");
|
||||
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
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
|
||||
@ -80,11 +81,19 @@ public class CrmBusinessController {
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<CrmBusinessDO> list = businessService.getBusinessList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<CrmBusinessExcelVO> datas = CrmBusinessConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "商机转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) {
|
||||
businessService.businessTransfer(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,12 +5,21 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 商机创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO {
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
|
||||
// TODO @ljileo:新建的时候,应该可以传递添加的产品;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 商机转移 Request VO")
|
||||
@Data
|
||||
public class CrmBusinessTransferReqVO {
|
||||
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId; // 新的负责人
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 商机更新 Request VO")
|
||||
@Data
|
||||
@ -17,6 +18,13 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO {
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
|
||||
// TODO @ljileo:修改的时候,应该可以传递添加的产品;
|
||||
|
||||
}
|
||||
|
@ -1,32 +1,30 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
|
||||
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
|
||||
import cn.iocoder.yudao.module.crm.service.contact.ContactService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
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
|
||||
@ -99,4 +97,12 @@ public class ContactController {
|
||||
ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "联系人转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) {
|
||||
contactService.contactTransfer(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import javax.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - crm联系人创建 Request VO")
|
||||
@Data
|
||||
@ -11,4 +13,10 @@ import javax.validation.constraints.*;
|
||||
@ToString(callSuper = true)
|
||||
public class ContactCreateReqVO extends ContactBaseVO {
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - crm联系人更新 Request VO")
|
||||
@Data
|
||||
@ -14,4 +16,10 @@ public class ContactUpdateReqVO extends ContactBaseVO {
|
||||
@Schema(description = "主键", example = "23210")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 联系人转移 Request VO")
|
||||
@Data
|
||||
public class CrmContactTransferReqVO {
|
||||
|
||||
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId; // 新的负责人
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
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
|
||||
@ -86,4 +87,13 @@ public class ContractController {
|
||||
ExcelUtils.write(response, "合同.xls", "数据", ContractExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "合同转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contract:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContractTransferReqVO reqVO) {
|
||||
contractService.contractTransfer(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 合同创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ -12,9 +14,9 @@ import lombok.ToString;
|
||||
public class ContractCreateReqVO extends ContractBaseVO {
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private String roUserIds;
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private String rwUserIds;
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 合同更新 Request VO")
|
||||
@Data
|
||||
@ -18,9 +19,9 @@ public class ContractUpdateReqVO extends ContractBaseVO {
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "只读权限的用户编号数组")
|
||||
private String roUserIds;
|
||||
private Set<Long> roUserIds;
|
||||
|
||||
@Schema(description = "读写权限的用户编号数组")
|
||||
private String rwUserIds;
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 合同转移 Request VO")
|
||||
@Data
|
||||
public class CrmContractTransferReqVO {
|
||||
|
||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "合同编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long ownerUserId; // 新的负责人
|
||||
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.business;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 商机 Convert
|
||||
@ -29,4 +30,12 @@ public interface CrmBusinessConvert {
|
||||
|
||||
List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list);
|
||||
|
||||
default CrmBusinessDO convert(CrmBusinessDO business, CrmBusinessTransferReqVO reqVO, Long userId) {
|
||||
Set<Long> rwUserIds = business.getRwUserIds();
|
||||
rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人
|
||||
rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人
|
||||
return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人
|
||||
.setRwUserIds(rwUserIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.contact;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* crm联系人 Convert
|
||||
@ -31,4 +32,12 @@ public interface ContactConvert {
|
||||
|
||||
List<ContactExcelVO> convertList02(List<ContactDO> list);
|
||||
|
||||
default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) {
|
||||
Set<Long> rwUserIds = contact.getRwUserIds();
|
||||
rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人
|
||||
rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人
|
||||
return new ContactDO().setId(contact.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人
|
||||
.setRwUserIds(rwUserIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.contract;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExcelVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 合同 Convert
|
||||
@ -33,4 +32,12 @@ public interface ContractConvert {
|
||||
|
||||
List<ContractExcelVO> convertList02(List<ContractDO> list);
|
||||
|
||||
default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) {
|
||||
Set<Long> rwUserIds = contract.getRwUserIds();
|
||||
rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人
|
||||
rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人
|
||||
return new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人
|
||||
.setRwUserIds(rwUserIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.business;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 商机 DO
|
||||
@ -85,16 +88,14 @@ public class CrmBusinessDO extends BaseDO {
|
||||
private Long ownerUserId;
|
||||
/**
|
||||
* 只读权限的用户编号数组
|
||||
*
|
||||
* TODO @lijie:应该是 List<Long>,然后使用下对应的 typehandler
|
||||
*/
|
||||
private String roUserIds;
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> roUserIds;
|
||||
/**
|
||||
* 读写权限的用户编号数组
|
||||
*
|
||||
* TODO @lijie:应该是 List<Long>,然后使用下对应的 typehandler
|
||||
*/
|
||||
private String rwUserIds;
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> rwUserIds;
|
||||
/**
|
||||
* 1赢单2输单3无效
|
||||
*
|
||||
|
@ -1,12 +1,15 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.contact;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* crm 联系人 DO
|
||||
@ -77,4 +80,15 @@ public class ContactDO extends BaseDO {
|
||||
*/
|
||||
private LocalDateTime lastTime;
|
||||
|
||||
/**
|
||||
* 只读权限的用户编号数组
|
||||
*/
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> roUserIds;
|
||||
/**
|
||||
* 读写权限的用户编号数组
|
||||
*/
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> rwUserIds;
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.contract;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 合同 DO
|
||||
@ -79,11 +82,13 @@ public class ContractDO extends BaseDO {
|
||||
/**
|
||||
* 只读权限的用户编号数组
|
||||
*/
|
||||
private String roUserIds;
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> roUserIds;
|
||||
/**
|
||||
* 读写权限的用户编号数组
|
||||
*/
|
||||
private String rwUserIds;
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> rwUserIds;
|
||||
/**
|
||||
* 联系人编号
|
||||
*/
|
||||
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.crm.framework.utils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 数据读写权限校验工具类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public class AuthUtil {
|
||||
|
||||
/**
|
||||
* 判断当前数据对用户来说是否是只读的
|
||||
*
|
||||
* @param roUserIds 当前操作数据的只读权限的用户编号数组
|
||||
* @param userId 当前操作数据的用户编号
|
||||
* @return boolean 是/否
|
||||
*/
|
||||
public static boolean isReadOnly(Collection<Long> roUserIds, Long userId) {
|
||||
return roUserIds.contains(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前数据对用户来说是否是可读写的
|
||||
*
|
||||
* @param rwUserIds 当前操作数据的读写权限的用户编号数组
|
||||
* @param userId 当前操作数据的用户编号
|
||||
* @return boolean 是/否
|
||||
*/
|
||||
public static boolean isReadAndWrite(Collection<Long> rwUserIds, Long userId) {
|
||||
return rwUserIds.contains(userId);
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.service.business;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@ -72,4 +69,12 @@ public interface CrmBusinessService {
|
||||
*/
|
||||
List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 商机转移
|
||||
*
|
||||
* @param reqVO 请求
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,12 @@ 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.CrmBusinessCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
|
||||
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.mysql.business.CrmBusinessMapper;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -18,7 +17,8 @@ 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.BUSINESS_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite;
|
||||
|
||||
/**
|
||||
* 商机 Service 实现类
|
||||
@ -32,6 +32,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
@Resource
|
||||
private CrmBusinessMapper businessMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public Long createBusiness(CrmBusinessCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -58,10 +61,12 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
businessMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateBusinessExists(Long id) {
|
||||
if (businessMapper.selectById(id) == null) {
|
||||
private CrmBusinessDO validateBusinessExists(Long id) {
|
||||
CrmBusinessDO crmBusiness = businessMapper.selectById(id);
|
||||
if (crmBusiness == null) {
|
||||
throw exception(BUSINESS_NOT_EXISTS);
|
||||
}
|
||||
return crmBusiness;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,4 +92,26 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
||||
return businessMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验商机是否存在
|
||||
CrmBusinessDO business = validateBusinessExists(reqVO.getId());
|
||||
// 1.2. 校验用户是否拥有读写权限
|
||||
if (!isReadAndWrite(business.getRwUserIds(), userId)) {
|
||||
throw exception(BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED);
|
||||
}
|
||||
// 2. 校验新负责人是否存在
|
||||
AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId());
|
||||
if (user == null) {
|
||||
throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 3. 更新新的负责人
|
||||
CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId);
|
||||
businessMapper.updateById(updateBusiness);
|
||||
|
||||
// 4. TODO 记录商机转移日志
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package cn.iocoder.yudao.module.crm.service.contact;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* crm联系人 Service 接口
|
||||
@ -67,4 +69,12 @@ public interface ContactService {
|
||||
*/
|
||||
List<ContactDO> getContactList(ContactExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 联系人编号
|
||||
*
|
||||
* @param reqVO 请求
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void contactTransfer(CrmContactTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.service.contact;
|
||||
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.contact.vo.ContactCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -18,7 +17,8 @@ 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.CONTACT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite;
|
||||
|
||||
/**
|
||||
* crm联系人 Service 实现类
|
||||
@ -32,6 +32,9 @@ public class ContactServiceImpl implements ContactService {
|
||||
@Resource
|
||||
private ContactMapper contactMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public Long createContact(ContactCreateReqVO createReqVO) {
|
||||
// TODO @customerId:需要校验存在
|
||||
@ -61,10 +64,12 @@ public class ContactServiceImpl implements ContactService {
|
||||
contactMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateContactExists(Long id) {
|
||||
if (contactMapper.selectById(id) == null) {
|
||||
private ContactDO validateContactExists(Long id) {
|
||||
ContactDO contact = contactMapper.selectById(id);
|
||||
if (contact == null) {
|
||||
throw exception(CONTACT_NOT_EXISTS);
|
||||
}
|
||||
return contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,4 +95,26 @@ public class ContactServiceImpl implements ContactService {
|
||||
return contactMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验联系人是否存在
|
||||
ContactDO contact = validateContactExists(reqVO.getId());
|
||||
// 1.2. 校验用户是否拥有读写权限
|
||||
if (!isReadAndWrite(contact.getRwUserIds(), userId)) {
|
||||
throw exception(CONTACT_TRANSFER_FAIL_PERMISSION_DENIED);
|
||||
}
|
||||
// 2. 校验新负责人是否存在
|
||||
AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId());
|
||||
if (user == null) {
|
||||
throw exception(CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 3. 更新新的负责人
|
||||
ContactDO updateContact = ContactConvert.INSTANCE.convert(contact, reqVO, userId);
|
||||
contactMapper.updateById(updateContact);
|
||||
|
||||
// 4. TODO 记录联系人转移日志
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
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.ContractCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@ -72,4 +69,12 @@ public interface ContractService {
|
||||
*/
|
||||
List<ContractDO> getContractList(ContractExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 合同转移
|
||||
*
|
||||
* @param reqVO 请求
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void contractTransfer(CrmContractTransferReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.service.contract;
|
||||
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.contract.vo.ContractCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contract.ContractMapper;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -18,7 +17,8 @@ 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.CONTRACT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite;
|
||||
|
||||
/**
|
||||
* 合同 Service 实现类
|
||||
@ -32,6 +32,9 @@ public class ContractServiceImpl implements ContractService {
|
||||
@Resource
|
||||
private ContractMapper contractMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public Long createContract(ContractCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -58,10 +61,12 @@ public class ContractServiceImpl implements ContractService {
|
||||
contractMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateContractExists(Long id) {
|
||||
if (contractMapper.selectById(id) == null) {
|
||||
private ContractDO validateContractExists(Long id) {
|
||||
ContractDO contract = contractMapper.selectById(id);
|
||||
if (contract == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
return contract;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,4 +92,26 @@ public class ContractServiceImpl implements ContractService {
|
||||
return contractMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验合同是否存在
|
||||
ContractDO contract = validateContractExists(reqVO.getId());
|
||||
// 1.2. 校验用户是否拥有读写权限
|
||||
if (!isReadAndWrite(contract.getRwUserIds(), userId)) {
|
||||
throw exception(CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED);
|
||||
}
|
||||
// 2. 校验新负责人是否存在
|
||||
AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId());
|
||||
if (user == null) {
|
||||
throw exception(CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 3. 更新新的负责人
|
||||
ContractDO updateContract = ContractConvert.INSTANCE.convert(contract, reqVO, userId);
|
||||
contractMapper.updateById(updateContract);
|
||||
|
||||
// 4. TODO 记录合同转移日志
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user