|
@@ -2,6 +2,8 @@ package com.huiju.welcome.controller;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.fastjson.JSONArray;
|
4
|
4
|
import com.alibaba.fastjson.JSONObject;
|
|
5
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
6
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
5
|
7
|
import com.google.gson.JsonArray;
|
6
|
8
|
import com.google.gson.JsonObject;
|
7
|
9
|
import com.huiju.welcome.common.base.BaseController;
|
|
@@ -9,19 +11,19 @@ import com.huiju.welcome.common.base.ResponseBean;
|
9
|
11
|
import com.huiju.welcome.model.TaGoods;
|
10
|
12
|
import com.huiju.welcome.model.TaGoodsImg;
|
11
|
13
|
import com.huiju.welcome.model.TaGoodsSpec;
|
|
14
|
+import com.huiju.welcome.model.TdGoodsType;
|
12
|
15
|
import com.huiju.welcome.service.ITaGoodsImgService;
|
13
|
16
|
import com.huiju.welcome.service.ITaGoodsService;
|
14
|
17
|
import com.huiju.welcome.service.ITaGoodsSpecService;
|
|
18
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
19
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
20
|
+import io.swagger.annotations.ApiOperation;
|
15
|
21
|
import org.slf4j.Logger;
|
16
|
22
|
import org.slf4j.LoggerFactory;
|
17
|
23
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
19
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
20
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
21
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
22
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
23
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
24
|
+import org.springframework.web.bind.annotation.*;
|
24
|
25
|
|
|
26
|
+import java.util.List;
|
25
|
27
|
|
26
|
28
|
|
27
|
29
|
/**
|
|
@@ -63,14 +65,15 @@ public class TaGoodsController extends BaseController {
|
63
|
65
|
try {
|
64
|
66
|
Boolean flag = iTaGoodsService.save(taGoods);
|
65
|
67
|
Boolean flagImg = iTaGoodsImgService.save(taGoodsImg);
|
66
|
|
- Boolean flagSpec = false;
|
67
|
|
- for(int i = 0;i<spec.size();i++){
|
68
|
|
- TaGoodsSpec taGoodsSpec = spec.getObject(i, TaGoodsSpec.class);
|
69
|
|
- taGoodsSpec.setGoodsId(taGoods.getGoodsId());
|
70
|
|
- flagSpec = iTaGoodsSpecService.save(taGoodsSpec);
|
71
|
|
- }
|
72
|
|
- if (flag&& flagImg&&flagSpec){
|
73
|
|
- responseBean.addSuccess("success");
|
|
68
|
+ List<TaGoodsSpec> specList = spec.toJavaList(TaGoodsSpec.class);
|
|
69
|
+ specList.stream().forEach(e -> {
|
|
70
|
+ e.setGoodsId(taGoods.getGoodsId());
|
|
71
|
+ });
|
|
72
|
+
|
|
73
|
+ boolean result = iTaGoodsSpecService.saveBatch(specList);
|
|
74
|
+
|
|
75
|
+ if (flag&&flagImg&&result){
|
|
76
|
+ responseBean.addSuccess(taGoods);
|
74
|
77
|
}else {
|
75
|
78
|
responseBean.addError("fail");
|
76
|
79
|
}
|
|
@@ -151,6 +154,22 @@ public class TaGoodsController extends BaseController {
|
151
|
154
|
return responseBean;
|
152
|
155
|
}
|
153
|
156
|
|
|
157
|
+ @ApiOperation(value = "商品列表", notes = "商品列表")
|
|
158
|
+ @ApiImplicitParams({
|
|
159
|
+ @ApiImplicitParam(paramType = "body", dataType = "String", name = "typeName", value = "商品名称")
|
|
160
|
+ })
|
|
161
|
+ @RequestMapping(value = "/taGoods", method = RequestMethod.GET)
|
|
162
|
+ public ResponseBean typeList(@RequestParam(defaultValue = "1") int pageNum,
|
|
163
|
+ @RequestParam(defaultValue = "10") int pageSize,
|
|
164
|
+ @RequestParam(value = "goodsName",required = false) String goodsName,
|
|
165
|
+ @RequestParam(value = "typeId",required = false) Integer typeId) {
|
|
166
|
+ IPage<TaGoods> pg = new Page<>(pageNum, pageSize);
|
|
167
|
+
|
|
168
|
+ ResponseBean userManagement= iTaGoodsService.goodsList(pg,goodsName,typeId);
|
|
169
|
+
|
|
170
|
+ return userManagement;
|
|
171
|
+ }
|
|
172
|
+
|
154
|
173
|
|
155
|
174
|
|
156
|
175
|
|