diff --git a/bonus-common-biz/src/main/java/com/bonus/common/houqin/constant/GlobalConstants.java b/bonus-common-biz/src/main/java/com/bonus/common/houqin/constant/GlobalConstants.java index 952d43dc..e8e52c31 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/houqin/constant/GlobalConstants.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/houqin/constant/GlobalConstants.java @@ -5,10 +5,6 @@ package com.bonus.common.houqin.constant; * @author bns_han */ public class GlobalConstants { - /** - * super admin role key - */ - public static final String SUPER_ADMIN_ROLE_KEY = "admin"; /** * 字符串 MSIE */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java index 8a545a4f..4de4b5d9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java @@ -28,6 +28,7 @@ import com.bonus.common.houqin.constant.GlobalConstants; import com.bonus.common.houqin.constant.LeConstants; import com.bonus.common.houqin.i18n.I18n; import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.system.api.domain.SysUser; import com.bonus.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -77,6 +78,12 @@ public class MgrAuthApi { // return this.getTenantOrg(excludeMiddle, DelFlagEnum.DEL_FALSE.key()); // } + public boolean isSuperAdmin() { + MgrUserAuthPO authPO = this.getUserAuthPO(); + String roleCode = authPO.getRoleCode(); + return SysUser.isAdmin(SecurityUtils.getUserId()); // || roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key()) && roleCode.split("&&").length <= 1; + } + public MgrUserAuthPO getUserAuthPO() { MgrUserAuthPO userAuthPO = new MgrUserAuthPO(); LoginUser user = SecurityUtils.getLoginUser(); @@ -90,7 +97,7 @@ public class MgrAuthApi { String roleCodeResult = null; for (String roleCode : roleSet) { roleCodeResult = roleCode; - if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key()) || GlobalConstants.SUPER_ADMIN_ROLE_KEY.equals(roleCode)) { + if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key()) || SysUser.isAdmin(SecurityUtils.getUserId())) { roleType = MgrRoleTypeV2Enum.ROLE_ADMIN.getKey(); // if (CharSequenceUtil.split(roleCode, "&&").size() > 1) { // roleType = MgrRoleTypeV2Enum.ROLE_ADMIN.getKey(); @@ -132,7 +139,8 @@ public class MgrAuthApi { if (!filterOtherRole) { return CollUtil.newArrayList(new AllocCanteenTreeVO[0]); } else if (!ObjectUtil.equal(mgrUserAuthPO.getRoleType(), MgrRoleTypeV2Enum.ROLE_ADMIN.getKey()) - && !ObjectUtil.equal(mgrUserAuthPO.getRoleCode(), GlobalConstants.SUPER_ADMIN_ROLE_KEY) + //&& !ObjectUtil.equal(mgrUserAuthPO.getRoleCode(), GlobalConstants.SUPER_ADMIN_ROLE_KEY) + && !SysUser.isAdmin(SecurityUtils.getUserId()) && !ObjectUtil.equal(mgrUserAuthPO.getRoleType(), MgrRoleTypeV2Enum.ROLE_ORG.getKey())) { return this.mgrRoleCanteenMapper.getTenantCanteen(excludeMiddle, tenantId, mgrUserAuthPO, delFlag); } else { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java index 37e4761b..3f857308 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java @@ -6,6 +6,7 @@ import com.bonus.canteen.core.auth.enums.RoleCodeV2Enum; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.houqin.constant.GlobalConstants; import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.system.api.domain.SysUser; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.HexValue; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; @@ -88,7 +89,7 @@ public class LeNiuDataPermissionHandler { private String getSqlByAliasAndPermissionType(Long userId, String roleCode, DataPermissionTypeEnum permissionType, String alias) { StringBuilder sb = new StringBuilder(); - if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key()) || GlobalConstants.SUPER_ADMIN_ROLE_KEY.equals(roleCode)) { + if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key()) || SysUser.isAdmin(SecurityUtils.getUserId())) { return ""; } else { if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_ORG, permissionType)) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/api/DrpAuthorityApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/api/DrpAuthorityApi.java index dabaea40..ead5bff4 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/api/DrpAuthorityApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/api/DrpAuthorityApi.java @@ -1,5 +1,6 @@ package com.bonus.canteen.core.drp.api; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.bonus.canteen.core.auth.api.MgrAuthApi; import com.bonus.canteen.core.drp.mapper.DrpSupplierMapper; @@ -46,21 +47,21 @@ public class DrpAuthorityApi { // public MgrUserAuthPO getUserAuthPO() { // return this.mgrAuthApi.getUserAuthPO(); // } -// -// public List authAreaList(List areaIdList) { -// if (this.mgrAuthApi.isSuperAdmin()) { -// return areaIdList; -// } else { -// List authArea = this.mgrAuthApi.getTenantAreaIdList(); -// if (CollUtil.isEmpty(areaIdList)) { -// return authArea; -// } else { -// authArea.retainAll(areaIdList); -// return (List)(CollUtil.isEmpty(authArea) ? CollUtil.newArrayList(new Long[]{-1L}) : authArea); -// } -// } -// } -// + + public List authAreaList(List areaIdList) { + if (this.mgrAuthApi.isSuperAdmin()) { + return areaIdList; + } else { + List authArea = this.mgrAuthApi.getTenantAreaIdList(); + if (CollUtil.isEmpty(areaIdList)) { + return authArea; + } else { + authArea.retainAll(areaIdList); + return (List)(CollUtil.isEmpty(authArea) ? CollUtil.newArrayList(new Long[]{-1L}) : authArea); + } + } + } + // public Long getAreaByDeviceSn(String machineSn) { // try { // return ((DeviceBind)this.deviceApi.listBindByDeviceSn(machineSn).get(0)).getAreaId(); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/DrpSupplierCategoryService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/DrpSupplierCategoryService.java new file mode 100644 index 00000000..1cdbe729 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/DrpSupplierCategoryService.java @@ -0,0 +1,7 @@ +package com.bonus.canteen.core.drp.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bonus.canteen.core.drp.model.DrpSupplierCategory; + +public interface DrpSupplierCategoryService extends IService { +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/impl/DrpSupplierCategoryServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/impl/DrpSupplierCategoryServiceImpl.java new file mode 100644 index 00000000..f7e62921 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/impl/DrpSupplierCategoryServiceImpl.java @@ -0,0 +1,11 @@ +package com.bonus.canteen.core.drp.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bonus.canteen.core.drp.mapper.DrpSupplierCategoryMapper; +import com.bonus.canteen.core.drp.model.DrpSupplierCategory; +import com.bonus.canteen.core.drp.service.DrpSupplierCategoryService; +import org.springframework.stereotype.Service; + +@Service +public class DrpSupplierCategoryServiceImpl extends ServiceImpl implements DrpSupplierCategoryService { +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/impl/DrpSupplierServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/impl/DrpSupplierServiceImpl.java index 45e1332a..3e6a6b1b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/impl/DrpSupplierServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/drp/service/impl/DrpSupplierServiceImpl.java @@ -28,6 +28,7 @@ import com.bonus.canteen.core.drp.model.DrpSupplierCategory; import com.bonus.canteen.core.drp.model.DrpSupplierDeliver; import com.bonus.canteen.core.drp.model.DrpSupplierQualification; import com.bonus.canteen.core.drp.po.CategoryModel; +import com.bonus.canteen.core.drp.service.DrpSupplierCategoryService; import com.bonus.canteen.core.drp.service.DrpSupplierDeliverService; import com.bonus.canteen.core.drp.service.DrpSupplierQualificationService; import com.bonus.canteen.core.drp.service.DrpSupplierService; @@ -65,9 +66,9 @@ public class DrpSupplierServiceImpl extends ServiceImpl categoryIdList, Long supplierId) { -// List supplierCategoryList = new ArrayList(); -// Iterator var4 = categoryIdList.iterator(); -// -// while(var4.hasNext()) { -// Long categoryId = (Long)var4.next(); -// DrpSupplierCategory supplierCategory = new DrpSupplierCategory(); -// supplierCategory.setSupplierId(supplierId); -// supplierCategory.setCategoryId(categoryId); -// supplierCategoryList.add(supplierCategory); -// } -// -// this.drpSupplierCategoryService.saveBatch(supplierCategoryList); -// } -// + + protected void insertSupplierCategoryBatch(List categoryIdList, Long supplierId) { + List supplierCategoryList = new ArrayList(); + Iterator var4 = categoryIdList.iterator(); + + while(var4.hasNext()) { + Long categoryId = (Long)var4.next(); + DrpSupplierCategory supplierCategory = new DrpSupplierCategory(); + supplierCategory.setSupplierId(supplierId); + supplierCategory.setCategoryId(categoryId); + supplierCategoryList.add(supplierCategory); + } + + this.drpSupplierCategoryService.saveBatch(supplierCategoryList); + } + // public List getMaterialSupplier(DrpMaterialInfoDTO content) { // List drpMaterialSupplierList; // if (!ObjectUtil.isNull(content.getConfigType()) && !ObjectUtil.equal(content.getConfigType(), 1)) {