1.1.39 客户、客户联系人信息本人创建的客户可以查看、修改。拥有客户管理员角色权限字符是KHMA的用户能维护所有客户信息。

dev
yinq 2 months ago
parent f161d26c28
commit dc98061b74

@ -1,5 +1,6 @@
package org.dromara.oa.crm.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -7,8 +8,8 @@ import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.oa.crm.domain.CrmCustomerInfo;
import org.springframework.stereotype.Service;
import org.dromara.oa.crm.domain.bo.CrmCustomerContactBo;
@ -33,6 +34,32 @@ public class CrmCustomerContactServiceImpl implements ICrmCustomerContactService
private final CrmCustomerContactMapper baseMapper;
/**
*
*/
private static final String CRM_CUSTOMER_ADMIN_ROLE_KEY = "KHMA";
/**
*
*/
private boolean isCrmCustomerDataAdmin() {
return LoginHelper.isSuperAdmin() || StpUtil.hasRole(CRM_CUSTOMER_ADMIN_ROLE_KEY);
}
/**
*
*/
private void applyCustomerDataScope(MPJLambdaWrapper<CrmCustomerContact> lqw) {
if (isCrmCustomerDataAdmin()) {
return;
}
Long userId = LoginHelper.getUserId();
if (userId == null) {
lqw.eq(CrmCustomerContact::getContactId, -1L);
return;
}
lqw.eq(CrmCustomerContact::getCreateBy, userId);
}
/**
*
*
@ -91,6 +118,7 @@ public class CrmCustomerContactServiceImpl implements ICrmCustomerContactService
.eq(StringUtils.isNotBlank(bo.getWechatAccount()), CrmCustomerContact::getWechatAccount, bo.getWechatAccount())
.eq(StringUtils.isNotBlank(bo.getQqNumber()), CrmCustomerContact::getQqNumber, bo.getQqNumber())
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), CrmCustomerContact::getActiveFlag, bo.getActiveFlag());
applyCustomerDataScope(lqw);
return lqw;
}

@ -1,13 +1,16 @@
package org.dromara.oa.crm.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.satoken.utils.LoginHelper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.dromara.oa.crm.domain.bo.CrmCustomerInfoBo;
@ -30,8 +33,35 @@ import java.util.Collection;
@Service
public class CrmCustomerInfoServiceImpl implements ICrmCustomerInfoService {
/**
*
*/
private static final String CRM_CUSTOMER_ADMIN_ROLE_KEY = "KHMA";
private final CrmCustomerInfoMapper baseMapper;
/**
*
*/
private boolean isCrmCustomerDataAdmin() {
return LoginHelper.isSuperAdmin() || StpUtil.hasRole(CRM_CUSTOMER_ADMIN_ROLE_KEY);
}
/**
*
*/
private void applyCustomerDataScope(MPJLambdaWrapper<CrmCustomerInfo> lqw) {
if (isCrmCustomerDataAdmin()) {
return;
}
Long userId = LoginHelper.getUserId();
if (userId == null) {
lqw.eq(CrmCustomerInfo::getCustomerId, -1L);
return;
}
lqw.eq(CrmCustomerInfo::getCreateBy, userId);
}
/**
*
*
@ -94,6 +124,7 @@ public class CrmCustomerInfoServiceImpl implements ICrmCustomerInfoService {
.eq(StringUtils.isNotBlank(bo.getOurCompanyFlag()), CrmCustomerInfo::getOurCompanyFlag, bo.getOurCompanyFlag())
.eq(bo.getParentCustomerId() != null, CrmCustomerInfo::getParentCustomerId, bo.getParentCustomerId())
.eq("t.del_flag", "0");
applyCustomerDataScope(lqw);
return lqw;
}

Loading…
Cancel
Save