Commit 71351af39885350a368c6c95d9251bb412658452

Authored by zhangxing
2 parents 83d0bd6a 121c6583
src/main/java/com/diligrp/xtrade/product/controllor/CategoryController.java
1 1 package com.diligrp.xtrade.product.controllor;
2 2  
  3 +import java.util.List;
  4 +
3 5 import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.validation.annotation.Validated;
4 7 import org.springframework.web.bind.annotation.PathVariable;
  8 +import org.springframework.web.bind.annotation.RequestBody;
5 9 import org.springframework.web.bind.annotation.RequestMapping;
6 10 import org.springframework.web.bind.annotation.RestController;
7 11  
8 12 import com.diligrp.xtrade.product.domain.dto.CategoryDto;
  13 +import com.diligrp.xtrade.product.domain.entity.CategoryDo;
9 14 import com.diligrp.xtrade.product.service.CategoryService;
10 15 import com.diligrp.xtrade.shared.domain.Message;
11 16  
... ... @@ -16,41 +21,42 @@ import com.diligrp.xtrade.shared.domain.Message;
16 21 * @date 2020年4月20日
17 22 */
18 23 @RestController
19   -@RequestMapping("category/")
  24 +@RequestMapping("sapi/category/")
20 25 public class CategoryController {
21   -
  26 +
22 27 @Autowired
23 28 private CategoryService categoryService;
24   -
  29 +
25 30 /**
26   - * 新增品类
27   - * @Title insert
28   - * @Description 新增品类
  31 + *
  32 + * @Title save
  33 + * @Description 保存
29 34 * @param categoryDTO
30 35 * @return
31 36 * @throws
32 37 */
33   - @RequestMapping("insert")
34   - public Message<?> insert(CategoryDto categoryDTO){
  38 + public Message<?> save(CategoryDto categoryDTO) {
35 39 categoryService.insert(categoryDTO);
36 40 return Message.success();
37 41 }
  42 +
38 43 /**
39   - * 修改品类
  44 + *
40 45 * @Title update
41   - * @Description 修改品类
  46 + * @Description 修改
42 47 * @param categoryDTO
43 48 * @return
44 49 * @throws
45 50 */
46 51 @RequestMapping("update")
47   - public Message<?> update(CategoryDto categoryDTO){
  52 + public Message<Object> update(CategoryDto categoryDTO) {
48 53 categoryService.update(categoryDTO);
49   - return Message.success();
  54 + return null;
  55 +
50 56 }
51   -
  57 +
52 58 /**
53   - * id获取
  59 + *
54 60 * @Title get
55 61 * @Description id获取
56 62 * @param id
... ... @@ -58,11 +64,12 @@ public class CategoryController {
58 64 * @throws
59 65 */
60 66 @RequestMapping("get/{id}")
61   - public Message<?> get(@PathVariable Long id){
  67 + public Message<?> get(@PathVariable Long id) {
62 68 return Message.success(categoryService.selectEntityById(id));
63 69 }
  70 +
64 71 /**
65   - * 主键删除
  72 + *
66 73 * @Title delect
67 74 * @Description 主键删除
68 75 * @param id
... ... @@ -70,8 +77,22 @@ public class CategoryController {
70 77 * @throws
71 78 */
72 79 @RequestMapping("delect/{id}")
73   - public Message<?> delect(@PathVariable Long id){
  80 + public Message<?> delect(@PathVariable Long id) {
74 81 categoryService.delectById(id);
75 82 return Message.success();
76 83 }
  84 +
  85 + /**
  86 + *
  87 + * @Title selectCategoryChild
  88 + * @Description TODO
  89 + * @param cateCode
  90 + * @return
  91 + * @throws
  92 + */
  93 + @RequestMapping("selectCategoryChild/{cateCode}")
  94 + public Message<?> selectCategoryChild(@PathVariable String cateCode) {
  95 + List<CategoryDo> categoryDos = categoryService.selectCateChild(cateCode);
  96 + return Message.success(categoryDos);
  97 + }
77 98 }
... ...
src/main/java/com/diligrp/xtrade/product/controllor/ShopController.java
... ... @@ -3,10 +3,13 @@ package com.diligrp.xtrade.product.controllor;
3 3 import java.util.List;
4 4  
5 5 import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.validation.annotation.Validated;
6 7 import org.springframework.web.bind.annotation.PathVariable;
  8 +import org.springframework.web.bind.annotation.RequestBody;
7 9 import org.springframework.web.bind.annotation.RequestMapping;
8 10 import org.springframework.web.bind.annotation.RestController;
9 11  
  12 +import com.diligrp.xtrade.product.domain.dto.ShopQueryDto;
10 13 import com.diligrp.xtrade.product.domain.dto.ShopDto;
11 14 import com.diligrp.xtrade.product.domain.entity.ShopDo;
12 15 import com.diligrp.xtrade.product.service.ShopService;
... ... @@ -34,7 +37,7 @@ public class ShopController {
34 37 * @throws
35 38 */
36 39 @RequestMapping("save")
37   - public Message<?> save(ShopDto shop){
  40 + public Message<?> save(@Validated @RequestBody ShopDto shop){
38 41 shopService.insert(shop);
39 42 return Message.success();
40 43 }
... ... @@ -48,7 +51,8 @@ public class ShopController {
48 51 * @throws
49 52 */
50 53 @RequestMapping("get/{shopId}")
51   - public Message<ShopDo> get(@PathVariable Long shopId){
  54 +
  55 + public Message<?> get(@PathVariable Long shopId){
52 56 return Message.success(shopService.selectByShopId(shopId));
53 57 }
54 58  
... ... @@ -64,5 +68,19 @@ public class ShopController {
64 68 public Message<?> selectShopByMerId(@PathVariable Long merId){
65 69 List<ShopDo> shopDos = shopService.selectShopByMerId(merId);
66 70 return Message.success(shopDos);
  71 +
  72 + }
  73 +
  74 + /**
  75 + *
  76 + * @Title selectShop
  77 + * @Description 店铺搜索
  78 + * @param shop
  79 + * @return
  80 + * @throws
  81 + */
  82 + @RequestMapping("selectShop")
  83 + public Message<?> selectShop(@Validated @RequestBody ShopQueryDto shop){
  84 + return null;
67 85 }
68 86 }
... ...
src/main/java/com/diligrp/xtrade/product/dao/CategoryDao.java
1 1 package com.diligrp.xtrade.product.dao;
2 2  
  3 +import java.util.List;
  4 +
3 5 import org.apache.ibatis.annotations.Mapper;
4 6  
  7 +import com.diligrp.xtrade.product.domain.dto.CategoryQueryDto;
5 8 import com.diligrp.xtrade.product.domain.entity.CategoryDo;
6 9  
7 10  
... ... @@ -18,7 +21,26 @@ public interface CategoryDao {
18 21  
19 22 void update(CategoryDo category);
20 23  
21   - CategoryDo selectEntityById(Integer id);
  24 + CategoryDo selectEntityById(Long id);
22 25  
23 26 void delect(Long id);
  27 +
  28 + /**
  29 + *
  30 + * @Title selectList
  31 + * @Description 品类条件查询
  32 + * @param categoryQueryDto
  33 + * @return
  34 + * @throws
  35 + */
  36 + List<CategoryDo> selectList(CategoryQueryDto categoryQueryDto);
  37 + /**
  38 + *
  39 + * @Title selectCateChild
  40 + * @Description 根据品类编码获取全部下级品类
  41 + * @param cateCode 品类编码
  42 + * @return
  43 + * @throws
  44 + */
  45 + List<CategoryDo> selectCateChild(String cateCode);
24 46 }
... ...
src/main/java/com/diligrp/xtrade/product/dao/ShopDao.java
... ... @@ -4,6 +4,7 @@ import java.util.List;
4 4  
5 5 import org.apache.ibatis.annotations.Mapper;
6 6  
  7 +import com.diligrp.xtrade.product.domain.dto.ShopQueryDto;
7 8 import com.diligrp.xtrade.product.domain.entity.ShopDo;
8 9 /**
9 10 *
... ... @@ -22,4 +23,7 @@ public interface ShopDao {
22 23 ShopDo selectByShopId(Long shopId);
23 24  
24 25 List<ShopDo> selectByMerId(Long merId);
  26 +
  27 + List<ShopDo> selectShop(ShopQueryDto shopQueryDto);
  28 +
25 29 }
... ...
src/main/java/com/diligrp/xtrade/product/domain/dto/CategoryQueryDto.java 0 → 100644
  1 +package com.diligrp.xtrade.product.domain.dto;
  2 +
  3 +
  4 +/**
  5 + * @ClassName: CategoryDto
  6 + * @Description 品类传输
  7 + * @author yangfan
  8 + * @date 2020年4月16日
  9 + */
  10 +public class CategoryQueryDto{
  11 +
  12 + /**
  13 + * 品类名称
  14 + */
  15 + private String cname;
  16 + /**
  17 + * 拼音缩写
  18 + */
  19 + private String shortName;
  20 + /**
  21 + * 品类状态
  22 + */
  23 + private Integer status;
  24 +
  25 + /**
  26 + * 品类有效期
  27 + */
  28 + private Integer validDay;
  29 + /**
  30 + * 类型
  31 + */
  32 + private Long type;
  33 + /**
  34 + * 品类等级
  35 + */
  36 + private Integer level;
  37 +
  38 + private Integer currentPage;
  39 +
  40 + public String getCname() {
  41 + return cname;
  42 + }
  43 + public void setCname(String cname) {
  44 + this.cname = cname;
  45 + }
  46 + public String getShortName() {
  47 + return shortName;
  48 + }
  49 + public void setShortName(String shortName) {
  50 + this.shortName = shortName;
  51 + }
  52 + public Integer getStatus() {
  53 + return status;
  54 + }
  55 + public void setStatus(Integer status) {
  56 + this.status = status;
  57 + }
  58 + public Integer getValidDay() {
  59 + return validDay;
  60 + }
  61 + public void setValidDay(Integer validDay) {
  62 + this.validDay = validDay;
  63 + }
  64 + public Long getType() {
  65 + return type;
  66 + }
  67 + public void setType(Long type) {
  68 + this.type = type;
  69 + }
  70 + public Integer getLevel() {
  71 + return level;
  72 + }
  73 + public void setLevel(Integer level) {
  74 + this.level = level;
  75 + }
  76 + public Integer getCurrentPage() {
  77 + return currentPage;
  78 + }
  79 + public void setCurrentPage(Integer currentPage) {
  80 + this.currentPage = currentPage;
  81 + }
  82 +
  83 +}
... ...
src/main/java/com/diligrp/xtrade/product/domain/dto/ShopDto.java
... ... @@ -39,12 +39,12 @@ public class ShopDto {
39 39 /**
40 40 * 是否自营
41 41 */
42   - private Integer isSelfShop;
  42 + private Integer selfShop;
43 43  
44 44 /**
45 45 * 主营业务
46 46 */
47   - private String mainBusiness;
  47 + private String mainBiz;
48 48  
49 49 /**
50 50 * 地址
... ... @@ -96,20 +96,22 @@ public class ShopDto {
96 96 this.status = status;
97 97 }
98 98  
99   - public Integer getIsSelfShop() {
100   - return isSelfShop;
  99 +
  100 + public Integer getSelfShop() {
  101 + return selfShop;
101 102 }
102 103  
103   - public void setIsSelfShop(Integer isSelfShop) {
104   - this.isSelfShop = isSelfShop;
  104 + public void setSelfShop(Integer selfShop) {
  105 + this.selfShop = selfShop;
105 106 }
106 107  
107   - public String getMainBusiness() {
108   - return mainBusiness;
  108 +
  109 + public String getMainBiz() {
  110 + return mainBiz;
109 111 }
110 112  
111   - public void setMainBusiness(String mainBusiness) {
112   - this.mainBusiness = mainBusiness;
  113 + public void setMainBiz(String mainBiz) {
  114 + this.mainBiz = mainBiz;
113 115 }
114 116  
115 117 public String getAddress() {
... ...
src/main/java/com/diligrp/xtrade/product/domain/dto/ShopQueryDto.java 0 → 100644
  1 +package com.diligrp.xtrade.product.domain.dto;
  2 +
  3 +import java.time.LocalDateTime;
  4 +
  5 +/**
  6 + * @ClassName: QueryShopDto
  7 + * @Description TODO(用一句话描述该文件做什么)
  8 + * @author yangfan
  9 + * @date 2020年4月22日
  10 + */
  11 +public class ShopQueryDto {
  12 +
  13 + private String shopName;
  14 + private Long merId;
  15 + private LocalDateTime createdTime;
  16 + public String getShopName() {
  17 + return shopName;
  18 + }
  19 + public void setShopName(String shopName) {
  20 + this.shopName = shopName;
  21 + }
  22 + public Long getMerId() {
  23 + return merId;
  24 + }
  25 + public void setMerId(Long merId) {
  26 + this.merId = merId;
  27 + }
  28 + public LocalDateTime getCreatedTime() {
  29 + return createdTime;
  30 + }
  31 + public void setCreatedTime(LocalDateTime createdTime) {
  32 + this.createdTime = createdTime;
  33 + }
  34 +
  35 +}
... ...
src/main/java/com/diligrp/xtrade/product/domain/emuns/IKeyGeneratorKeys.java
... ... @@ -10,7 +10,8 @@ package com.diligrp.xtrade.product.domain.emuns;
10 10 public enum IKeyGeneratorKeys {
11 11 SHOP_SEQUENCE("SHOP_SEQUENCE","店铺id"),
12 12 MERCHANT_SEQUENCE("MERCHANT_SEQUENCE","市场id"),
13   - ACCOUNT_SEQUENCE("ACCOUNT_SEQUENCE","账号id")
  13 + ACCOUNT_SEQUENCE("ACCOUNT_SEQUENCE","账号id"),
  14 + CATEGORY_SEQUENCE("CATEGORY_SEQUENCE","品类is")
14 15 ;
15 16  
16 17 private String code;
... ...
src/main/java/com/diligrp/xtrade/product/domain/entity/ShopDo.java
... ... @@ -31,10 +31,10 @@ public class ShopDo extends BaseDo {
31 31 private Integer status;
32 32  
33 33 //是否自营
34   - private Integer isSelfShop;
  34 + private Integer selfShop;
35 35  
36 36 //主营业务
37   - private String mainBusiness;
  37 + private String mainBiz;
38 38  
39 39 //地址
40 40 private String address;
... ... @@ -82,20 +82,22 @@ public class ShopDo extends BaseDo {
82 82 this.status = status;
83 83 }
84 84  
85   - public Integer getIsSelfShop() {
86   - return isSelfShop;
  85 +
  86 +
  87 + public Integer getSelfShop() {
  88 + return selfShop;
87 89 }
88 90  
89   - public void setIsSelfShop(Integer isSelfShop) {
90   - this.isSelfShop = isSelfShop;
  91 + public void setSelfShop(Integer selfShop) {
  92 + this.selfShop = selfShop;
91 93 }
92 94  
93   - public String getMainBusiness() {
94   - return mainBusiness;
  95 + public String getMainBiz() {
  96 + return mainBiz;
95 97 }
96 98  
97   - public void setMainBusiness(String mainBusiness) {
98   - this.mainBusiness = mainBusiness;
  99 + public void setMainBiz(String mainBiz) {
  100 + this.mainBiz = mainBiz;
99 101 }
100 102  
101 103 public String getAddress() {
... ...
src/main/java/com/diligrp/xtrade/product/service/CategoryService.java
... ... @@ -4,6 +4,7 @@ import java.util.List;
4 4  
5 5  
6 6 import com.diligrp.xtrade.product.domain.dto.CategoryDto;
  7 +import com.diligrp.xtrade.product.domain.dto.CategoryQueryDto;
7 8 import com.diligrp.xtrade.product.domain.entity.CategoryDo;
8 9  
9 10  
... ... @@ -23,9 +24,19 @@ public interface CategoryService {
23 24 /**
24 25 * @Title selectList
25 26 * @Description 条件查询
26   - * @param category
  27 + * @param CategoryQueryDto
27 28 * @return
28 29 * @throws
29 30 */
30   - List<CategoryDo> selectList(CategoryDto category);
  31 + List<CategoryDo> selectList(CategoryQueryDto category);
  32 +
  33 + /**
  34 + *
  35 + * @Title selectCateChild
  36 + * @Description 根据品类catecode获取下级品类
  37 + * @param cateCode
  38 + * @return
  39 + * @throws
  40 + */
  41 + List<CategoryDo> selectCateChild(String cateCode);
31 42 }
... ...
src/main/java/com/diligrp/xtrade/product/service/ShopService.java
... ... @@ -3,6 +3,7 @@ package com.diligrp.xtrade.product.service;
3 3 import java.util.List;
4 4  
5 5 import com.diligrp.xtrade.product.domain.dto.ShopDto;
  6 +import com.diligrp.xtrade.product.domain.dto.ShopQueryDto;
6 7 import com.diligrp.xtrade.product.domain.entity.ShopDo;
7 8  
8 9 public interface ShopService {
... ... @@ -43,4 +44,14 @@ public interface ShopService {
43 44 * @throws
44 45 */
45 46 List<ShopDo> selectShopByMerId(Long merId);
  47 +
  48 + /**
  49 + *
  50 + * @Title selectShop
  51 + * @Description 商铺查询
  52 + * @param shopQuery
  53 + * @return
  54 + * @throws
  55 + */
  56 + List<ShopDo> selectShop(ShopQueryDto shopQuery);
46 57 }
... ...
src/main/java/com/diligrp/xtrade/product/service/impl/CategoryServiceImpl.java
... ... @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
9 9  
10 10 import com.diligrp.xtrade.product.dao.CategoryDao;
11 11 import com.diligrp.xtrade.product.domain.dto.CategoryDto;
  12 +import com.diligrp.xtrade.product.domain.dto.CategoryQueryDto;
12 13 import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys;
13 14 import com.diligrp.xtrade.product.domain.entity.CategoryDo;
14 15 import com.diligrp.xtrade.product.service.CategoryService;
... ... @@ -34,6 +35,7 @@ public class CategoryServiceImpl implements CategoryService {
34 35 BeanUtils.copyProperties(category, categoryDo);
35 36 long id = keyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.CATEGORY_SEQUENCE).nextId();
36 37 String cateCode = ""+id;
  38 + //cateCode 生成 子级品类继承上级品类cateCode 父code_子code
37 39 if (StringUtils.isNotBlank(category.getParentId())) {
38 40 CategoryDo pCategoryDo = selectEntityById(Long.valueOf(category.getParentId()));
39 41 cateCode = String.format("%s_%d", pCategoryDo.getCateCode(),id);
... ... @@ -51,20 +53,22 @@ public class CategoryServiceImpl implements CategoryService {
51 53  
52 54 @Override
53 55 public void delectById(Long id) {
54   - // TODO Auto-generated method stub
55   -
  56 + categoryDao.delect(id);
56 57 }
57 58  
58 59 @Override
59 60 public CategoryDo selectEntityById(Long id) {
60   - // TODO Auto-generated method stub
61   - return null;
  61 + return categoryDao.selectEntityById(id);
  62 + }
  63 +
  64 + @Override
  65 + public List<CategoryDo> selectList(CategoryQueryDto categoryQueryDto) {
  66 + return categoryDao.selectList(categoryQueryDto);
62 67 }
63 68  
64 69 @Override
65   - public List<CategoryDo> selectList(CategoryDto category) {
66   - // TODO Auto-generated method stub
67   - return null;
  70 + public List<CategoryDo> selectCateChild(String cateCode) {
  71 + return categoryDao.selectCateChild(cateCode);
68 72 }
69 73  
70 74 }
... ...
src/main/java/com/diligrp/xtrade/product/service/impl/ShopServiceImpl.java
... ... @@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
8 8  
9 9 import com.diligrp.xtrade.product.dao.ShopDao;
10 10 import com.diligrp.xtrade.product.domain.dto.ShopDto;
  11 +import com.diligrp.xtrade.product.domain.dto.ShopQueryDto;
11 12 import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys;
12 13 import com.diligrp.xtrade.product.domain.entity.ShopDo;
13 14 import com.diligrp.xtrade.product.service.ShopService;
... ... @@ -48,4 +49,10 @@ public class ShopServiceImpl implements ShopService {
48 49 return shops;
49 50 }
50 51  
  52 + @Override
  53 + public List<ShopDo> selectShop(ShopQueryDto shopQuery) {
  54 + List<ShopDo> shops = shopDao.selectShop(shopQuery);
  55 + return shops;
  56 + }
  57 +
51 58 }
... ...
src/main/resources/bootstrap.yml
... ... @@ -20,5 +20,5 @@ spring:
20 20 active: dev
21 21  
22 22 mybatis:
23   - mapper-locations: classpath:mapping/com/diligrp/xtrade/product/*Dao.xml
  23 + mapper-locations: classpath:mapping/com/diligrp/xtrade/*product/*Dao.xml
24 24 type-aliases-package: com.diligrp.xtrade.*.domain.entity
25 25 \ No newline at end of file
... ...
src/main/resources/mapping/com/diligrp/xtrade/product/CategoryDao.xml
... ... @@ -51,7 +51,15 @@
51 51 UPDATE `category` SET status = 2 WHERE id = #{id};
52 52 ]]>
53 53 </update>
54   -
  54 + <select id="selectCateChild" parameterType="string">
  55 + <![CDATA[
  56 + SELECT
  57 + ]]>
  58 + <include refid="QUERY_COLUMN_LIST"/>
  59 + <![CDATA[
  60 + FROM `category` WHERE cate_code LIKE CONCAT(#{cateCode},"%");
  61 + ]]>
  62 + </select>
55 63  
56 64  
57 65  
... ...
src/main/resources/mapping/com/diligrp/xtrade/product/ShopDao.xml
... ... @@ -5,7 +5,7 @@
5 5 <sql id="QUERY_COLUMN_LIST">
6 6 <![CDATA[
7 7 `id`, `shop_id` AS shopId, `shop_name` AS shopName, `address`, `mer_id` AS merId, `type`, `status`,
8   - `main_business` AS mainBusiness, `self_shop` AS selfShop,`description`,`created_time` AS createdTime, `modified_time`AS modifiedTime
  8 + `main_biz` AS mainBiz, `self_shop` AS selfShop,`description`,`created_time` AS createdTime, `modified_time`AS modifiedTime
9 9 ]]>
10 10 </sql>
11 11 <sql id="UPDATE_COLUMN_SET">
... ... @@ -15,7 +15,7 @@
15 15 <if test="merId != null"><![CDATA[mer_id = #{merId},]]></if>
16 16 <if test="type != null"><![CDATA[type = #{type},]]></if>
17 17 <if test="status != null"><![CDATA[status = #{status},]]></if>
18   - <if test="mainBusiness != null"><![CDATA[main_business = #{mainBusiness},]]></if>
  18 + <if test="mainBiz != null"><![CDATA[main_biz = #{mainBiz},]]></if>
19 19 <if test="selfShop != null"><![CDATA[self_shop = #{selfShop},]]></if>
20 20 <if test="description != null"><![CDATA[description = #{description},]]></if>
21 21 <![CDATA[modify_date = now()]]>
... ... @@ -50,4 +50,13 @@
50 50 FROM `xt_shop` WHERE mer_id = #{merId}
51 51 ]]>
52 52 </select>
  53 + <select id="selectShop" parameterType="long" resultType="com.diligrp.xtrade.product.domain.dto.ShopQueryDto">
  54 + <![CDATA[
  55 + SELECT
  56 + ]]>
  57 + <include refid="QUERY_COLUMN_LIST" />
  58 + <![CDATA[
  59 + FROM `xt_shop` WHERE mer_id = #{merId}
  60 + ]]>
  61 + </select>
53 62 </mapper>
54 63 \ No newline at end of file
... ...