Commit cb39a12d98a713b5529fefadf875c9f5761bf9e1
1 parent
794ac27e
更新api接口头信息
Showing
18 changed files
with
106 additions
and
31 deletions
src/com/fh/controller/api/ApiServer.java
... | ... | @@ -10,10 +10,9 @@ import org.springframework.web.bind.annotation.ResponseBody; |
10 | 10 | |
11 | 11 | import com.fh.controller.base.BaseController; |
12 | 12 | import com.fh.service.sunvote.basestation.BasestationManager; |
13 | +import com.fh.service.sunvote.keypad.KeypadManager; | |
13 | 14 | import com.fh.service.sunvote.school.SchoolManager; |
14 | -import com.fh.util.Jurisdiction; | |
15 | 15 | import com.fh.util.PageData; |
16 | -import com.google.gson.Gson; | |
17 | 16 | |
18 | 17 | @Controller |
19 | 18 | @RequestMapping(value="/api") |
... | ... | @@ -25,26 +24,80 @@ public class ApiServer extends BaseController { |
25 | 24 | @Resource(name="basestationService") |
26 | 25 | private BasestationManager basestationService; |
27 | 26 | |
27 | + @Resource(name="keypadService") | |
28 | + private KeypadManager keypadService; | |
28 | 29 | |
29 | - @RequestMapping(value="/school" ,produces="application/json;charset=UTF-8") | |
30 | + | |
31 | + @RequestMapping(value="/school/list" ,produces="application/json;charset=UTF-8") | |
30 | 32 | @ResponseBody |
31 | - public Object school() throws Exception{ | |
33 | + public Object schoolList() throws Exception{ | |
32 | 34 | PageData pd = this.getPageData(); |
33 | 35 | String id = pd.getString("id"); |
34 | 36 | if(id != null && !"".equals(id)){ |
35 | 37 | pd.put("SCHOOL_ID", pd.getString("id")); |
36 | 38 | PageData ret = schoolService.findById(pd); |
37 | - Gson gson = new Gson(); | |
38 | - return gson.toJson(ret); | |
39 | + ResponseGson<PageData> res = new ResponseGson(); | |
40 | + res.setData(ret); | |
41 | + return res.toJson(); | |
39 | 42 | }else{ |
40 | 43 | List<PageData> ret = schoolService.listAll(pd); |
41 | - Gson gson = new Gson(); | |
42 | - return gson.toJson(ret); | |
44 | + ResponseGson<List<PageData>> res = new ResponseGson(); | |
45 | + res.setData(ret); | |
46 | + return res.toJson(); | |
43 | 47 | } |
44 | - | |
48 | + } | |
49 | + @RequestMapping(value="/school/add" ,produces="application/json;charset=UTF-8") | |
50 | + @ResponseBody | |
51 | + public Object schoolAdd() throws Exception{ | |
52 | + PageData pd = this.getPageData(); | |
53 | + ResponseGson<PageData> res = new ResponseGson(); | |
54 | + try { | |
55 | + if (pd.get("name") != null) { | |
56 | + schoolService.save(pd); | |
57 | + res.setData(pd); | |
58 | + } else { | |
59 | + res.setDataError(); | |
60 | + } | |
61 | + }catch(Exception e){ | |
62 | + res.setDataError(); | |
63 | + } | |
64 | + return res.toJson(); | |
65 | + } | |
66 | + | |
67 | + @RequestMapping(value="/school/delete" ,produces="application/json;charset=UTF-8") | |
68 | + @ResponseBody | |
69 | + public Object schoolDelete() throws Exception{ | |
70 | + ResponseGson<PageData> res = new ResponseGson(); | |
71 | + PageData pd = this.getPageData(); | |
72 | + String id = pd.getString("id"); | |
73 | + if(id != null && !"".equals(id)){ | |
74 | + pd.put("SCHOOL_ID", pd.getString("id")); | |
75 | + schoolService.delete(pd); | |
76 | + res.setData(pd); | |
77 | + }else{ | |
78 | + res.setDataError(); | |
79 | + } | |
80 | + return res.toJson(); | |
81 | + } | |
82 | + | |
83 | + @RequestMapping(value="/school/update" ,produces="application/json;charset=UTF-8") | |
84 | + @ResponseBody | |
85 | + public Object schoolUpdate() throws Exception{ | |
86 | + ResponseGson<PageData> res = new ResponseGson(); | |
87 | + PageData pd = this.getPageData(); | |
88 | + String id = pd.getString("id"); | |
89 | + if(id != null && !"".equals(id)){ | |
90 | + pd.put("SCHOOL_ID", pd.getString("id")); | |
91 | + schoolService.edit(pd); | |
92 | + res.setData(pd); | |
93 | + }else{ | |
94 | + res.setDataError(); | |
95 | + } | |
96 | + return res.toJson(); | |
45 | 97 | } |
46 | 98 | |
47 | - @RequestMapping(value="/basestation" ,produces="application/json;charset=UTF-8") | |
99 | + | |
100 | + @RequestMapping(value="/basestation/list" ,produces="application/json;charset=UTF-8") | |
48 | 101 | @ResponseBody |
49 | 102 | public Object basestation() throws Exception{ |
50 | 103 | PageData pd = this.getPageData(); |
... | ... | @@ -52,12 +105,34 @@ public class ApiServer extends BaseController { |
52 | 105 | if(id != null && !"".equals(id)){ |
53 | 106 | pd.put("BASESTATION_ID", pd.getString("id")); |
54 | 107 | PageData ret = basestationService.findById(pd); |
55 | - Gson gson = new Gson(); | |
56 | - return gson.toJson(ret); | |
108 | + ResponseGson<PageData> res = new ResponseGson(); | |
109 | + res.setData(ret); | |
110 | + return res.toJson(); | |
57 | 111 | }else{ |
58 | 112 | List<PageData> ret = basestationService.listAll(pd); |
59 | - Gson gson = new Gson(); | |
60 | - return gson.toJson(ret); | |
113 | + ResponseGson<List<PageData>> res = new ResponseGson(); | |
114 | + res.setData(ret); | |
115 | + return res.toJson(); | |
116 | + } | |
117 | + | |
118 | + } | |
119 | + | |
120 | + @RequestMapping(value="/keypad/list" ,produces="application/json;charset=UTF-8") | |
121 | + @ResponseBody | |
122 | + public Object keypad() throws Exception{ | |
123 | + PageData pd = this.getPageData(); | |
124 | + String id = pd.getString("id"); | |
125 | + if(id != null && !"".equals(id)){ | |
126 | + pd.put("KEYPAD_ID", pd.getString("id")); | |
127 | + PageData ret = keypadService.findById(pd); | |
128 | + ResponseGson<PageData> res = new ResponseGson(); | |
129 | + res.setData(ret); | |
130 | + return res.toJson(); | |
131 | + }else{ | |
132 | + List<PageData> ret = keypadService.listAll(pd); | |
133 | + ResponseGson<List<PageData>> res = new ResponseGson(); | |
134 | + res.setData(ret); | |
135 | + return res.toJson(); | |
61 | 136 | } |
62 | 137 | |
63 | 138 | } | ... | ... |
src/com/fh/controller/app/appuser/IntAppuserController.java
src/com/fh/controller/app/redis/RedisDemoController.java
src/com/fh/controller/app/sysuser/SysUserController.java
src/com/fh/controller/base/BaseController.java
src/com/fh/controller/dst/datasource2/DataSource2Controller.java
src/com/fh/controller/fhdb/brdb/BRdbController.java
src/com/fh/controller/fhdb/sqledit/SQLeditController.java
src/com/fh/controller/fhdb/timingbackup/TimingBackUpController.java
src/com/fh/controller/fhoa/datajur/DatajurController.java
src/com/fh/controller/fhoa/department/DepartmentController.java
src/com/fh/controller/fhoa/fhfile/FhfileController.java
src/com/fh/controller/fhoa/staff/StaffController.java
src/com/fh/controller/sunvote/teachingmaterial/TeachingMaterialController.java
src/com/fh/dao/AbstractBaseRedisDao.java
src/com/fh/dao/DAO.java
src/com/fh/dao/DaoSupport.java
... | ... | @@ -10,7 +10,7 @@ import org.apache.ibatis.session.SqlSessionFactory; |
10 | 10 | import org.mybatis.spring.SqlSessionTemplate; |
11 | 11 | import org.springframework.stereotype.Repository; |
12 | 12 | /** |
13 | - * @author FH Q313596790 | |
13 | + * @author Elvis | |
14 | 14 | * 修改时间:2015、12、11 |
15 | 15 | */ |
16 | 16 | @Repository("daoSupport") | ... | ... |