package com.jtzx.crm.module.sys.service; import cc.uncarbon.framework.core.context.UserContextHolder; import cc.uncarbon.framework.core.exception.BusinessException; import cn.hutool.core.collection.CollUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; /** * 客户数据权限业务 */ @RequiredArgsConstructor @Service @Slf4j public class SysCustomerDataPermissionService { /** * 客户权限,只允许管理员和普通成员查看,没有小组长权限,如果小组长同时是管理员或普通成员,则可以查看 */ public void publicPrivateCustomerPermission() throws BusinessException{ if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles())) { throw new BusinessException(400, "无权操作"); } if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) { throw new BusinessException(400, "无权操作"); } } public void adminPermission() throws BusinessException{ if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) { throw new BusinessException(400, "无权操作"); } } }