Преглед изворни кода

商品列表,上架,下架,详情查询

杨德宝 пре 2 година
родитељ
комит
806d5de53f

+ 36 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/dto/admin/shopGood/DownShelfDTO.java

@@ -0,0 +1,36 @@
+package com.kxs.product.api.dto.admin.shopGood;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+
+/**
+ * 商城管理-商品下架-dto
+ *
+ * @author 系统
+ * @date 2024-07-09 11:54:33
+ */
+@Data
+public class DownShelfDTO {
+
+    /**
+     * 主键ID
+     */
+    @Schema(description = "主键ID")
+    private Integer id;
+
+
+    /**
+     * 下架时间
+     */
+    @Schema(description = "下架时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime downTime;
+
+
+
+
+}

+ 102 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/dto/admin/shopGood/SysShopGoodsAddDTO.java

@@ -0,0 +1,102 @@
+package com.kxs.product.api.dto.admin.shopGood;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 商品新增参数
+ * @author debao.yang
+ * @createTime 2024-07-09 14:12
+ */
+@Data
+public class SysShopGoodsAddDTO {
+
+
+    /**
+     * 封面图
+     */
+    @Schema(description = "封面图")
+    private String picUrl;
+
+
+    /**
+     * 商品名称
+     */
+    @Schema(description = "商品名称")
+    private String goodsName;
+
+
+    /**
+     * 价格
+     */
+    @Schema(description = "价格")
+    private BigDecimal price;
+
+
+    /**
+     * 子标题
+     */
+    @Schema(description = "子标题")
+    private String subtitle;
+
+    /**
+     * 详情
+     */
+    @Schema(description = "详情")
+    private String details;
+
+    /**
+     * sku属性详情
+     */
+    @Schema(description = "sku属性详情")
+    private String specList;
+
+
+    /**
+     * 状态 0下架 1上架
+     */
+    @Schema(description = "状态 0下架 1上架")
+    private Integer status;
+
+
+    /**
+     * 分类ID
+     */
+    @Schema(description = "分类ID")
+    private String colId;
+
+
+    /**
+     * 限购数量
+     */
+    @Schema(description = "限购数量")
+    private Integer limitCount;
+
+
+    /**
+     * 起购数量
+     */
+    @Schema(description = "起购数量")
+    private Integer startByCount;
+
+    /**
+     * 排序
+     */
+    @Schema(description = "排序")
+    private Integer sort;
+
+
+    /**
+     * 商品类型 0实物商品 1虚拟物品
+     */
+    @Schema(description = "商品类型 0实物商品 1虚拟物品")
+    private Integer goodsType;
+
+}

+ 12 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/dto/admin/shopGood/SysShopGoodsPageDTO.java

@@ -0,0 +1,12 @@
+package com.kxs.product.api.dto.admin.shopGood;
+
+import lombok.Data;
+
+/**
+ * 商品搜索参数
+ * @author debao.yang
+ * @createTime 2024-07-09 13:47
+ */
+@Data
+public class SysShopGoodsPageDTO {
+}

+ 36 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/dto/admin/shopGood/UpShelfDTO.java

@@ -0,0 +1,36 @@
+package com.kxs.product.api.dto.admin.shopGood;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+
+/**
+ * 商城管理-商品上架-dto
+ *
+ * @author 系统
+ * @date 2024-07-09 11:54:33
+ */
+@Data
+public class UpShelfDTO {
+
+    /**
+     * 主键ID
+     */
+    @Schema(description = "主键ID")
+    private Integer id;
+
+
+    /**
+     * 上架时间
+     */
+    @Schema(description = "上架时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime upTime;
+
+
+
+
+}

+ 28 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/vo/admin/shopGoods/SysShopGoodsPageVO.java

@@ -0,0 +1,28 @@
+package com.kxs.product.api.vo.admin.shopGoods;
+
+
+import com.kxs.product.api.model.KxsShopGoods;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 商城管理-商品列表vo
+ *
+ * @author 系统
+ * @date 2024-07-09 11:54:33
+ */
+@Data
+@Schema(description = "商城管理-商品列表返回实体")
+public class SysShopGoodsPageVO extends KxsShopGoods implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+
+
+	
+
+}

+ 29 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/constant/enums/GoodsStatusEnum.java

@@ -0,0 +1,29 @@
+package com.kxs.product.biz.constant.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 商品状态
+ * @author debao.yang
+ * @createTime 2024-07-09 14:55
+ */
+@Getter
+@AllArgsConstructor
+public enum GoodsStatusEnum {
+
+
+    UP_SHELF(1,"上架"),
+    DOWN_SHELF(0,"下架");
+
+
+    /**
+     * 类型
+     */
+    private final Integer type;
+
+    /**
+     * 描述
+     */
+    private final String description;
+}

+ 108 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/controller/admin/SysShopGoodsController.java

@@ -0,0 +1,108 @@
+package com.kxs.product.biz.controller.admin;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.kxs.common.core.util.R;
+import com.kxs.product.api.dto.admin.shopGood.DownShelfDTO;
+import com.kxs.product.api.dto.admin.shopGood.SysShopGoodsAddDTO;
+import com.kxs.product.api.dto.admin.shopGood.SysShopGoodsPageDTO;
+import com.kxs.product.api.dto.admin.shopGood.UpShelfDTO;
+import com.kxs.product.api.vo.admin.shopGoods.SysShopGoodsPageVO;
+import com.kxs.product.biz.service.KxsShopGoodsService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 商城管理(SysShopGood)控制层
+ *
+ * @author 系统
+ * @since 2024-07-09 11:54:33
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("sysShopGoods")
+public class SysShopGoodsController {
+
+    /**
+     * 服务对象
+     */
+    private final KxsShopGoodsService kxsShopGoodsService;
+
+
+
+    /**
+     * 商城管理-商品列表
+     *
+     * @param page 分页对象
+     * @param param 查询实体
+     * @return 商城管理-商品列表
+     */
+    @GetMapping("/page")
+    public R page(Page<SysShopGoodsPageVO> page, SysShopGoodsPageDTO param) {
+        kxsShopGoodsService.shopGoodsPage(page, param);
+        return R.ok(page);
+    }
+
+
+    /**
+     * 商城管理-商品新增
+     *
+     * @param param 实体对象
+     * @return 商城管理-商品新增
+     */
+    @PostMapping("/add")
+    public R shopGoodAdd(@RequestBody SysShopGoodsAddDTO param) {
+        kxsShopGoodsService.shopGoodsAdd(param);
+        return R.ok();
+    }
+
+
+    /**
+     * 商城管理-商品上架
+     *
+     * @param param 实体对象
+     * @return 商城管理-商品上架
+     */
+    @PutMapping("/upShelf")
+    public R upShelf(@RequestBody UpShelfDTO param) {
+        kxsShopGoodsService.upShelf(param);
+        return R.ok();
+    }
+
+
+    /**
+     * 商城管理-商品下架
+     *
+     * @param param 实体对象
+     * @return 商城管理-商品下架
+     */
+    @PutMapping("/downShelf")
+    public R downShelf(@RequestBody DownShelfDTO param) {
+        kxsShopGoodsService.downShelf(param);
+        return R.ok();
+    }
+
+
+    /**
+     * 商城管理-商品详情
+     *
+     * @param id 主键ID
+     * @return 商城管理-商品详情
+     */
+    @GetMapping("/{id}")
+    public R shopGoodsDetail(@PathVariable("id") Integer id) {
+        return R.ok(kxsShopGoodsService.getById(id));
+    }
+
+
+
+
+
+
+}
+

+ 13 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/mapper/KxsShopGoodsMapper.java

@@ -3,11 +3,15 @@ package com.kxs.product.biz.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.kxs.product.api.dto.admin.shopGood.SysShopGoodsPageDTO;
 import com.kxs.product.api.model.KxsShopGoods;
+import com.kxs.product.api.vo.admin.shopGoods.SysShopGoodsPageVO;
 import com.kxs.product.api.vo.kxsapp.shop.ShopGoodsListVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 商城商品表(KxsShopGoods)表数据库访问层
  *
@@ -25,5 +29,14 @@ public interface KxsShopGoodsMapper extends BaseMapper<KxsShopGoods> {
      * @return {@link IPage}<{@link ShopGoodsListVO}>
      */
     IPage<ShopGoodsListVO> getByPage(Page<ShopGoodsListVO> page, @Param("colId") Integer colId);
+
+
+    /**
+     * 分页查询商品列表
+     * @param page
+     * @param param
+     * @return
+     */
+    List<SysShopGoodsPageVO> shopGoodsPage(Page page, @Param("query") SysShopGoodsPageDTO param);
 }
 

+ 36 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/KxsShopGoodsService.java

@@ -3,10 +3,17 @@ package com.kxs.product.biz.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.kxs.product.api.dto.admin.shopGood.DownShelfDTO;
+import com.kxs.product.api.dto.admin.shopGood.SysShopGoodsAddDTO;
+import com.kxs.product.api.dto.admin.shopGood.SysShopGoodsPageDTO;
+import com.kxs.product.api.dto.admin.shopGood.UpShelfDTO;
 import com.kxs.product.api.model.KxsShopGoods;
+import com.kxs.product.api.vo.admin.shopGoods.SysShopGoodsPageVO;
 import com.kxs.product.api.vo.kxsapp.shop.ShopGoodsDetailVO;
 import com.kxs.product.api.vo.kxsapp.shop.ShopGoodsListVO;
 
+import java.util.List;
+
 /**
  * 商城商品表(KxsShopGoods)表服务接口
  *
@@ -31,5 +38,34 @@ public interface KxsShopGoodsService extends IService<KxsShopGoods> {
      * @return {@link ShopGoodsDetailVO}
      */
     ShopGoodsDetailVO getByGoodsDetail(Integer id);
+
+
+    /**
+     * 商品分页查询
+     * @param page
+     * @param param
+     * @return
+     */
+    List<SysShopGoodsPageVO> shopGoodsPage(Page page, SysShopGoodsPageDTO param);
+
+
+    /**
+     * 商品新增
+     * @param param
+     */
+    void shopGoodsAdd(SysShopGoodsAddDTO param);
+
+
+    /**
+     * 商品上架
+     * @param upShelfDTO
+     */
+    void upShelf(UpShelfDTO upShelfDTO);
+
+    /**
+     * 商品
+     * @param downShelfDTO
+     */
+    void downShelf(DownShelfDTO downShelfDTO);
 }
 

