‘linchangsheng’ hace 1 semana
padre
commit
26e517a92e

+ 57 - 0
src/main/java/com/gree/mall/contest/bean/goods/GoodsVO.java

@@ -0,0 +1,57 @@
+package com.gree.mall.contest.bean.goods;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.gree.mall.contest.annotation.ZfireField;
+import com.gree.mall.contest.enums.GoodsStatusEnum;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class GoodsVO {
+
+    @ZfireField(hide = true)
+    private String goodsId;
+
+    @ZfireField(hide = true)
+    @Schema(description = "商品类型: COMMON=普通商品  PACKAGE=套购商品")
+    private String goodsType;
+
+    @Schema(description = "商品名称")
+    private String goodsName;
+
+    @Schema(description = "商品图片")
+    private String imgUrl;
+
+    @ZfireField(hide = true)
+    @Schema(description = "商品分类id")
+    private String categoryId;
+
+    @Schema(description = "商品大类")
+    private String categoryPname;
+
+    @Schema(description = "商品小类")
+    private String categoryName;
+
+    @ZfireField(hide = true)
+    @Schema(description = "大类id")
+    private String categoryPid;
+
+
+
+    @Schema(description = "划线价格")
+    private BigDecimal orgGoodsPrice;
+
+    @Schema(description = "商品价格")
+    private BigDecimal goodsPrice;
+
+
+    @Schema(description = "商品状态 true:上架  false:下架")
+    private GoodsStatusEnum status;
+
+    @Schema(description = "排序")
+    private Integer sortNum;
+
+}

+ 3 - 0
src/main/java/com/gree/mall/contest/commonmapper/CustomGoodsMapper.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.contest.bean.goods.GoodsPackageList;
 import com.gree.mall.contest.bean.goods.GoodsSpecBean;
 import com.gree.mall.contest.bean.goods.GoodsTypeCount;
+import com.gree.mall.contest.bean.goods.GoodsVO;
+import com.gree.mall.contest.bean.zfire.ZfireParamBean;
 import com.gree.mall.contest.plus.entity.Goods;
 import com.gree.mall.contest.plus.entity.GoodsCategory;
 import org.apache.ibatis.annotations.Param;
@@ -102,4 +104,5 @@ public interface CustomGoodsMapper {
                                                   @Param("status") Boolean status,
                                                   @Param("companyWechatIds")List<String> companyWechatIds);
 
+    IPage<GoodsVO> goodsList(Page page, @Param("ex") ZfireParamBean zfireParam);
 }

+ 0 - 1
src/main/java/com/gree/mall/contest/controller/pc/goods/GoodsCategoryController.java

@@ -36,7 +36,6 @@ public class GoodsCategoryController {
         return ResponseHelper.success(list);
     }
 
-
     @PostMapping("/add")
     @Operation(summary = "新增分类")
     public ResponseHelper add(

+ 31 - 0
src/main/java/com/gree/mall/contest/controller/pc/goods/GoodsController.java

@@ -1,12 +1,17 @@
 package com.gree.mall.contest.controller.pc.goods;
 
+import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.contest.annotation.ZfireList;
 import com.gree.mall.contest.bean.goods.*;
+import com.gree.mall.contest.bean.zfire.ZfireParamBean;
 import com.gree.mall.contest.exception.RemoteServiceException;
 import com.gree.mall.contest.helper.ResponseHelper;
 import com.gree.mall.contest.logic.goods.GoodsLogic;
 import com.gree.mall.contest.plus.entity.User;
 import com.gree.mall.contest.utils.excel.ExcelUtils;
+import com.gree.mall.contest.utils.zfire.FieldUtils;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -108,6 +113,32 @@ public class GoodsController {
     }
 
 
+    @ZfireList
+    @PostMapping("/list")
+    @Operation(summary = "商品列表V2")
+    public ResponseHelper<IPage<GoodsVO>> list(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) throws RemoteServiceException {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<GoodsVO> adminDeptVOIPage = goodsLogic.goodsList(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        return ResponseHelper.success(adminDeptVOIPage, new TypeReference<GoodsVO>() {});
+    }
+
+    @PostMapping("/list/export")
+    @Operation(summary = "商品列表V2导出")
+    public void listExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<GoodsVO> adminDeptVOIPage = goodsLogic.goodsList(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        //3.导出
+        FieldUtils.exportData(adminDeptVOIPage.getRecords(), zfireParam.getExportFields(), request, response);
+    }
+
+
+
 
     @GetMapping("/listbycategory")
     @Operation(summary = "商品详情")

+ 29 - 0
src/main/java/com/gree/mall/contest/enums/GoodsStatusEnum.java

@@ -0,0 +1,29 @@
+package com.gree.mall.contest.enums;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.baomidou.mybatisplus.annotation.IEnum;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import com.gree.mall.contest.enums.base.BaseEnum;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public enum GoodsStatusEnum implements BaseEnum, IEnum<Boolean> {
+    ONE("true", "上架"),
+    TWO("false", "下架"),
+    ;
+
+    @EnumValue
+    @JsonValue
+    private final String key;
+    private final String remark;
+
+
+    @Override
+    public Boolean getValue() {
+        return Boolean.parseBoolean(key);
+    }
+}

+ 12 - 0
src/main/java/com/gree/mall/contest/logic/goods/GoodsLogic.java

@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.contest.bean.ExcelData;
 import com.gree.mall.contest.bean.admin.AdminUserCom;
 import com.gree.mall.contest.bean.goods.*;
+import com.gree.mall.contest.bean.zfire.ZfireParamBean;
 import com.gree.mall.contest.commonmapper.CustomGoodsMapper;
 import com.gree.mall.contest.commonmapper.GoodsCheckMapper;
 import com.gree.mall.contest.constant.Constant;
@@ -24,6 +25,7 @@ import com.gree.mall.contest.logic.user.UserLogic;
 import com.gree.mall.contest.plus.entity.*;
 import com.gree.mall.contest.plus.service.*;
 import com.gree.mall.contest.utils.excel.ExcelUtils;
+import com.gree.mall.contest.utils.zfire.FieldUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringEscapeUtils;
@@ -189,6 +191,16 @@ public class GoodsLogic {
         return goodsSpecBeanIPage.getRecords();
     }
 
+    public IPage<GoodsVO> goodsList(Page page, ZfireParamBean zfireParam) {
+        //获取当前登录企业id
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        //1.组装查询条件
+        FieldUtils.supplyParam(zfireParam, GoodsVO.class,adminUser);
+
+        IPage<GoodsVO> goodsVOIPage = customGoodsMapper.goodsList(page, zfireParam);
+        return goodsVOIPage;
+    }
 
     /**
      * 商品上下架

+ 10 - 0
src/main/resources/mapper/CustomGoodsMapper.xml

@@ -211,6 +211,16 @@
         </choose>
 
     </select>
+    <select id="goodsList" resultType="com.gree.mall.contest.bean.goods.GoodsVO">
+        SELECT
+        ${ex.selected}
+        FROM goods a
+        ${ex.query}
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 
 
 </mapper>