xiaoyong931011
2021-06-24 7a8413c07a44737e559cbc0369f9ff9687f22646
20210624 商品分类
2 files added
10 files modified
162 ■■■■ changed files
gc-core/src/main/java/com/xzx/gc/entity/ScoreGoods.java 7 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/controller/AdminGoodsCategoryController.java 12 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java 12 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/dto/QueryGoodsListDto.java 2 ●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/dto/ViewGoodsCategoryListDto.java 12 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsCategoryMapper.java 7 ●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsMapper.java 4 ●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java 19 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsCategoryListVo.java 31 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/resources/mapper/shop/ScoreGoodsCategoryMapper.xml 30 ●●●● patch | view | raw | blame | history
gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml 2 ●●● patch | view | raw | blame | history
gc-shop/src/main/resources/sql 24 ●●●●● patch | view | raw | blame | history
gc-core/src/main/java/com/xzx/gc/entity/ScoreGoods.java
@@ -2,6 +2,7 @@
import com.xzx.gc.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
@@ -26,6 +27,12 @@
    private String details;
    private String priceRange;
    private String categoryId;
    private String categoryName;
    /**
     * 是否抢购 1-是 2-否
     */
gc-shop/src/main/java/com/xzx/gc/shop/controller/AdminGoodsCategoryController.java
@@ -48,6 +48,18 @@
    }
    /**
     * 查询商品分类--所有一级分类
     * xzx_score_goods_category商品分类
     */
    @PostMapping(Constants.ADMIN_VIEW_PREFIX+"/score/goods/viewGoodsCategoryList.json")
    @ApiResponses({@ApiResponse( code = 200, message = "success", response = ViewGoodsCategoryListVo.class)})
    @ApiOperation(value = "商品分类管理--所有一级分类", notes = "test: 仅0有正确返回")
    public JsonResult<List<ViewGoodsCategoryListVo>> viewGoodsCategoryList(@RequestBody ViewGoodsCategoryListDto viewGoodsCategoryListDto) {
        List<ViewGoodsCategoryListVo> result = goodsService.viewGoodsCategoryList(viewGoodsCategoryListDto);
        return JsonResult.success(result);
    }
    /**
     * 添加商品分类
     */
    @PostMapping(Constants.ADMIN_VIEW_PREFIX+"/score/goods/addGoodsCategory.json")
gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java
@@ -32,6 +32,16 @@
    @ApiModelProperty(value="商品详情",required=true)
    private String details;
    @ApiModelProperty(value="积分范围",required=true)
    private String priceRange;
    @ApiModelProperty(value="商品分类ID",required=true)
    private String categoryId;
    @ApiModelProperty(value="商品分类名称",required=true)
    private String categoryName;
    /**
     * 是否抢购 1-是 2-否
     */
@@ -50,7 +60,7 @@
    @ApiModelProperty(value="碳排放量",required=true)
    private Integer carbonEmissions;
    @ApiModelProperty(value="积分商品轮播图")
    @ApiModelProperty(value="主图")
    private List<String> goodsImages;
    @ApiModelProperty(value="积分商品样式")
gc-shop/src/main/java/com/xzx/gc/shop/dto/QueryGoodsListDto.java
@@ -10,7 +10,7 @@
    @ApiModelProperty(value="名称",required=true)
    private String name;
    @ApiModelProperty(value="是否已删除 1:是 2:否",required=true)
    @ApiModelProperty(value="是否已删除 0:未删除 1:已删除 2全部")
    private Integer delFlag;
    @ApiModelProperty(value="第几页",required=true)
    private int page;