+ 41 - 5
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/impl/KxsShopGoodsServiceImpl.java

@@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.kxs.product.api.dto.admin.shopGood.DownShelfDTO;
+import com.kxs.product.api.dto.admin.shopGood.SysShopGoodsAddDTO;
+import com.kxs.product.api.dto.admin.shopGood.SysShopGoodsPageDTO;
+import com.kxs.product.api.dto.admin.shopGood.UpShelfDTO;
 import com.kxs.product.api.model.KxsShopGoodsPic;
-import com.kxs.product.api.model.KxsShopGoodsSku;
+import com.kxs.product.api.vo.admin.shopGoods.SysShopGoodsPageVO;
 import com.kxs.product.api.vo.kxsapp.shop.ShopGoodsDetailVO;
 import com.kxs.product.api.vo.kxsapp.shop.ShopGoodsListVO;
 import com.kxs.product.api.vo.kxsapp.shop.ShopGoodsSkuVO;
 import com.kxs.product.api.vo.kxsapp.shop.ShopGoodsSpecVO;
+import com.kxs.product.biz.constant.enums.GoodsStatusEnum;
 import com.kxs.product.biz.mapper.KxsShopGoodsMapper;
 import com.kxs.product.api.model.KxsShopGoods;
 import com.kxs.product.biz.mapper.KxsShopGoodsPicMapper;
