SysCustomerDataPermissionService.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.jtzx.crm.module.sys.service;
  2. import cc.uncarbon.framework.core.context.UserContextHolder;
  3. import cc.uncarbon.framework.core.exception.BusinessException;
  4. import cn.hutool.core.collection.CollUtil;
  5. import lombok.RequiredArgsConstructor;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.stereotype.Service;
  8. /**
  9. * 客户数据权限业务
  10. */
  11. @RequiredArgsConstructor
  12. @Service
  13. @Slf4j
  14. public class SysCustomerDataPermissionService {
  15. /**
  16. * 客户权限,只允许管理员和普通成员查看,没有小组长权限,如果小组长同时是管理员或普通成员,则可以查看
  17. */
  18. public void publicPrivateCustomerPermission() throws BusinessException{
  19. if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles())) {
  20. throw new BusinessException(400, "无权操作");
  21. }
  22. if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
  23. throw new BusinessException(400, "无权操作");
  24. }
  25. }
  26. public void adminPermission() throws BusinessException{
  27. if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
  28. throw new BusinessException(400, "无权操作");
  29. }
  30. }
  31. }