gc-shop/src/main/java/com/xzx/gc/shop/dto/ViewGoodsCategoryListDto.java
New file
@@ -0,0 +1,12 @@
package com.xzx.gc.shop.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ViewGoodsCategoryListDto {
    @ApiModelProperty(value="查询分类  一级:0  全部:1",required=true)
    private Long parentId;
}
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsCategoryMapper.java
@@ -3,12 +3,17 @@
import com.xzx.gc.entity.ScoreGoodsCategory;
import com.xzx.gc.model.admin.GoodsCategoryModel;
import com.xzx.gc.shop.vo.QueryGoodsCategoryListVo;
import com.xzx.gc.shop.vo.ViewGoodsCategoryListVo;
import com.xzx.gc.util.GcMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ScoreGoodsCategoryMapper extends GcMapper<ScoreGoodsCategory> {
    List<QueryGoodsCategoryListVo> queryGoodsCategoryList(GoodsCategoryModel goodsCategoryModel);
    List<QueryGoodsCategoryListVo> queryGoodsCategoryList(@Param("record") GoodsCategoryModel goodsCategoryModel);
    List<ViewGoodsCategoryListVo> viewGoodsCategoryOneList(@Param("parentId")Long parentId);
    List<ViewGoodsCategoryListVo> viewGoodsCategoryList();
}
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsMapper.java
@@ -9,9 +9,9 @@
public interface ScoreGoodsMapper extends GcMapper<ScoreGoods> {
    List<QueryGoodsListVo> queryGoodsList(ScoreGoods scoreGoods);
    void updateDelFlagById(@Param("id")long id, @Param("delFlag")Short toShort);
    ScoreGoods selectById(long id);
    List<QueryGoodsListVo> queryGoodsList(@Param("name")String name, @Param("delFlag")int delFlag);
}
gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
@@ -96,14 +96,11 @@
    }
    public Map<String, Object> queryGoodsList(QueryGoodsListDto model) {
        String name = model.getName();
        int delFlag = model.getDelFlag();
        ScoreGoods scoreGoods = new ScoreGoods();
        scoreGoods.setName(name);
        scoreGoods.setDelFlag(Convert.toShort(delFlag));
        String name = model.getName() == null ? "":model.getName();
        int delFlag = model.getDelFlag() == null ? 2:model.getDelFlag();
        PageHelper.startPage(model.getPage(), model.getLimit());
        List<QueryGoodsListVo> maps = scoreGoodsMapper.queryGoodsList(scoreGoods);
        List<QueryGoodsListVo> maps = scoreGoodsMapper.queryGoodsList(name,delFlag);
        PageInfo pageInfo = new PageInfo(maps);
        int count = Convert.toInt(pageInfo.getTotal());
        Map<String, Object> map = new HashMap<>();
@@ -280,4 +277,14 @@
            scoreGoodsMapper.updateByExampleSelective(scoreGoods,exampleGoods);
        }
    }
    public List<ViewGoodsCategoryListVo> viewGoodsCategoryList(ViewGoodsCategoryListDto viewGoodsCategoryListDto) {
        List<ViewGoodsCategoryListVo> maps = new ArrayList<>();
        if(viewGoodsCategoryListDto.getParentId() == 0L){
            maps = scoreGoodsCategoryMapper.viewGoodsCategoryOneList(viewGoodsCategoryListDto.getParentId());
        }else{
            maps = scoreGoodsCategoryMapper.viewGoodsCategoryList();
        }
        return maps;
    }
}
gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsCategoryListVo.java
New file
@@ -0,0 +1,31 @@
package com.xzx.gc.shop.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "ViewGoodsCategoryListVo", description = "信息返回")
public class ViewGoodsCategoryListVo {
    private long id ;
    @ApiModelProperty(value="分类名称")
    private String name;
    @ApiModelProperty(value="类别标识")
    private String categoryIden;
    @ApiModelProperty(value="父分类")
    private Long parentId;
    @ApiModelProperty(value="父分类名称")
    private String parentName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value="创建时间")
    private Date createdTime;
    @ApiModelProperty(value="创建人")
    private String createdBy;
}
gc-shop/src/main/resources/mapper/shop/ScoreGoodsCategoryMapper.xml
@@ -8,16 +8,34 @@
        FROM
        xzx_score_goods_category a
        WHERE 1 = 1
        <if test="name != null and name != ''">
            and a.name=#{name}
        <if test="record.name != null and record.name != ''">
            and a.name=#{record.name}
        </if>
        <if test="categoryIden != null and categoryIden != ''">
            and a.category_iden=#{categoryIden}
        <if test="record.categoryIden != null and record.categoryIden != ''">
            and a.category_iden=#{record.categoryIden}
        </if>
        <if test="parentId != null and parentId != ''">
            and a.parent_id=#{parentId}
        <if test="record.parentId != null and record.parentId != ''">
            and a.parent_id=#{record.parentId}
        </if>
        order by a.CREATED_TIME desc
    </select>
    <select id="viewGoodsCategoryOneList" resultType="com.xzx.gc.shop.vo.ViewGoodsCategoryListVo">
        SELECT
        *
        FROM
        xzx_score_goods_category a
        WHERE 1 = 1
            and a.parent_id=#{parentId}
    </select>
    <select id="viewGoodsCategoryList" resultType="com.xzx.gc.shop.vo.ViewGoodsCategoryListVo">
        SELECT
            a.*,
               (select name from xzx_score_goods_category where a.parent_id = id) parentName
        FROM
            xzx_score_goods_category a
        WHERE 1 = 1
    </select>
</mapper>
gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml
@@ -11,7 +11,7 @@
        <if test="name != null and name != ''">
            and a.name like concat('%',#{name},'%')
        </if>
        <if test="delFlag != null and delFlag != ''">
        <if test="delFlag == 0 or delFlag == 1">
            and a.del_flag = #{delFlag}
        </if>
        order by a.CREATED_TIME desc
gc-shop/src/main/resources/sql
@@ -28,3 +28,27 @@
ALTER TABLE `xzx_score_goods`
CHANGE COLUMN `gq_end_time` `qg_end_time`  datetime NULL DEFAULT NULL COMMENT '抢购结束时间' AFTER `qg_start_time`;
ALTER TABLE `xzx_score_goods`
MODIFY COLUMN `del_flag`  smallint(2) NULL DEFAULT 0 COMMENT '删除标识0 正常 1已删除 ' AFTER `CREATED_TIME`;
ALTER TABLE `xzx_score_goods_category`
MODIFY COLUMN `del_flag`  smallint(2) NULL DEFAULT 0 COMMENT '删除标识0 正常 1已删除 ' AFTER `CREATED_TIME`;
ALTER TABLE `xzx_score_goods_sku`
MODIFY COLUMN `del_flag`  smallint(2) NULL DEFAULT 0 COMMENT '删除标识0 正常 1已删除 ' AFTER `CREATED_TIME`;
ALTER TABLE `xzx_score_goods_style`
MODIFY COLUMN `del_flag`  smallint(2) NULL DEFAULT 0 COMMENT '删除标识0 正常 1已删除 ' AFTER `CREATED_TIME`;
ALTER TABLE `xzx_score_order`
MODIFY COLUMN `del_flag`  smallint(2) NULL DEFAULT 0 COMMENT '删除标识0 正常 1已删除 ' AFTER `CREATED_TIME`;
ALTER TABLE `xzx_score_order_details`
MODIFY COLUMN `del_flag`  smallint(2) NULL DEFAULT 0 COMMENT '删除标识0 正常 1已删除 ' AFTER `CREATED_TIME`;
ALTER TABLE `xzx_score_goods`
ADD COLUMN `category_id`  bigint(20) NULL COMMENT '分类ID' AFTER `price_range`,
ADD COLUMN `category_name`  varchar(100) NULL COMMENT '分类名称' AFTER `category_id`;