|
@@ -1,6 +1,8 @@
|
1
|
1
|
package com.community.huiju.controller;
|
2
|
2
|
|
3
|
3
|
|
|
4
|
+import com.alibaba.fastjson.JSONArray;
|
|
5
|
+import com.alibaba.fastjson.JSONObject;
|
4
|
6
|
import com.community.commom.mode.ResponseBean;
|
5
|
7
|
import com.community.commom.session.UserElement;
|
6
|
8
|
import com.community.huiju.common.base.BaseController;
|
|
@@ -21,6 +23,8 @@ import org.springframework.web.bind.annotation.RestController;
|
21
|
23
|
|
22
|
24
|
import javax.servlet.http.HttpSession;
|
23
|
25
|
import java.time.LocalDateTime;
|
|
26
|
+import java.util.ArrayList;
|
|
27
|
+import java.util.List;
|
24
|
28
|
|
25
|
29
|
/**
|
26
|
30
|
* <p>
|
|
@@ -87,4 +91,77 @@ public class TpShopController extends BaseController {
|
87
|
91
|
responseBean.addSuccess(tpShop);
|
88
|
92
|
return responseBean;
|
89
|
93
|
}
|
|
94
|
+
|
|
95
|
+ @ApiOperation(value = "更新商铺", notes = "更新商铺")
|
|
96
|
+ @ApiImplicitParams({
|
|
97
|
+ @ApiImplicitParam(paramType = "body", dataType = "TpShop", name = "shop", value = "商铺"),
|
|
98
|
+ @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
|
|
99
|
+ })
|
|
100
|
+ @RequestMapping(value = "/shop/update",method = RequestMethod.POST)
|
|
101
|
+ public ResponseBean updateShop(@RequestBody TpShop shop, HttpSession session){
|
|
102
|
+ ResponseBean responseBean = new ResponseBean();
|
|
103
|
+ UserElement userElement = getUserElement(session);
|
|
104
|
+ responseBean = shopService.updateShop(shop,userElement);
|
|
105
|
+ return responseBean;
|
|
106
|
+ }
|
|
107
|
+
|
|
108
|
+ @ApiOperation(value = "上架商铺", notes = "上架商铺")
|
|
109
|
+ @ApiImplicitParams({
|
|
110
|
+ @ApiImplicitParam(paramType = "body", dataType = "String", name = "jsonString", value = "商铺id集合"),
|
|
111
|
+ @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
|
|
112
|
+ })
|
|
113
|
+ @RequestMapping(value = "/shop/shelf",method = RequestMethod.POST)
|
|
114
|
+ public ResponseBean shelfShop(@RequestBody String jsonString, HttpSession session){
|
|
115
|
+ ResponseBean responseBean = new ResponseBean();
|
|
116
|
+ UserElement userElement = getUserElement(session);
|
|
117
|
+ JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
118
|
+ JSONArray ids = jsonObject.getJSONArray("idArray");
|
|
119
|
+ List<TpShop> tpShopList = new ArrayList<>();
|
|
120
|
+ for (Object id : ids){
|
|
121
|
+ TpShop tpShop = new TpShop();
|
|
122
|
+ tpShop.setId((Integer) id);
|
|
123
|
+ tpShop.setShopStatus("1");
|
|
124
|
+ tpShop.setUpdateUser(userElement.getId());
|
|
125
|
+ tpShop.setUpdateDate(LocalDateTime.now());
|
|
126
|
+ tpShopList.add(tpShop);
|
|
127
|
+ }
|
|
128
|
+
|
|
129
|
+ boolean state = shopService.updateBatchById(tpShopList);
|
|
130
|
+ if (state){
|
|
131
|
+ responseBean.addSuccess("上架成功");
|
|
132
|
+ }else{
|
|
133
|
+ responseBean.addError("上架失败");
|
|
134
|
+ }
|
|
135
|
+ return responseBean;
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ @ApiOperation(value = "下架商铺", notes = "下架商铺")
|
|
139
|
+ @ApiImplicitParams({
|
|
140
|
+ @ApiImplicitParam(paramType = "body", dataType = "String", name = "jsonString", value = "商铺id集合"),
|
|
141
|
+ @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
|
|
142
|
+ })
|
|
143
|
+ @RequestMapping(value = "/shop/obtained",method = RequestMethod.POST)
|
|
144
|
+ public ResponseBean obtainedShop(@RequestBody String jsonString, HttpSession session){
|
|
145
|
+ ResponseBean responseBean = new ResponseBean();
|
|
146
|
+ UserElement userElement = getUserElement(session);
|
|
147
|
+ JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
148
|
+ JSONArray ids = jsonObject.getJSONArray("idArray");
|
|
149
|
+ List<TpShop> tpShopList = new ArrayList<>();
|
|
150
|
+ for (Object id : ids){
|
|
151
|
+ TpShop tpShop = new TpShop();
|
|
152
|
+ tpShop.setId((Integer) id);
|
|
153
|
+ tpShop.setShopStatus("2");
|
|
154
|
+ tpShop.setUpdateUser(userElement.getId());
|
|
155
|
+ tpShop.setUpdateDate(LocalDateTime.now());
|
|
156
|
+ tpShopList.add(tpShop);
|
|
157
|
+ }
|
|
158
|
+
|
|
159
|
+ boolean state = shopService.updateBatchById(tpShopList);
|
|
160
|
+ if (state){
|
|
161
|
+ responseBean.addSuccess("下架成功");
|
|
162
|
+ }else{
|
|
163
|
+ responseBean.addError("下架失败");
|
|
164
|
+ }
|
|
165
|
+ return responseBean;
|
|
166
|
+ }
|
90
|
167
|
}
|