Blame view

src/com/fh/controller/api/ApiServer.java 1.78 KB
92455d76   孙向锦   添加更新到服务器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  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;
  import com.fh.service.sunvote.school.SchoolManager;
  import com.fh.util.Jurisdiction;
  import com.fh.util.PageData;
  import com.google.gson.Gson;
  
  @Controller
  @RequestMapping(value="/api")
  public class ApiServer extends BaseController {
  
  	@Resource(name="schoolService")
  	private SchoolManager schoolService;
  	
  	@Resource(name="basestationService")
  	private BasestationManager basestationService;
  	
  	
  	@RequestMapping(value="/school" ,produces="application/json;charset=UTF-8")
  	@ResponseBody
  	public Object school() throws Exception{
  		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);
  			Gson gson = new Gson();
  			return gson.toJson(ret);
  		}else{
  			List<PageData> ret = schoolService.listAll(pd);
  			Gson gson = new Gson();
  			return gson.toJson(ret);
  		}
  		
  	}
  	
  	@RequestMapping(value="/basestation" ,produces="application/json;charset=UTF-8")
  	@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);
  			Gson gson = new Gson();
  			return gson.toJson(ret);
  		}else{
  			List<PageData> ret = basestationService.listAll(pd);
  			Gson gson = new Gson();
  			return gson.toJson(ret);
  		}
  		
  	}
  }