From 7a8413c07a44737e559cbc0369f9ff9687f22646 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 24 Jun 2021 14:48:11 +0800
Subject: [PATCH] 20210624 商品分类
---
gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsCategoryListVo.java | 31 ++++++++++
gc-shop/src/main/java/com/xzx/gc/shop/controller/AdminGoodsCategoryController.java | 12 ++++
gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml | 2
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsCategoryMapper.java | 7 ++
gc-core/src/main/java/com/xzx/gc/entity/ScoreGoods.java | 7 ++
gc-shop/src/main/java/com/xzx/gc/shop/dto/QueryGoodsListDto.java | 2
gc-shop/src/main/java/com/xzx/gc/shop/dto/ViewGoodsCategoryListDto.java | 12 ++++
gc-shop/src/main/resources/sql | 24 ++++++++
gc-shop/src/main/resources/mapper/shop/ScoreGoodsCategoryMapper.xml | 30 ++++++++--
gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java | 12 +++
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsMapper.java | 4
gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java | 19 ++++--
12 files changed, 144 insertions(+), 18 deletions(-)
diff --git a/gc-core/src/main/java/com/xzx/gc/entity/ScoreGoods.java b/gc-core/src/main/java/com/xzx/gc/entity/ScoreGoods.java
index 41dae17..8f534a1 100644
--- a/gc-core/src/main/java/com/xzx/gc/entity/ScoreGoods.java
+++ b/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-否
*/
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/controller/AdminGoodsCategoryController.java b/gc-shop/src/main/java/com/xzx/gc/shop/controller/AdminGoodsCategoryController.java
index 2b589bf..30087a0 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/controller/AdminGoodsCategoryController.java
+++ b/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")
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java b/gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java
index 244b68e..5a61c0a 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java
+++ b/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="积分商品样式")
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/dto/QueryGoodsListDto.java b/gc-shop/src/main/java/com/xzx/gc/shop/dto/QueryGoodsListDto.java
index 1a650eb..9e812c1 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/dto/QueryGoodsListDto.java
+++ b/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;
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/dto/ViewGoodsCategoryListDto.java b/gc-shop/src/main/java/com/xzx/gc/shop/dto/ViewGoodsCategoryListDto.java
new file mode 100644
index 0000000..b16d03b
--- /dev/null
+++ b/gc-shop/src/main/java/com/xzx/gc/shop/dto/ViewGoodsCategoryListDto.java
@@ -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;
+
+}
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsCategoryMapper.java b/gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsCategoryMapper.java
index 2f28934..fb4f34d 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsCategoryMapper.java
+++ b/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();
}
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsMapper.java b/gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsMapper.java
index 1b72bb5..05c091f 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreGoodsMapper.java
+++ b/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);
}
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java b/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
index f6c181e..30c6201 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
+++ b/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;
+ }
}
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsCategoryListVo.java b/gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsCategoryListVo.java
new file mode 100644
index 0000000..6eb7fae
--- /dev/null
+++ b/gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsCategoryListVo.java
@@ -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;
+}
diff --git a/gc-shop/src/main/resources/mapper/shop/ScoreGoodsCategoryMapper.xml b/gc-shop/src/main/resources/mapper/shop/ScoreGoodsCategoryMapper.xml
index 581a8ec..8c67f58 100644
--- a/gc-shop/src/main/resources/mapper/shop/ScoreGoodsCategoryMapper.xml
+++ b/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>
diff --git a/gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml b/gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml
index 46c2412..bbd2c0c 100644
--- a/gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml
+++ b/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
diff --git a/gc-shop/src/main/resources/sql b/gc-shop/src/main/resources/sql
index a0f7ea1..263f717 100644
--- a/gc-shop/src/main/resources/sql
+++ b/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`;
+
+
+
--
Gitblit v1.9.1