删除 delete 枚举

This commit is contained in:
gong
2025-12-18 20:42:53 +08:00
parent 8ea7ef8c50
commit 0000302d62
9 changed files with 34 additions and 65 deletions

View File

@@ -3,7 +3,7 @@ package com.czg.controller.admin;
import cn.hutool.core.bean.BeanUtil;
import com.czg.BaseQueryParam;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.enums.DeleteEnum;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.market.dto.MkPointsGoodsDTO;
import com.czg.market.entity.MkPointsGoods;
@@ -62,7 +62,7 @@ public class PointsGoodsController {
dto.setShopId(StpKit.USER.getShopId());
if (dto.getCouponId() != null) {
ShopCoupon coupon = shopCouponService.getById(dto.getCouponId());
if (coupon == null || coupon.getIsDel() == DeleteEnum.DELETED.value() || coupon.getStatus() != 1) {
if (coupon == null || coupon.getIsDel() == SystemConstants.OneZero.ONE || coupon.getStatus() != 1) {
throw new CzgException("操作失败,优惠券已删除或未启用");
}
if ("custom".equals(coupon.getValidType())) {
@@ -88,7 +88,7 @@ public class PointsGoodsController {
@SaAdminCheckPermission(parentName = "积分相关", value = "points:goods:delete", name = "积分-商品-删除")
public CzgResult<Void> deletePointsGoodsSetting(@PathVariable("id") Long id) {
MkPointsGoods entity = pointsGoodsSettingService.getById(id);
entity.setDelFlag(DeleteEnum.DELETED.value());
entity.setDelFlag(SystemConstants.OneZero.ONE);
pointsGoodsSettingService.updateById(entity);
return CzgResult.success();
}

View File

@@ -1,28 +0,0 @@
package com.czg.enums;
/**
* 逻辑删除枚举
*
* @author tankaikai
* @since 2025-02-11 14:55
*/
public enum DeleteEnum {
/**
* 是(删除)
*/
DELETED(1),
/**
* 否(未删除)
*/
NORMAL(0);
private int value;
DeleteEnum(int value) {
this.value = value;
}
public int value() {
return this.value;
}
}

View File

@@ -6,7 +6,6 @@ import com.czg.account.dto.PictureClassifyDTO;
import com.czg.account.entity.PictureClassify;
import com.czg.account.service.PictureClassifyService;
import com.czg.constants.SystemConstants;
import com.czg.enums.DeleteEnum;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import com.czg.service.account.mapper.PictureClassifyMapper;
@@ -40,7 +39,7 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
q2.eq(PictureClassify::getIsSystem, SystemConstants.OneZero.ONE);
});
});
queryWrapper.eq(PictureClassify::getIsDel, DeleteEnum.NORMAL.value());
queryWrapper.eq(PictureClassify::getIsDel, SystemConstants.OneZero.ONE);
queryWrapper.orderBy(PictureClassify::getSort, true);
queryWrapper.orderBy(PictureClassify::getId, false);
return queryWrapper;
@@ -101,7 +100,7 @@ public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMappe
checkPictureClassify(id);
Long shopId = StpKit.USER.getShopId(0L);
UpdateChain.of(PictureClassify.class)
.set(PictureClassify::getIsDel, DeleteEnum.DELETED.value())
.set(PictureClassify::getIsDel, SystemConstants.OneZero.ONE)
.eq(PictureClassify::getShopId, shopId)
.eq(PictureClassify::getId, id)
.update();

View File

@@ -6,7 +6,7 @@ import com.czg.account.dto.PictureGalleryDTO;
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.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import com.czg.service.account.mapper.PictureGalleryMapper;
@@ -41,7 +41,7 @@ public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper,
q1.eq(PictureGallery::getShopId, 1L);
});
});
queryWrapper.eq(PictureGallery::getIsDel, DeleteEnum.NORMAL.value());
queryWrapper.eq(PictureGallery::getIsDel, SystemConstants.OneZero.ZERO);
queryWrapper.orderBy(PictureGallery::getId, false);
return queryWrapper;
}
@@ -73,7 +73,7 @@ public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper,
throw new CzgException("公共图片不可操作");
}
UpdateChain.of(PictureGallery.class)
.set(PictureGallery::getIsDel, DeleteEnum.DELETED.value())
.set(PictureGallery::getIsDel, SystemConstants.OneZero.ONE)
.eq(PictureGallery::getShopId, shopId)
.eq(PictureGallery::getId, id)
.update();

