From 8baef699b083277bda71a36fa45ef2a67ec7c2ae Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Tue, 31 Dec 2024 10:37:32 +0800
Subject: [PATCH] refactor(mall): 优化商品查询并添加新枚举类 - 使用 LambdaQueryWrapper 优化商品查询,提高代码可读性 - 添加 YesOrNoOrIngEnum 枚举类,用于表示成功、失败和进行中的状态 - 移除无用的用户等级验证代码

---
 src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java       |    9 ++++++---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java |    5 -----
 src/main/java/cc/mrbird/febs/common/enumerates/YesOrNoOrIngEnum.java            |   26 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/common/enumerates/YesOrNoOrIngEnum.java b/src/main/java/cc/mrbird/febs/common/enumerates/YesOrNoOrIngEnum.java
new file mode 100644
index 0000000..3b5ea6a
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/common/enumerates/YesOrNoOrIngEnum.java
@@ -0,0 +1,26 @@
+package cc.mrbird.febs.common.enumerates;
+
+import lombok.Getter;
+
+@Getter
+public enum YesOrNoOrIngEnum {
+
+    /**
+     *
+     */
+    YES(1, "成功、是"),
+
+    NO(0, "失败、否"),
+
+    ING(2, "进行中、运行中");
+
+    private final int value;
+
+    private final String desc;
+
+    YesOrNoOrIngEnum(int value, String desc) {
+        this.value = value;
+        this.desc = desc;
+    }
+
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
index 10cd251..66b9a5d 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
@@ -13,6 +13,7 @@
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -1008,9 +1009,11 @@
 
     @Override
     public List<AdminMallGoodsCouponTreeListVo> findAdminMallGoodsVoTreeList() {
-        QueryWrapper<MallGoods> objectQueryWrapper = new QueryWrapper<>();
-        objectQueryWrapper.eq("is_sale",1);
-        List<MallGoods> mallGoodsList = mallGoodsMapper.selectList(objectQueryWrapper);
+        List<MallGoods> mallGoodsList = mallGoodsMapper.selectList(
+                new LambdaQueryWrapper<MallGoods>()
+                        .select(MallGoods::getId, MallGoods::getGoodsName)
+                        .eq(MallGoods::getIsSale, MallGoods.ISSALE_STATUS_ENABLE)
+        );
 
         List<AdminMallGoodsCouponTreeListVo> objects = new ArrayList<>();
         if(CollUtil.isNotEmpty(mallGoodsList)){
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
index a29f344..eae26db 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -93,11 +93,6 @@
         Long memberId = LoginUserUtil.getLoginUser().getId();
         MallMember member = mallMemberMapper.selectById(memberId);
 
-                //验证用户的等级
-//        if(AgentLevelEnum.ZERO_LEVEL.name().equals(member.getLevel())){
-//            throw new FebsException("请先申请成为代理人");
-//        }
-
         //订单范围内才允许下单
         MallAddressInfo address = mallAddressInfoMapper.selectAddressInfoByMemberIdAndId(member.getId(), addOrderDto.getAddressId());
         if(ObjectUtil.isEmpty(address)){

--
Gitblit v1.9.1