|
@@ -44,13 +44,11 @@ public class TaGoodsController extends BaseController {
|
44
|
44
|
|
45
|
45
|
/**
|
46
|
46
|
* 保存对象
|
47
|
|
- * @param paramStr 实体对象
|
|
47
|
+ * @param taGoods 实体对象
|
48
|
48
|
* @return
|
49
|
49
|
*/
|
50
|
50
|
@RequestMapping(value="/taGoods/add",method= RequestMethod.POST)
|
51
|
|
- public ResponseBean tpShopImgAdd(@RequestBody String paramStr){
|
52
|
|
- JSONObject jsonObject = JSONObject.parseObject(paramStr);
|
53
|
|
- TaGoods taGoods = jsonObject.getObject("goods", TaGoods.class);
|
|
51
|
+ public ResponseBean taGoodsAdd(@RequestBody TaGoods taGoods){
|
54
|
52
|
ResponseBean responseBean = new ResponseBean();
|
55
|
53
|
try {
|
56
|
54
|
taGoods.setCreateDate(LocalDateTime.now());
|
|
@@ -100,23 +98,20 @@ public class TaGoodsController extends BaseController {
|
100
|
98
|
|
101
|
99
|
/**
|
102
|
100
|
* 修改对象
|
103
|
|
- * @param paramStr 实体对象
|
|
101
|
+ * @param taGoods 实体对象
|
104
|
102
|
* @return
|
105
|
103
|
*/
|
106
|
104
|
@RequestMapping(value="/taGoods/update",method= RequestMethod.PUT)
|
107
|
|
- public ResponseBean tpShopImgUpdate(@RequestBody String paramStr){
|
|
105
|
+ public ResponseBean taGoodsUpdate(@RequestBody TaGoods taGoods){
|
108
|
106
|
ResponseBean responseBean = new ResponseBean();
|
109
|
|
- JSONObject jsonObject = JSONObject.parseObject(paramStr);
|
110
|
|
- TaGoods taGoods = jsonObject.getObject("goods", TaGoods.class);
|
111
|
|
- JSONArray spec = jsonObject.getJSONArray("spec");
|
112
|
|
-
|
113
|
107
|
try {
|
114
|
108
|
Boolean flag = iTaGoodsService.updateById(taGoods);
|
115
|
109
|
Boolean flagSpec = false;
|
116
|
|
- for(int i = 0;i<spec.size();i++){
|
117
|
|
- TaGoodsSpec taGoodsSpec = spec.getObject(i, TaGoodsSpec.class);
|
118
|
|
- flagSpec = iTaGoodsSpecService.updateById(taGoodsSpec);
|
119
|
|
- }
|
|
110
|
+ List<TaGoodsSpec> specList = taGoods.getSpecList();
|
|
111
|
+ specList.stream().forEach(e -> {
|
|
112
|
+ e.setGoodsId(taGoods.getGoodsId());
|
|
113
|
+ });
|
|
114
|
+ flagSpec = iTaGoodsSpecService.saveBatch(specList);
|
120
|
115
|
if (flag&& flagSpec){
|
121
|
116
|
responseBean.addSuccess("success");
|
122
|
117
|
}else {
|
|
@@ -134,7 +129,7 @@ public class TaGoodsController extends BaseController {
|
134
|
129
|
* @param id 实体ID
|
135
|
130
|
*/
|
136
|
131
|
@RequestMapping(value="/taGoods/get/{id}",method= RequestMethod.GET)
|
137
|
|
- public ResponseBean tpShopImgGet(@PathVariable Integer id){
|
|
132
|
+ public ResponseBean taGoodsGet(@PathVariable Integer id){
|
138
|
133
|
ResponseBean responseBean = new ResponseBean();
|
139
|
134
|
try {
|
140
|
135
|
TaGoods taGoods = iTaGoodsService.getById(id);
|