diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java index 5f0e04e1..77c173ce 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java @@ -6,11 +6,13 @@ import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.gson.Gson; import com.suisung.mall.common.api.CommonResult; +import com.suisung.mall.common.domain.UserDto; import com.suisung.mall.common.enums.DicEnum; import com.suisung.mall.common.exception.ApiException; import com.suisung.mall.common.modules.base.ShopBaseProductBrand; import com.suisung.mall.common.modules.base.ShopBaseProductCategory; import com.suisung.mall.common.modules.sync.StoreDbConfig; +import com.suisung.mall.common.utils.ContextUtil; import com.suisung.mall.shop.base.service.ShopBaseProductBrandService; import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService; import com.suisung.mall.shop.number.service.ShopNumberSeqService; @@ -110,6 +112,9 @@ public class ShopSyncImportServiceImpl implements ShopSyncImportService { @Override public CommonResult importBrandData(MultipartFile file,String storeId) { + if(!checkIsPlate()){ + throw new ApiException("用户无权限"); + } String fileName = storeUploadedFile(file); try { List excelList = readBrandExcelData(fileName); @@ -133,6 +138,9 @@ public class ShopSyncImportServiceImpl implements ShopSyncImportService { @Override public CommonResult importCategoryData(MultipartFile file,String storeId) { + if(!checkIsPlate()){ + throw new ApiException("用户无权限"); + } String fileName = storeUploadedFile(file); try { List excelList = readCategoryExcelData(fileName); @@ -157,6 +165,9 @@ public class ShopSyncImportServiceImpl implements ShopSyncImportService { @Override @Async public void importShopsData(MultipartFile file,String storeId) { + if(!checkIsPlate()){ + throw new ApiException("用户无权限"); + } String fileName = storeUploadedFile(file); readAndImportShopsExcelData(fileName,storeId); } @@ -244,6 +255,16 @@ public class ShopSyncImportServiceImpl implements ShopSyncImportService { private void initData(String storeId){ shopBaseProductCategoryService.getCategoryListByStoreId(storeId); } + + /** + * 判断是否平台 + * @return + */ + private boolean checkIsPlate(){ + UserDto userDto= ContextUtil.getCurrentUser(); + assert userDto != null; + return 9 == userDto.getRole_id(); + } }