@@ -17,6 +22,7 @@ import com.kxs.product.biz.mapper.KxsShopGoodsSkuMapper;
 import com.kxs.product.biz.mapper.KxsShopGoodsSpecMapper;
 import com.kxs.product.biz.service.KxsShopGoodsService;
 import lombok.RequiredArgsConstructor;
+import org.checkerframework.checker.units.qual.K;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
@@ -74,14 +80,44 @@ public class KxsShopGoodsServiceImpl extends ServiceImpl<KxsShopGoodsMapper, Kxs
         return goodsDetailVO;
     }
 
+    @Override
+    public List<SysShopGoodsPageVO> shopGoodsPage(Page page, SysShopGoodsPageDTO param) {
+        List<SysShopGoodsPageVO> list = baseMapper.shopGoodsPage(page, param);
+        if(page != null){
+            page.setRecords(list);
+        }
+        return list;
+    }
 
+    @Override
+    public void shopGoodsAdd(SysShopGoodsAddDTO param) {
+        KxsShopGoods kxsShopGoods = new KxsShopGoods();
+        BeanUtils.copyProperties(param,kxsShopGoods);
+        this.save(kxsShopGoods);
+    }
 
+    @Override
+    public void upShelf(UpShelfDTO upShelfDTO) {
+        Integer id = upShelfDTO.getId();
+        KxsShopGoods shopGoods = this.getById(id);
+        if(shopGoods != null){
+            shopGoods.setUpTime(upShelfDTO.getUpTime());
+            shopGoods.setStatus(GoodsStatusEnum.UP_SHELF.getType());
+        }
+        this.updateById(shopGoods);
 
+    }
 
-
-
-
-
+    @Override
+    public void downShelf(DownShelfDTO downShelfDTO) {
+        Integer id = downShelfDTO.getId();
+        KxsShopGoods shopGoods = this.getById(id);
+        if(shopGoods != null){
+            shopGoods.setDownTime(downShelfDTO.getDownTime());
+            shopGoods.setStatus(GoodsStatusEnum.DOWN_SHELF.getType());
+        }
+        this.updateById(shopGoods);
+    }
 
 
 }

+ 14 - 0
kxs-product/kxs-product-biz/src/main/resources/mapper/KxsShopGoodsMapper.xml

@@ -24,6 +24,10 @@
 
     </resultMap>
 
+    <resultMap id="WebKxsShopGoodsMap" type="com.kxs.product.api.vo.admin.shopGoods.SysShopGoodsPageVO" extends="KxsShopGoodsMap">
+
+    </resultMap>
+
     <select id="getByPage" resultType="com.kxs.product.api.vo.kxsapp.shop.ShopGoodsListVO">
         select * from kxs_shop_goods a
         <where>
@@ -35,4 +39,14 @@
         </where>
     </select>
 
+    <select id="shopGoodsPage" resultMap="WebKxsShopGoodsMap">
+        SELECT
+            *
+        FROM
+            kxs_shop_goods ksg
+        <where>
+            and ksg.del_flag = 0
+        </where>
+    </select>
+
 </mapper>