92455d76
孙向锦
添加更新到服务器
|
1
2
|
package com.fh.controller.api;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
3
4
|
import java.io.File;
import java.util.Date;
|
92455d76
孙向锦
添加更新到服务器
|
5
6
7
|
import java.util.List;
import javax.annotation.Resource;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
8
|
import javax.servlet.http.HttpServletRequest;
|
92455d76
孙向锦
添加更新到服务器
|
9
10
11
12
|
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
13
|
import org.springframework.web.multipart.MultipartFile;
|
92455d76
孙向锦
添加更新到服务器
|
14
15
|
import com.fh.controller.base.BaseController;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
16
|
import com.fh.service.feedback.feedback.FeedbackManager;
|
92455d76
孙向锦
添加更新到服务器
|
17
|
import com.fh.service.sunvote.basestation.BasestationManager;
|
cb39a12d
孙向锦
更新api接口头信息
|
18
|
import com.fh.service.sunvote.keypad.KeypadManager;
|
92455d76
孙向锦
添加更新到服务器
|
19
|
import com.fh.service.sunvote.school.SchoolManager;
|
92455d76
孙向锦
添加更新到服务器
|
20
|
import com.fh.util.PageData;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
21
|
import com.fh.util.Tools;
|
92455d76
孙向锦
添加更新到服务器
|
22
23
|
@Controller
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
24
|
@RequestMapping(value = "/api")
|
92455d76
孙向锦
添加更新到服务器
|
25
26
|
public class ApiServer extends BaseController {
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
27
|
@Resource(name = "schoolService")
|
92455d76
孙向锦
添加更新到服务器
|
28
|
private SchoolManager schoolService;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
29
30
|
@Resource(name = "basestationService")
|
92455d76
孙向锦
添加更新到服务器
|
31
|
private BasestationManager basestationService;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
32
33
|
@Resource(name = "keypadService")
|
cb39a12d
孙向锦
更新api接口头信息
|
34
|
private KeypadManager keypadService;
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
35
36
37
38
39
|
@Resource(name = "feedbackService")
private FeedbackManager feedbackService;
@RequestMapping(value = "/school", produces = "application/json;charset=UTF-8")
|
7db3ebeb
孙向锦
添加一些模块
|
40
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
41
|
public Object schoolDefault() throws Exception {
|
7db3ebeb
孙向锦
添加一些模块
|
42
43
|
return schoolList();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
44
45
|
@RequestMapping(value = "/school/list", produces = "application/json;charset=UTF-8")
|
92455d76
孙向锦
添加更新到服务器
|
46
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
47
|
public Object schoolList() throws Exception {
|
92455d76
孙向锦
添加更新到服务器
|
48
|
PageData pd = this.getPageData();
|
b980d59d
孙向锦
修改模板
|
49
|
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
50
|
if (id != null && !"".equals(id)) {
|
92455d76
孙向锦
添加更新到服务器
|
51
|
PageData ret = schoolService.findById(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
52
53
54
|
ResponseGson<PageData> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
55
|
} else {
|
92455d76
孙向锦
添加更新到服务器
|
56
|
List<PageData> ret = schoolService.listAll(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
57
58
59
|
ResponseGson<List<PageData>> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
60
|
}
|
cb39a12d
孙向锦
更新api接口头信息
|
61
|
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
62
63
|
@RequestMapping(value = "/school/add", produces = "application/json;charset=UTF-8")
|
cb39a12d
孙向锦
更新api接口头信息
|
64
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
65
|
public Object schoolAdd() throws Exception {
|
cb39a12d
孙向锦
更新api接口头信息
|
66
|
PageData pd = this.getPageData();
|
b980d59d
孙向锦
修改模板
|
67
|
ResponseGson<Integer> res = new ResponseGson();
|
cb39a12d
孙向锦
更新api接口头信息
|
68
|
try {
|
b980d59d
孙向锦
修改模板
|
69
70
71
|
if (pd.get("NAME") != null) {
Integer id = schoolService.save(pd);
res.setData(id);
|
cb39a12d
孙向锦
更新api接口头信息
|
72
73
74
|
} else {
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
75
|
} catch (Exception e) {
|
cb39a12d
孙向锦
更新api接口头信息
|
76
77
78
79
|
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
80
81
|
@RequestMapping(value = "/school/delete", produces = "application/json;charset=UTF-8")
|
cb39a12d
孙向锦
更新api接口头信息
|
82
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
83
|
public Object schoolDelete() throws Exception {
|
cb39a12d
孙向锦
更新api接口头信息
|
84
85
|
ResponseGson<PageData> res = new ResponseGson();
PageData pd = this.getPageData();
|
b980d59d
孙向锦
修改模板
|
86
|
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
87
|
if (id != null && !"".equals(id)) {
|
b980d59d
孙向锦
修改模板
|
88
89
90
91
92
|
try {
schoolService.delete(pd);
} catch (Exception e) {
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
93
|
} else {
|
cb39a12d
孙向锦
更新api接口头信息
|
94
95
96
97
|
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
98
99
|
@RequestMapping(value = "/school/update", produces = "application/json;charset=UTF-8")
|
cb39a12d
孙向锦
更新api接口头信息
|
100
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
101
|
public Object schoolUpdate() throws Exception {
|
cb39a12d
孙向锦
更新api接口头信息
|
102
103
|
ResponseGson<PageData> res = new ResponseGson();
PageData pd = this.getPageData();
|
b980d59d
孙向锦
修改模板
|
104
|
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
105
|
if (id != null && !"".equals(id)) {
|
b980d59d
孙向锦
修改模板
|
106
107
108
109
110
|
try {
schoolService.edit(pd);
} catch (Exception e) {
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
111
|
} else {
|
cb39a12d
孙向锦
更新api接口头信息
|
112
113
114
|
res.setDataError();
}
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
115
|
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
116
117
|
@RequestMapping(value = "/basestation/list", produces = "application/json;charset=UTF-8")
|
92455d76
孙向锦
添加更新到服务器
|
118
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
119
|
public Object basestation() throws Exception {
|
92455d76
孙向锦
添加更新到服务器
|
120
|
PageData pd = this.getPageData();
|
b980d59d
孙向锦
修改模板
|
121
|
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
122
|
if (id != null && !"".equals(id)) {
|
92455d76
孙向锦
添加更新到服务器
|
123
124
|
pd.put("BASESTATION_ID", pd.getString("id"));
PageData ret = basestationService.findById(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
125
126
127
|
ResponseGson<PageData> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
128
|
} else {
|
92455d76
孙向锦
添加更新到服务器
|
129
|
List<PageData> ret = basestationService.listAll(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
130
131
132
133
|
ResponseGson<List<PageData>> res = new ResponseGson();
res.setData(ret);
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
134
|
|
cb39a12d
孙向锦
更新api接口头信息
|
135
|
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
136
137
|
@RequestMapping(value = "/basestation/add", produces = "application/json;charset=UTF-8")
|
b980d59d
孙向锦
修改模板
|
138
139
140
141
142
143
144
145
146
147
|
@ResponseBody
public Object basestationAdd() throws Exception {
ResponseGson<PageData> res = new ResponseGson();
PageData pd = this.getPageData();
if (pd.getString("NAME") != null) {
try {
basestationService.edit(pd);
} catch (Exception ex) {
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
148
|
} else {
|
b980d59d
孙向锦
修改模板
|
149
150
151
152
|
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
153
154
|
@RequestMapping(value = "/basestation/delete", produces = "application/json;charset=UTF-8")
|
b980d59d
孙向锦
修改模板
|
155
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
156
|
public Object basestationDelete() throws Exception {
|
b980d59d
孙向锦
修改模板
|
157
158
159
|
PageData pd = this.getPageData();
ResponseGson<PageData> res = new ResponseGson();
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
160
|
if (id != null && !"".equals(id)) {
|
b980d59d
孙向锦
修改模板
|
161
162
163
164
165
|
try {
basestationService.delete(pd);
} catch (Exception e) {
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
166
|
} else {
|
b980d59d
孙向锦
修改模板
|
167
168
169
170
|
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
171
172
|
@RequestMapping(value = "/basestation/update", produces = "application/json;charset=UTF-8")
|
b980d59d
孙向锦
修改模板
|
173
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
174
|
public Object basestationUpdate() throws Exception {
|
b980d59d
孙向锦
修改模板
|
175
176
177
|
PageData pd = this.getPageData();
ResponseGson<PageData> res = new ResponseGson();
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
178
|
if (id != null && !"".equals(id)) {
|
b980d59d
孙向锦
修改模板
|
179
180
181
182
183
|
try {
basestationService.edit(pd);
} catch (Exception e) {
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
184
|
} else {
|
b980d59d
孙向锦
修改模板
|
185
186
187
188
|
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
189
190
|
@RequestMapping(value = "/keypad/list", produces = "application/json;charset=UTF-8")
|
cb39a12d
孙向锦
更新api接口头信息
|
191
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
192
|
public Object keypad() throws Exception {
|
cb39a12d
孙向锦
更新api接口头信息
|
193
|
PageData pd = this.getPageData();
|
b980d59d
孙向锦
修改模板
|
194
|
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
195
|
if (id != null && !"".equals(id)) {
|
cb39a12d
孙向锦
更新api接口头信息
|
196
197
198
199
|
PageData ret = keypadService.findById(pd);
ResponseGson<PageData> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
200
|
} else {
|
cb39a12d
孙向锦
更新api接口头信息
|
201
202
203
204
|
List<PageData> ret = keypadService.listAll(pd);
ResponseGson<List<PageData>> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
205
|
}
|
92455d76
孙向锦
添加更新到服务器
|
206
|
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
207
208
|
@RequestMapping(value = "/keypad/add", produces = "application/json;charset=UTF-8")
|
b980d59d
孙向锦
修改模板
|
209
210
211
212
213
214
215
216
217
218
219
|
@ResponseBody
public Object keypadAdd() throws Exception {
PageData pd = this.getPageData();
ResponseGson<PageData> res = new ResponseGson();
try {
keypadService.save(pd);
} catch (Exception ex) {
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
220
221
|
@RequestMapping(value = "/keypad/delete", produces = "application/json;charset=UTF-8")
|
b980d59d
孙向锦
修改模板
|
222
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
223
|
public Object keypadDelete() throws Exception {
|
b980d59d
孙向锦
修改模板
|
224
225
226
|
PageData pd = this.getPageData();
ResponseGson<PageData> res = new ResponseGson();
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
227
|
if (id != null && !"".equals(id)) {
|
b980d59d
孙向锦
修改模板
|
228
229
230
231
232
|
try {
keypadService.delete(pd);
} catch (Exception e) {
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
233
|
} else {
|
b980d59d
孙向锦
修改模板
|
234
235
236
237
|
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
238
239
|
@RequestMapping(value = "/keypad/update", produces = "application/json;charset=UTF-8")
|
b980d59d
孙向锦
修改模板
|
240
|
@ResponseBody
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
241
|
public Object keypadUpdate() throws Exception {
|
b980d59d
孙向锦
修改模板
|
242
243
244
|
PageData pd = this.getPageData();
ResponseGson<PageData> res = new ResponseGson();
String id = pd.getString("ID");
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
245
246
|
if (id != null && !"".equals(id)) {
try {
|
b980d59d
孙向锦
修改模板
|
247
|
keypadService.edit(pd);
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
248
|
} catch (Exception ex) {
|
b980d59d
孙向锦
修改模板
|
249
250
|
res.setDataError();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
251
|
} else {
|
b980d59d
孙向锦
修改模板
|
252
253
254
255
|
res.setDataError();
}
return res.toJson();
}
|
6cdfeaf1
孙向锦
修改相关信息,添加反馈模块
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
@RequestMapping(value = "/feedback/add", produces = "application/json;charset=UTF-8")
@ResponseBody
public Object feedbackAdd(MultipartFile file, HttpServletRequest request)
throws Exception {
PageData pd = this.getPageData();
ResponseGson<PageData> res = new ResponseGson();
String path = request.getSession().getServletContext()
.getRealPath("/images");
if (file != null) {
String fileName = file.getOriginalFilename();
File dir = new File(path, Tools.date2Str(new Date()) + fileName);
if (!dir.exists()) {
dir.mkdirs();
}
file.transferTo(dir);
pd.put("PROBLEM_PATH", dir.getAbsolutePath());
}
String id = pd.getString("ID");
if (id != null && !"".equals(id)) {
try {
feedbackService.edit(pd);
} catch (Exception ex) {
res.setDataError();
}
} else {
pd.put("CREATE_DATE", Tools.date2Str(new Date()));
try {
feedbackService.save(pd);
} catch (Exception ex) {
res.setDataError();
}
}
return res.toJson();
}
|
92455d76
孙向锦
添加更新到服务器
|
292
|
}
|