图库相关代码&商品单位相关代码
This commit is contained in:
@@ -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("公共单位不可操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user