图库相关代码&商品单位相关代码

This commit is contained in:
Tankaikai
2025-02-28 11:50:00 +08:00
parent e09e2beb0e
commit 0c5469557e
3 changed files with 37 additions and 7 deletions

View File

@@ -35,7 +35,9 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.and(q -> {
q.eq(PictureClassify::getShopId, shopId).or(q1 -> {
q1.eq(PictureClassify::getShopId, 0).eq(PictureClassify::getIsSystem, YesNoEnum.YES.value());
q1.eq(PictureClassify::getShopId, 1L);
}).or(q2 -> {
q2.eq(PictureClassify::getIsSystem, YesNoEnum.YES.value());
});
});
queryWrapper.eq(PictureClassify::getIsDel, DeleteEnum.NORMAL.value());
@@ -56,7 +58,9 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
boolean exists = super.exists(query().eq(PictureClassify::getName, dto.getName())
.and(q -> {
q.eq(PictureClassify::getShopId, shopId).or(q1 -> {
q1.eq(PictureClassify::getShopId, 0).eq(PictureClassify::getIsSystem, YesNoEnum.YES.value());
q1.eq(PictureClassify::getShopId, 1L);
}).or(q2 -> {
q2.eq(PictureClassify::getIsSystem, YesNoEnum.YES.value());
});
})
);
@@ -78,7 +82,9 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
.ne(PictureClassify::getId, dto.getId())
.and(q -> {
q.eq(PictureClassify::getShopId, shopId).or(q1 -> {
q1.eq(PictureClassify::getShopId, 0).eq(PictureClassify::getIsSystem, YesNoEnum.YES.value());
q1.eq(PictureClassify::getShopId, 1L);
}).or(q2 -> {
q2.eq(PictureClassify::getIsSystem, YesNoEnum.YES.value());
});
})
);
@@ -102,6 +108,7 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
}
private void checkPictureClassify(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
PictureClassify entity = super.getById(id);
if (entity == null) {
throw new CzgException("图片分类不存在");
@@ -109,6 +116,9 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
throw new CzgException("系统预设分类不可操作");
}
if (!shopId.equals(entity.getShopId())) {
throw new CzgException("公共分类不可操作");
}
}
}

View File

@@ -7,6 +7,7 @@ import com.czg.account.entity.PictureGallery;
import com.czg.account.param.PictureGalleryParam;
import com.czg.account.service.PictureGalleryService;
import com.czg.enums.DeleteEnum;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import com.czg.service.account.mapper.PictureGalleryMapper;
import com.czg.utils.PageUtil;
@@ -33,8 +34,13 @@ public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper,
if (ObjUtil.isNotNull(param.getPictureClassifyId())) {
queryWrapper.eq(PictureGallery::getPictureClassifyId, param.getPictureClassifyId());
}
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(PictureGallery::getShopId, shopId);
queryWrapper.and(q -> {
q.eq(PictureGallery::getShopId, shopId).or(q1 -> {
q1.eq(PictureGallery::getShopId, 1L);
});
});
queryWrapper.eq(PictureGallery::getIsDel, DeleteEnum.NORMAL.value());
queryWrapper.orderBy(PictureGallery::getId, false);
return queryWrapper;
@@ -61,7 +67,11 @@ public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper,
@Override
public void deletePictureGallery(Long id) {
PictureGallery entity = super.getById(id);
Long shopId = StpKit.USER.getShopId(0L);
if (!shopId.equals(entity.getShopId())) {
throw new CzgException("公共图片不可操作");
}
UpdateChain.of(PictureGallery.class)
.set(PictureGallery::getIsDel, DeleteEnum.DELETED.value())
.eq(PictureGallery::getShopId, shopId)

View File

@@ -38,7 +38,9 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.and(q -> {
q.eq(ShopProdUnit::getShopId, shopId).or(q1 -> {
q1.eq(ShopProdUnit::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
q1.eq(ShopProdUnit::getShopId, 1L);
}).or(q2 -> {
q2.eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
});
});
queryWrapper.orderBy(ShopProdUnit::getId, false);
@@ -70,7 +72,9 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName())
.and(q -> {
q.eq(ShopProdUnit::getShopId, shopId).or(q1 -> {
q1.eq(ShopProdUnit::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
q1.eq(ShopProdUnit::getShopId, 1L);
}).or(q2 -> {
q2.eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
});
}));
if (exists) {
@@ -95,7 +99,9 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
.ne(ShopProdUnit::getId, dto.getId())
.and(q -> {
q.eq(ShopProdUnit::getShopId, shopId).or(q1 -> {
q1.eq(ShopProdUnit::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
q1.eq(ShopProdUnit::getShopId, 1L);
}).or(q2 -> {
q2.eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
});
})
);
@@ -136,6 +142,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
}
private void checkShopProdUnit(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
ShopProdUnit entity = super.getById(id);
if (entity == null) {
throw new CzgException("单位信息不存在");
@@ -143,5 +150,8 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
throw new CzgException("系统预设单位不可操作");
}
if (!shopId.equals(entity.getShopId())) {
throw new CzgException("公共单位不可操作");
}
}
}