92455d76
孙向锦
添加更新到服务器
|
1
2
3
4
5
6
7
8
9
10
11
12
|
package com.fh.controller.api;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fh.controller.base.BaseController;
import com.fh.service.sunvote.basestation.BasestationManager;
|
cb39a12d
孙向锦
更新api接口头信息
|
13
|
import com.fh.service.sunvote.keypad.KeypadManager;
|
92455d76
孙向锦
添加更新到服务器
|
14
|
import com.fh.service.sunvote.school.SchoolManager;
|
92455d76
孙向锦
添加更新到服务器
|
15
|
import com.fh.util.PageData;
|
92455d76
孙向锦
添加更新到服务器
|
16
17
18
19
20
21
22
23
24
25
26
|
@Controller
@RequestMapping(value="/api")
public class ApiServer extends BaseController {
@Resource(name="schoolService")
private SchoolManager schoolService;
@Resource(name="basestationService")
private BasestationManager basestationService;
|
cb39a12d
孙向锦
更新api接口头信息
|
27
28
|
@Resource(name="keypadService")
private KeypadManager keypadService;
|
92455d76
孙向锦
添加更新到服务器
|
29
|
|
cb39a12d
孙向锦
更新api接口头信息
|
30
31
|
@RequestMapping(value="/school/list" ,produces="application/json;charset=UTF-8")
|
92455d76
孙向锦
添加更新到服务器
|
32
|
@ResponseBody
|
cb39a12d
孙向锦
更新api接口头信息
|
33
|
public Object schoolList() throws Exception{
|
92455d76
孙向锦
添加更新到服务器
|
34
35
36
37
38
|
PageData pd = this.getPageData();
String id = pd.getString("id");
if(id != null && !"".equals(id)){
pd.put("SCHOOL_ID", pd.getString("id"));
PageData ret = schoolService.findById(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
39
40
41
|
ResponseGson<PageData> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
42
43
|
}else{
List<PageData> ret = schoolService.listAll(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
44
45
46
|
ResponseGson<List<PageData>> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
47
|
}
|
cb39a12d
孙向锦
更新api接口头信息
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
}
@RequestMapping(value="/school/add" ,produces="application/json;charset=UTF-8")
@ResponseBody
public Object schoolAdd() throws Exception{
PageData pd = this.getPageData();
ResponseGson<PageData> res = new ResponseGson();
try {
if (pd.get("name") != null) {
schoolService.save(pd);
res.setData(pd);
} else {
res.setDataError();
}
}catch(Exception e){
res.setDataError();
}
return res.toJson();
}
@RequestMapping(value="/school/delete" ,produces="application/json;charset=UTF-8")
@ResponseBody
public Object schoolDelete() throws Exception{
ResponseGson<PageData> res = new ResponseGson();
PageData pd = this.getPageData();
String id = pd.getString("id");
if(id != null && !"".equals(id)){
pd.put("SCHOOL_ID", pd.getString("id"));
schoolService.delete(pd);
res.setData(pd);
}else{
res.setDataError();
}
return res.toJson();
}
@RequestMapping(value="/school/update" ,produces="application/json;charset=UTF-8")
@ResponseBody
public Object schoolUpdate() throws Exception{
ResponseGson<PageData> res = new ResponseGson();
PageData pd = this.getPageData();
String id = pd.getString("id");
if(id != null && !"".equals(id)){
pd.put("SCHOOL_ID", pd.getString("id"));
schoolService.edit(pd);
res.setData(pd);
}else{
res.setDataError();
}
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
97
98
|
}
|
cb39a12d
孙向锦
更新api接口头信息
|
99
100
|
@RequestMapping(value="/basestation/list" ,produces="application/json;charset=UTF-8")
|
92455d76
孙向锦
添加更新到服务器
|
101
102
103
104
105
106
107
|
@ResponseBody
public Object basestation() throws Exception{
PageData pd = this.getPageData();
String id = pd.getString("id");
if(id != null && !"".equals(id)){
pd.put("BASESTATION_ID", pd.getString("id"));
PageData ret = basestationService.findById(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
108
109
110
|
ResponseGson<PageData> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
111
112
|
}else{
List<PageData> ret = basestationService.listAll(pd);
|
cb39a12d
孙向锦
更新api接口头信息
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
ResponseGson<List<PageData>> res = new ResponseGson();
res.setData(ret);
return res.toJson();
}
}
@RequestMapping(value="/keypad/list" ,produces="application/json;charset=UTF-8")
@ResponseBody
public Object keypad() throws Exception{
PageData pd = this.getPageData();
String id = pd.getString("id");
if(id != null && !"".equals(id)){
pd.put("KEYPAD_ID", pd.getString("id"));
PageData ret = keypadService.findById(pd);
ResponseGson<PageData> res = new ResponseGson();
res.setData(ret);
return res.toJson();
}else{
List<PageData> ret = keypadService.listAll(pd);
ResponseGson<List<PageData>> res = new ResponseGson();
res.setData(ret);
return res.toJson();
|
92455d76
孙向锦
添加更新到服务器
|
136
137
138
139
|
}
}
}
|