View File

@@ -5,7 +5,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.enums.DeleteEnum;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.order.dto.CreditBuyerDTO;
import com.czg.order.dto.CreditBuyerOrderDTO;
@@ -149,11 +149,11 @@ public class CreditBuyerOrderServiceImpl extends ServiceImpl<CreditBuyerOrderMap
throw new CzgException("挂账人不存在");
}
Integer delFlag = creditBuyer.getIsDel();
if (delFlag != null && delFlag == DeleteEnum.DELETED.value()) {
if (delFlag != null && delFlag == SystemConstants.OneZero.ONE) {
throw new CzgException("挂账人已删除");
}
Integer status = creditBuyer.getStatus();
if (status != null && status == DeleteEnum.NORMAL.value()) {
if (status != null && status == SystemConstants.OneZero.ZERO) {
throw new CzgException("挂账人已被停用");
}
OrderInfo orderInfo = orderInfoMapper.selectOneById(orderId);

View File

@@ -8,7 +8,7 @@ import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.enums.DeleteEnum;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.order.dto.CreditBuyerDTO;
import com.czg.order.dto.CreditBuyerOrderDTO;
@@ -142,7 +142,7 @@ public class CreditBuyerServiceImpl extends ServiceImpl<CreditBuyerMapper, Credi
public void deleteCreditBuyer(String id) {
Long shopId = StpKit.USER.getShopId(0L);
UpdateChain.of(CreditBuyer.class)
.set(CreditBuyer::getIsDel, DeleteEnum.DELETED.value())
.set(CreditBuyer::getIsDel, SystemConstants.OneZero.ONE)
.eq(CreditBuyer::getId, id)
.eq(CreditBuyer::getShopId, shopId)
.update();
@@ -165,7 +165,7 @@ public class CreditBuyerServiceImpl extends ServiceImpl<CreditBuyerMapper, Credi
throw new CzgException("挂账人不存在");
}
Integer isDel = dto.getIsDel();
if (isDel == DeleteEnum.DELETED.value()) {
if (isDel == SystemConstants.OneZero.ONE) {
throw new CzgException("挂账人已删除");
}
if (!"total".equals(dto.getRepaymentMethod())) {

View File

@@ -9,7 +9,6 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import com.czg.constant.CacheConstant;
import com.czg.constants.SystemConstants;
import com.czg.enums.DeleteEnum;
import com.czg.exception.CzgException;
import com.czg.product.dto.ProdConsRelationDTO;
import com.czg.product.dto.ProdSkuDTO;
@@ -117,7 +116,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
param.setShopId(shopId);
}
queryWrapper.eq(Product::getShopId, param.getShopId());
queryWrapper.eq(Product::getIsDel, DeleteEnum.NORMAL.value());
queryWrapper.eq(Product::getIsDel, SystemConstants.OneZero.ZERO);
queryWrapper.orderBy(Product::getIsSoldStock, true);
queryWrapper.orderBy(Product::getIsSale, false);
queryWrapper.orderBy(Product::getSort, false);
@@ -141,7 +140,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
private void buildProductExtInfo(List<ProductDTO> records) {
records.forEach(record -> {
record.setIsSaleTime(calcIsSaleTime(record.getDays(), record.getStartTime(), record.getEndTime()));
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, record.getId()).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, record.getId()).eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO), ProdSkuDTO.class);
if (CollUtil.isNotEmpty(skuList)) {
Optional<BigDecimal> lowPriceIsPresent = skuList.stream().map(obj -> NumberUtil.nullToZero(obj.getSalePrice())).min(BigDecimal::compareTo);
lowPriceIsPresent.ifPresent(record::setLowPrice);
@@ -307,7 +306,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
if (dto == null) {
return null;
}
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, id).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, id).eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO), ProdSkuDTO.class);
dto.setSkuList(skuList);
List<ProdConsRelationDTO> consList = prodConsRelationMapper.selectListByProdId(dto.getId());
dto.setConsList(consList);
@@ -319,7 +318,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@CacheEvict(value = {CacheConstant.USER_CLIENT_HOTS_PRODUCT, CacheConstant.USER_CLIENT_GROUPS_PRODUCT}, key = "#dto.shopId", allEntries = true)
public void addProduct(ProductDTO dto) {
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId).eq(Product::getIsDel, DeleteEnum.NORMAL.value()));
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId).eq(Product::getIsDel, SystemConstants.OneZero.ZERO));
if (exists) {
throw new CzgException("名称已存在");
}
@@ -335,7 +334,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
entity.setGroupSnap(groupSnap);
}
}
entity.setIsDel(DeleteEnum.NORMAL.value());
entity.setIsDel(SystemConstants.OneZero.ZERO);
entity.setShopId(shopId);
super.save(entity);
dto.setId(entity.getId());
@@ -351,7 +350,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
prodSku.setRealSalesNumber(BigDecimal.ZERO);
prodSku.setIsPauseSale(SystemConstants.OneZero.ZERO);
prodSku.setIsGrounding(SystemConstants.OneZero.ONE);
prodSku.setIsDel(DeleteEnum.NORMAL.value());
prodSku.setIsDel(SystemConstants.OneZero.ZERO);
prodSkuList.add(prodSku);
}
prodSkuMapper.insertBatch(prodSkuList);
@@ -382,7 +381,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
public void updateProduct(ProductDTO dto) {
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId).eq(Product::getIsDel, DeleteEnum.NORMAL.value()).ne(Product::getId, dto.getId()));
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId).eq(Product::getIsDel, SystemConstants.OneZero.ZERO).ne(Product::getId, dto.getId()));
if (exists) {
throw new CzgException("名称已存在");
}
@@ -400,7 +399,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
entity.setGroupSnap(JSON.toJSONString(dto.getProGroupVo(), JSONWriter.Feature.WriteMapNullValue));
}
}
entity.setIsDel(DeleteEnum.NORMAL.value());
entity.setIsDel(SystemConstants.OneZero.ZERO);
entity.setShopId(shopId);
if (!ProductTypeEnum.SKU.value().equals(entity.getType())) {
UpdateChain.of(Product.class).set(Product::getSpecId, null).eq(Product::getId, dto.getId()).update();
@@ -432,7 +431,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
prodSku.setRealSalesNumber(BigDecimal.ZERO);
prodSku.setIsPauseSale(SystemConstants.OneZero.ZERO);
prodSku.setIsGrounding(SystemConstants.OneZero.ONE);
prodSku.setIsDel(DeleteEnum.NORMAL.value());
prodSku.setIsDel(SystemConstants.OneZero.ZERO);
prodSkuMapper.insert(prodSku);
} else {
prodSkuMapper.update(prodSku);
@@ -445,7 +444,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
if (CollUtil.isNotEmpty(skuIdList)) {
// 逻辑删除无用的SKU数据
UpdateChain.of(ProdSku.class)
.set(ProdSku::getIsDel, DeleteEnum.DELETED.value())
.set(ProdSku::getIsDel, SystemConstants.OneZero.ONE)
.in(ProdSku::getId, skuIdList)
.eq(ProdSku::getShopId, shopId)
.update();
@@ -537,7 +536,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
Product old = getById(id);
Long categoryId = old.getCategoryId();
UpdateChain.of(Product.class)
.set(Product::getIsDel, DeleteEnum.DELETED.value())
.set(Product::getIsDel, SystemConstants.OneZero.ONE)
.eq(Product::getId, id)
.eq(Product::getShopId, shopId)
.update();
@@ -572,7 +571,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
long normalCount = prodSkuMapper.selectCountByQuery(QueryWrapper.create()
.eq(ProdSku::getProductId, prodSku.getProductId())
.eq(ProdSku::getIsGrounding, SystemConstants.OneZero.ZERO)
.eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value())
.eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO)
);
if (normalCount == 0) {
UpdateChain.of(Product.class)
@@ -626,7 +625,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
long normalCount = prodSkuMapper.selectCountByQuery(QueryWrapper.create()
.eq(ProdSku::getProductId, prodSku.getProductId())
.eq(ProdSku::getIsPauseSale, SystemConstants.OneZero.ZERO)
.eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value())
.eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO)
);
if (normalCount == 0) {
UpdateChain.of(Product.class)

View File

@@ -3,7 +3,7 @@ package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.enums.DeleteEnum;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.product.dto.ShopVendorBillPayDTO;
import com.czg.product.dto.ShopVendorDTO;
@@ -56,7 +56,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
}
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ShopVendor::getShopId, shopId);
queryWrapper.eq(ShopVendor::getIsDel, DeleteEnum.NORMAL.value());
queryWrapper.eq(ShopVendor::getIsDel, SystemConstants.OneZero.ZERO);
queryWrapper.orderBy(ShopVendor::getSort, true);
queryWrapper.orderBy(ShopVendor::getId, false);
return queryWrapper;
@@ -88,7 +88,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
throw new CzgException("供应商已存在");
}
ShopVendor entity = BeanUtil.copyProperties(dto, ShopVendor.class);
entity.setIsDel(DeleteEnum.NORMAL.value());
entity.setIsDel(SystemConstants.OneZero.ZERO);
entity.setShopId(shopId);
super.save(entity);
dto.setId(entity.getId());
@@ -110,7 +110,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
public void deleteShopVendor(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
UpdateChain.of(ShopVendor.class)
.set(ShopVendor::getIsDel, DeleteEnum.DELETED.value())
.set(ShopVendor::getIsDel, SystemConstants.OneZero.ONE)
.eq(ShopVendor::getId, id)
.eq(ShopVendor::getShopId, shopId)
.update();

View File

@@ -8,7 +8,6 @@ import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.constant.CacheConstant;
import com.czg.constants.SystemConstants;
import com.czg.enums.DeleteEnum;
import com.czg.enums.StatusEnum;
import com.czg.exception.CzgException;
import com.czg.product.dto.ProdGroupRelationDTO;
@@ -67,7 +66,7 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query()
.eq(ProdSku::getProductId, item.getId())
.eq(ProdSku::getIsGrounding, SystemConstants.OneZero.ONE)
.eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
.eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO), ProdSkuDTO.class);
item.setSkuList(skuList);
});
return list;
@@ -85,7 +84,7 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query()
.eq(ProdSku::getProductId, item.getId())
.eq(ProdSku::getIsGrounding, SystemConstants.OneZero.ONE)
.eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
.eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO), ProdSkuDTO.class);
item.setSkuList(skuList);
});
Map<Long, ShopProductVo> productKv = productAllList.stream().collect(Collectors.toMap(ShopProductVo::getId, shopProductVo -> shopProductVo));
@@ -146,7 +145,7 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
ShopProductSkuInfoVo data = prodSkuMapper.selectOneByQueryAs(
query().eq(ProdSku::getProductId, param.getId())
.eq(ProdSku::getShopId, shopId)
.eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value())
.eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO)
.eq(ProdSku::getIsGrounding, SystemConstants.OneZero.ONE)
.eq(ProdSku::getSpecInfo, specInfo)
, ShopProductSkuInfoVo.class);