mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
CRM:code review 客户权限的实现
This commit is contained in:
@ -13,6 +13,7 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class CrmBusinessTransferReqVO {
|
||||
|
||||
// TODO @puhui999:这里最好还是用 id 哈,主要还是在 Business 业务里
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "商机编号不能为空")
|
||||
private Long bizId;
|
||||
|
@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.crm.framework.excel.core.AreaExcelColumnSelectFunctionImpl;
|
||||
import cn.iocoder.yudao.module.crm.framework.excel.core.AreaExcelColumnSelectFunction;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -43,7 +43,7 @@ public class CrmCustomerImportExcelVO {
|
||||
private String email;
|
||||
|
||||
@ExcelProperty(value = "地区", converter = AreaConvert.class)
|
||||
@ExcelColumnSelect(functionName = AreaExcelColumnSelectFunctionImpl.NAME)
|
||||
@ExcelColumnSelect(functionName = AreaExcelColumnSelectFunction.NAME)
|
||||
private Integer areaId;
|
||||
|
||||
@ExcelProperty("详细地址")
|
||||
|
@ -31,7 +31,7 @@ public class CrmCustomerTransferReqVO {
|
||||
private Integer oldOwnerPermissionLevel;
|
||||
|
||||
/**
|
||||
* 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择
|
||||
* 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择。选中时,也一起转移
|
||||
*/
|
||||
@Schema(description = "同时转移", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
private List<Integer> toBizTypes;
|
||||
|
@ -68,22 +68,24 @@ public class CrmPermissionController {
|
||||
@Resource
|
||||
private PostApi postApi;
|
||||
|
||||
// TODO @puhui999:是不是还是叫 create 好点哈。
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建数据权限")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PreAuthorize("@ss.hasPermission('crm:permission:create')")
|
||||
@CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
||||
public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionSaveReqVO reqVO) {
|
||||
public CommonResult<Boolean> savePermission(@Valid @RequestBody CrmPermissionSaveReqVO reqVO) {
|
||||
permissionService.createPermission(BeanUtils.toBean(reqVO, CrmPermissionCreateReqBO.class));
|
||||
// 处理【同时添加至】的权限
|
||||
if (CollUtil.isNotEmpty(reqVO.getToBizTypes())) {
|
||||
createBizTypePermissions(reqVO);
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
private void createBizTypePermissions(CrmPermissionSaveReqVO reqVO) {
|
||||
List<CrmPermissionCreateReqBO> createPermissions = new ArrayList<>();
|
||||
// TODO @puhui999:需要考虑,被添加人,是不是应该有对应的权限了;
|
||||
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) {
|
||||
List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getBizId(), getLoginUserId());
|
||||
contactList.forEach(item -> {
|
||||
|
@ -33,7 +33,8 @@ public class CrmPermissionSaveReqVO {
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 添加客户团队成员时,需要额外有【联系人】【商机】【合同】的 checkbox 选择
|
||||
* 添加客户团队成员时,需要额外有【联系人】【商机】【合同】的 checkbox 选择。
|
||||
* 选中时,同时添加对应的权限
|
||||
*/
|
||||
@Schema(description = "同时添加", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
private List<Integer> toBizTypes;
|
||||
|
@ -74,6 +74,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
|
||||
}
|
||||
|
||||
default List<CrmContactDO> selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) {
|
||||
// TODO @puhui999:父类有 selectList,查询 2 个字段的简化方法哈,可以用下
|
||||
return selectList(new LambdaQueryWrapperX<CrmContactDO>()
|
||||
.eq(CrmContactDO::getCustomerId, customerId)
|
||||
.eq(CrmContactDO::getOwnerUserId, ownerUserId));
|
||||
|
@ -99,4 +99,8 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
||||
return convertMap(result, obj -> (Long) obj.get("contract_id"), obj -> (BigDecimal) obj.get("total_price"));
|
||||
}
|
||||
|
||||
default Long selectCountByContractId(Long contractId) {
|
||||
return selectCount(CrmReceivableDO::getContractId, contractId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,10 +10,12 @@ import java.util.List;
|
||||
/**
|
||||
* Excel 所属地区列下拉数据源获取接口实现类
|
||||
*
|
||||
* // TODO @puhui999:类名叫:地区下拉框数据源的 {@link ExcelColumnSelectFunction} 实现类,这样看起来会更简洁一点哈
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
public class AreaExcelColumnSelectFunctionImpl implements ExcelColumnSelectFunction {
|
||||
public class AreaExcelColumnSelectFunction implements ExcelColumnSelectFunction {
|
||||
|
||||
public static final String NAME = "getCrmAreaNameList"; // 防止和别的模块重名
|
||||
|
@ -1 +1,4 @@
|
||||
/**
|
||||
* crm 模块的 excel 拓展封装
|
||||
*/
|
||||
package cn.iocoder.yudao.module.crm.framework.excel;
|
@ -1 +1,4 @@
|
||||
/**
|
||||
* crm 模块的 operatelog 拓展封装
|
||||
*/
|
||||
package cn.iocoder.yudao.module.crm.framework.operatelog;
|
@ -1 +1,4 @@
|
||||
/**
|
||||
* crm 模块的 permission 拓展封装
|
||||
*/
|
||||
package cn.iocoder.yudao.module.crm.framework.permission;
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
* trade 模块的 web 配置
|
||||
* crm 模块的 web 拓展封装
|
||||
*/
|
||||
package cn.iocoder.yudao.module.crm.framework.web;
|
||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -27,7 +26,6 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm
|
||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerServiceImpl;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||
@ -231,7 +229,7 @@ public class CrmContractServiceImpl implements CrmContractService {
|
||||
// 1.1 校验存在
|
||||
CrmContractDO contract = validateContractExists(id);
|
||||
// 1.2 如果被 CrmReceivableDO 所使用,则不允许删除
|
||||
if (receivableService.getReceivableByContractId(contract.getId()) != 0) {
|
||||
if (receivableService.getReceivableCountByContractId(contract.getId()) > 0) {
|
||||
throw exception(CONTRACT_DELETE_FAIL);
|
||||
}
|
||||
|
||||
|
@ -123,11 +123,11 @@ public interface CrmReceivableService {
|
||||
Map<Long, BigDecimal> getReceivablePriceMapByContractId(Collection<Long> contractIds);
|
||||
|
||||
/**
|
||||
* 更具合同编号查询回款列表
|
||||
* 根据合同编号查询回款数量
|
||||
*
|
||||
* @param contractId 合同编号
|
||||
* @return 回款
|
||||
* @return 回款数量
|
||||
*/
|
||||
Long getReceivableByContractId(Long contractId);
|
||||
Long getReceivableCountByContractId(Long contractId);
|
||||
|
||||
}
|
||||
|
@ -302,8 +302,8 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getReceivableByContractId(Long contractId) {
|
||||
return receivableMapper.selectCount(CrmReceivableDO::getContractId, contractId);
|
||||
public Long getReceivableCountByContractId(Long contractId) {
|
||||
return receivableMapper.selectCountByContractId(contractId);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user