Commit 3416a2c31cee7176cac84f8ffdf0f8da4de1514d
Merge branch 'master' of http://git3.nong12.com/xtrade/order-service.git
Showing
2 changed files
with
22 additions
and
14 deletions
src/main/java/com/diligrp/xtrade/product/controllor/CategoryController.java
... | ... | @@ -5,6 +5,7 @@ import java.util.List; |
5 | 5 | |
6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
7 | 7 | import org.springframework.beans.factory.annotation.Value; |
8 | +import org.springframework.validation.annotation.Validated; | |
8 | 9 | import org.springframework.web.bind.annotation.PathVariable; |
9 | 10 | import org.springframework.web.bind.annotation.RequestBody; |
10 | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
... | ... | @@ -20,6 +21,7 @@ import com.diligrp.xtrade.product.exception.ExceptionEnum; |
20 | 21 | import com.diligrp.xtrade.product.exception.ProductException; |
21 | 22 | import com.diligrp.xtrade.product.service.CategoryService; |
22 | 23 | import com.diligrp.xtrade.shared.domain.Message; |
24 | +import com.diligrp.xtrade.shared.util.AssertUtils; | |
23 | 25 | |
24 | 26 | /** |
25 | 27 | * @ClassName: CategoryController |
... | ... | @@ -51,7 +53,7 @@ public class CategoryController { |
51 | 53 | * @throws |
52 | 54 | */ |
53 | 55 | @RequestMapping("save") |
54 | - public Message<?> save(CategoryDto categoryDTO) { | |
56 | + public Message<?> save(@Validated CategoryDto categoryDTO) { | |
55 | 57 | checkImageFile(categoryDTO.getImage()); |
56 | 58 | categoryService.insert(categoryDTO); |
57 | 59 | return Message.success(); |
... | ... | @@ -66,7 +68,7 @@ public class CategoryController { |
66 | 68 | * @throws |
67 | 69 | */ |
68 | 70 | @RequestMapping("update") |
69 | - public Message<Object> update(CategoryDto categoryDTO) { | |
71 | + public Message<Object> update(@Validated CategoryDto categoryDTO) { | |
70 | 72 | categoryService.update(categoryDTO); |
71 | 73 | return null; |
72 | 74 | |
... | ... | @@ -80,22 +82,24 @@ public class CategoryController { |
80 | 82 | * @return |
81 | 83 | * @throws |
82 | 84 | */ |
83 | - @RequestMapping("get/{id}") | |
84 | - public Message<?> get(@PathVariable Long id) { | |
85 | - return Message.success(categoryService.selectEntityById(id)); | |
85 | + @RequestMapping("get/{cateCode}") | |
86 | + public Message<?> get(@PathVariable Long cateCode) { | |
87 | + AssertUtils.notNull(cateCode, "编码不能为空"); | |
88 | + return Message.success(categoryService.selectEntityById(cateCode)); | |
86 | 89 | } |
87 | 90 | |
88 | 91 | /** |
89 | 92 | * |
90 | 93 | * @Title delect |
91 | 94 | * @Description 主键删除 |
92 | - * @param id | |
95 | + * @param cateCode | |
93 | 96 | * @return |
94 | 97 | * @throws |
95 | 98 | */ |
96 | - @RequestMapping("delect/{id}") | |
97 | - public Message<?> delect(@PathVariable Long id) { | |
98 | - categoryService.delectById(id); | |
99 | + @RequestMapping("delect/{cateCode}") | |
100 | + public Message<?> delect(@PathVariable Long cateCode) { | |
101 | + AssertUtils.notNull(cateCode, "编码不能为空"); | |
102 | + categoryService.delectById(cateCode); | |
99 | 103 | return Message.success(); |
100 | 104 | } |
101 | 105 | |
... | ... | @@ -109,6 +113,7 @@ public class CategoryController { |
109 | 113 | */ |
110 | 114 | @RequestMapping("selectCategoryChild/{cateCode}") |
111 | 115 | public Message<?> selectCategoryChild(@PathVariable String cateCode) { |
116 | + AssertUtils.notEmpty(cateCode, "编码不能为空"); | |
112 | 117 | List<CategoryDo> categoryDos = categoryService.selectCateChild(cateCode); |
113 | 118 | return Message.success(categoryDos); |
114 | 119 | } |
... | ... | @@ -125,11 +130,11 @@ public class CategoryController { |
125 | 130 | if (!ImageUtil.isImage(file.getInputStream())) { |
126 | 131 | throw new ProductException(ExceptionEnum.FILE_UP_ERROR.getCode(),"只能上传图片"); |
127 | 132 | } |
128 | -// if (!ImageUtil.checkImageSize(file.getInputStream(), MAX_WIDTH, MAX_HEIGHT, MIN_WIDTH, MIN_HEIGHT)) { | |
129 | -// | |
130 | -// throw new ProductException(ExceptionEnum.FILE_UP_ERROR.getCode(),"上传图片长宽超过限制,请保证图片大小范围为" + MIN_WIDTH + "*" + MIN_HEIGHT + "到" + MAX_WIDTH + "*" | |
131 | -// + MAX_HEIGHT); | |
132 | -// } | |
133 | + if (!ImageUtil.checkImageSize(file.getInputStream(), MAX_WIDTH, MAX_HEIGHT, MIN_WIDTH, MIN_HEIGHT)) { | |
134 | + | |
135 | + throw new ProductException(ExceptionEnum.FILE_UP_ERROR.getCode(),"上传图片长宽超过限制,请保证图片大小范围为" + MIN_WIDTH + "*" + MIN_HEIGHT + "到" + MAX_WIDTH + "*" | |
136 | + + MAX_HEIGHT); | |
137 | + } | |
133 | 138 | if (file.getBytes().length > MAX_FILE_SIZE) { |
134 | 139 | throw new ProductException(ExceptionEnum.FILE_UP_ERROR.getCode(),"上传图片大小超过限制,请保证图片不超过256K"); |
135 | 140 | } | ... | ... |
src/main/java/com/diligrp/xtrade/product/controllor/ShopController.java
... | ... | @@ -14,6 +14,7 @@ import com.diligrp.xtrade.product.domain.dto.ShopDto; |
14 | 14 | import com.diligrp.xtrade.product.domain.entity.ShopDo; |
15 | 15 | import com.diligrp.xtrade.product.service.ShopService; |
16 | 16 | import com.diligrp.xtrade.shared.domain.Message; |
17 | +import com.diligrp.xtrade.shared.util.AssertUtils; | |
17 | 18 | |
18 | 19 | /** |
19 | 20 | * @ClassName: ShopControler |
... | ... | @@ -53,6 +54,7 @@ public class ShopController { |
53 | 54 | @RequestMapping("get/{shopId}") |
54 | 55 | |
55 | 56 | public Message<?> get(@PathVariable Long shopId){ |
57 | + AssertUtils.notNull(shopId, "店铺id不能为空"); | |
56 | 58 | return Message.success(shopService.selectByShopId(shopId)); |
57 | 59 | } |
58 | 60 | |
... | ... | @@ -66,6 +68,7 @@ public class ShopController { |
66 | 68 | */ |
67 | 69 | @RequestMapping("selectShopByMerId/{merId}") |
68 | 70 | public Message<?> selectShopByMerId(@PathVariable Long merId){ |
71 | + AssertUtils.notNull(merId, "商户id不能为空"); | |
69 | 72 | List<ShopDo> shopDos = shopService.selectShopByMerId(merId); |
70 | 73 | return Message.success(shopDos); |
71 | 74 | ... | ... |