控制平台导入权限

This commit is contained in:
liyj 2025-12-29 09:38:40 +08:00
parent 7f0d3e9897
commit e919a934dd

View File

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