Authored by FengRuwei

rm old

1 -package com.ui.ctrl;  
2 -  
3 -import com.alibaba.fastjson.JSONObject;  
4 -import com.ui.contants.HttpUriContants;  
5 -import com.ui.http.HttpRestClient;  
6 -import org.slf4j.Logger;  
7 -import org.slf4j.LoggerFactory;  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.stereotype.Controller;  
10 -import org.springframework.web.bind.annotation.RequestMapping;  
11 -import org.springframework.web.bind.annotation.RequestParam;  
12 -import org.springframework.web.bind.annotation.ResponseBody;  
13 -  
14 -/**  
15 - * Created by fruwei on 2016/6/16.  
16 - */  
17 -@Controller  
18 -@RequestMapping("type")  
19 -public class TypeCtrl {  
20 - Logger logger = LoggerFactory.getLogger(TypeCtrl.class);  
21 -  
22 - @Autowired  
23 - private HttpRestClient httpClient;  
24 -  
25 - @RequestMapping("/all")  
26 - @ResponseBody  
27 - public String getAllType() {  
28 - String strType = "";  
29 -  
30 - logger.debug("get all type");  
31 -  
32 - strType = httpClient.defaultGet(HttpUriContants.TYPE_GET_ALL, String.class);  
33 -  
34 - logger.info("all type: {}", strType);  
35 -  
36 - return strType;  
37 - }  
38 -  
39 -  
40 - @RequestMapping("/add")  
41 - @ResponseBody  
42 - public String addType(@RequestParam String name, @RequestParam int pid, @RequestParam int isleaf) {  
43 -  
44 - String rel;  
45 - logger.info("add type name:{},pid:{},isLeaf{}", name, pid, isleaf);  
46 -  
47 - JSONObject req=new JSONObject();  
48 - req.put("typeName",name);  
49 - req.put("typeParentId",pid);  
50 - req.put("typeIsLeaf",isleaf);  
51 -  
52 - rel = httpClient.defaultPost(HttpUriContants.TYPE_ADD, req,String.class);  
53 -  
54 - logger.info("all type: {}", rel);  
55 -  
56 -  
57 -  
58 - return rel;  
59 - }  
60 -  
61 -  
62 - @RequestMapping("/del")  
63 - @ResponseBody  
64 - public String delType(@RequestParam int id) {  
65 - String rel = "";  
66 - logger.info("update type id {} ", id);  
67 - rel = httpClient.defaultGet(HttpUriContants.TYPE_DEL+"/"+id,String.class);  
68 - logger.info("update type: {}", rel);  
69 - return "ok";  
70 - }  
71 -  
72 -  
73 - @RequestMapping("/update")  
74 - @ResponseBody  
75 - public String updateType(@RequestParam int id, @RequestParam String name) {  
76 - String rel = "";  
77 -  
78 - logger.info("update type id {} ,name {}", id, name);  
79 -  
80 - JSONObject req=new JSONObject();  
81 -  
82 - req.put("typeId",id);  
83 - req.put("typeName",name);  
84 -  
85 - rel = httpClient.defaultPost(HttpUriContants.TYPE_UPDATE, req,String.class);  
86 - logger.info("update type: {}", rel);  
87 -  
88 - return rel;  
89 - }  
90 -  
91 -}