gc-shop/src/main/java/com/xzx/gc/shop/controller/ApiGoodsController.java
New file @@ -0,0 +1,50 @@ package com.xzx.gc.shop.controller; import com.github.pagehelper.PageInfo; import com.xzx.gc.model.JsonResult; import com.xzx.gc.shop.dto.XcxGoodsListDto; import com.xzx.gc.shop.service.GoodsService; import com.xzx.gc.shop.vo.GoodsCategoryVo; import com.xzx.gc.shop.vo.XcxGoodsListVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.List; @RestController @Api(tags = {"积分商城--API商品管理"}) @Slf4j public class ApiGoodsController { @Autowired private GoodsService goodsService; @ApiOperation("分类列表") @ApiResponses( @ApiResponse(code = 200, message = "success", response = GoodsCategoryVo.class) ) @GetMapping(value = "/goods/goodsCategory") public JsonResult<List<GoodsCategoryVo>> goodsCategory() { return JsonResult.success(goodsService.findCategoryWithChildren()); } @ApiOperation("商品列表") @ApiResponses( @ApiResponse(code = 200, message = "success", response = XcxGoodsListVo.class) ) @PostMapping(value = "/goods/goodsList") public JsonResult<PageInfo<XcxGoodsListVo>> goodsList(@RequestBody XcxGoodsListDto xcxGoodsListDto, HttpServletRequest request) { return JsonResult.success(goodsService.findGoodsListInPage(xcxGoodsListDto)); } } gc-shop/src/main/java/com/xzx/gc/shop/dto/XcxGoodsListDto.java
New file @@ -0,0 +1,29 @@ package com.xzx.gc.shop.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "XcxGoodsListDto", description = "小程序商品列表参数接受类") public class XcxGoodsListDto { @ApiModelProperty(value = "名称搜索") private String name; @ApiModelProperty(value = "积分") private String score; @ApiModelProperty(value = "分类ID") private Long cateId; @ApiModelProperty(value="页码") private int pageNo=1; @ApiModelProperty(value="每页显示记录数") private int pageSize=10; } gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsCategoryMapper.java
@@ -2,6 +2,7 @@ import com.xzx.gc.entity.ScoreGoodsCategory; import com.xzx.gc.model.admin.GoodsCategoryModel; import com.xzx.gc.shop.vo.GoodsCategoryVo; import com.xzx.gc.shop.vo.QueryGoodsCategoryListVo; import com.xzx.gc.shop.vo.ViewGoodsCategoryListVo; import com.xzx.gc.util.GcMapper; @@ -11,6 +12,8 @@ public interface ScoreGoodsCategoryMapper extends GcMapper<ScoreGoodsCategory> { List<GoodsCategoryVo> selectCategoryWithChildren(); List<QueryGoodsCategoryListVo> queryGoodsCategoryList(@Param("record") GoodsCategoryModel goodsCategoryModel); List<ViewGoodsCategoryListVo> viewGoodsCategoryOneList(@Param("parentId")Long parentId); gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsMapper.java
@@ -1,7 +1,11 @@ package com.xzx.gc.shop.mapper; import com.github.pagehelper.PageInfo; import com.xzx.gc.entity.ScoreGoods; import com.xzx.gc.model.order.OrderInfoVo; import com.xzx.gc.shop.dto.XcxGoodsListDto; import com.xzx.gc.shop.vo.QueryGoodsListVo; import com.xzx.gc.shop.vo.XcxGoodsListVo; import com.xzx.gc.util.GcMapper; import org.apache.ibatis.annotations.Param; @@ -14,4 +18,6 @@ ScoreGoods selectById(long id); List<QueryGoodsListVo> queryGoodsList(@Param("name")String name, @Param("delFlag")int delFlag); List<XcxGoodsListVo> selectXcxGoodsList(@Param("record") XcxGoodsListDto xcxGoodsListDto); } gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
@@ -11,6 +11,7 @@ import com.xzx.gc.common.utils.MqUtil; import com.xzx.gc.entity.*; import com.xzx.gc.model.admin.GoodsCategoryModel; import com.xzx.gc.model.order.OrderInfoVo; import com.xzx.gc.shop.dto.*; import com.xzx.gc.shop.mapper.*; import com.xzx.gc.shop.vo.*; @@ -287,4 +288,16 @@ } return maps; } public List<GoodsCategoryVo> findCategoryWithChildren() { return scoreGoodsCategoryMapper.selectCategoryWithChildren(); } public PageInfo<XcxGoodsListVo> findGoodsListInPage(XcxGoodsListDto xcxGoodsListDto) { PageHelper.startPage(xcxGoodsListDto.getPageNo(), xcxGoodsListDto.getPageSize()); List<XcxGoodsListVo> data = scoreGoodsMapper.selectXcxGoodsList(xcxGoodsListDto); return new PageInfo<>(data); } } gc-shop/src/main/java/com/xzx/gc/shop/vo/GoodsCategoryVo.java
New file @@ -0,0 +1,21 @@ package com.xzx.gc.shop.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @Data @ApiModel(value = "GoodsCategoryVo", description = "小程序分类接口返回参数类") public class GoodsCategoryVo { @ApiModelProperty(value = "分类ID") private Long id; @ApiModelProperty(value = "分类名称") private String name; @ApiModelProperty(value = "子类") private List<GoodsCategoryVo> children; } gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailSkuVo.java
New file @@ -0,0 +1,34 @@ package com.xzx.gc.shop.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; /** * @author wzy * @date 2021-06-24 **/ @Data @ApiModel(value = "XcxGoodsDetailSkuVo", description = "小程序商品详情规格参数类") public class XcxGoodsDetailSkuVo { @ApiModelProperty(value = "规格ID") private Long id; @ApiModelProperty(value = "规格名称") private String name; @ApiModelProperty(value = "现价") private BigDecimal presentPrice; @ApiModelProperty(value = "原价") private BigDecimal originalPrice; @ApiModelProperty(value = "销量") private Integer quantity; @ApiModelProperty(value = "库存") private Integer stock; } gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailStyleVo.java
New file @@ -0,0 +1,21 @@ package com.xzx.gc.shop.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @Data @ApiModel(value = "XcxGoodsDetailStyleVo", description = "小程序商品详情样式参数类") public class XcxGoodsDetailStyleVo { @ApiModelProperty(value = "样式ID") private Long id; @ApiModelProperty(value = "样式名称") private String name; @ApiModelProperty(value = "规格") private List<XcxGoodsDetailSkuVo> skus; } gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailVo.java
New file @@ -0,0 +1,44 @@ package com.xzx.gc.shop.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; /** * @author wzy * @date 2021-06-24 **/ @Data @ApiModel(value = "XcxGoodsDetailVo", description = "小程序商品详情返回参数类") public class XcxGoodsDetailVo { @ApiModelProperty(value = "商品名称") private String name; @ApiModelProperty(value = "列表缩略图") private String image; @ApiModelProperty(value = "现价") private String presentPrice; @ApiModelProperty(value = "原价") private String originalPrice; @ApiModelProperty(value = "销量") private Integer quantity; @ApiModelProperty(value = "库存") private Integer stock; @ApiModelProperty(value = "商品详情") private String details; @ApiModelProperty(value = "轮播图") private List<String> images; @ApiModelProperty(value = "样式") private List<XcxGoodsDetailStyleVo> styles; } gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsListVo.java
New file @@ -0,0 +1,31 @@ package com.xzx.gc.shop.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "XcxGoodsListVo", description = "小程序商品列表返回参数类") public class XcxGoodsListVo { @ApiModelProperty(value = "商品ID") private Long id; @ApiModelProperty(value = "商品名称") private String name; @ApiModelProperty(value = "图片") private String image; @ApiModelProperty(value = "现价") private String presentPrice; @ApiModelProperty(value = "原价") private String originalPrice; @ApiModelProperty(value = "销量") private Integer quantity; @ApiModelProperty(value = "库存") private Integer stock; } gc-shop/src/main/resources/mapper/shop/ScoreGoodsCategoryMapper.xml
@@ -2,6 +2,21 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.xzx.gc.shop.mapper.ScoreGoodsCategoryMapper"> <resultMap id="goodsCategoryMap" type="com.xzx.gc.shop.vo.GoodsCategoryVo"> <id column="id" property="id" /> <result column="name" property="name" /> <collection property="children" ofType="com.xzx.gc.shop.vo.GoodsCategoryVo"> <id column="c_id" property="id" /> <result column="c_name" property="name" /> </collection> </resultMap> <select id="selectCategoryWithChildren" resultMap="goodsCategoryMap"> select a.id id, a.name name, b.id c_id, b.name c_name from xzx_score_goods_category a left join xzx_score_goods_category b on a.id=b.parent_id </select> <select id="queryGoodsCategoryList" resultType="com.xzx.gc.shop.vo.QueryGoodsCategoryListVo"> SELECT * gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml
@@ -35,4 +35,22 @@ where id=#{id} </update> <select id="selectXcxGoodsList" resultType="com.xzx.gc.shop.vo.XcxGoodsListVo"> select a.*, sum(b.quantity) quantity, sum(b.stock) stock from xzx_score_goods a inner join xzx_score_goods_sku b on a.id=b.goods_id and b.del_flag=0 <where> a.del_flag=0 <if test="record.name != null and record.name != ''"> and a.name like CONCAT(CONCAT(#{record.name}, "%"), "%") </if> <if test="record.cateId != null and record.cateId != ''"> and (a.category_id = #{record.cateId} or a.category in (select id from xzx_score_goods_category where parent_id=#{record.cateId})) </if> </where> order by a.CREATED_TIME desc </select> </mapper>