PropertiesCtrl.java
4.3 KB
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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.ui.ctrl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.req.PageRequest;
import com.ui.model.req.ProperityUpdateReq;
import com.ui.model.req.UploadProperity;
import com.ui.model.req.ZkTreeReq;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.servlet.ModelAndView;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.Properties;
/**
* Created by jimi on 2018/11/28.
*/
@RestController
@RequestMapping("properity")
public class PropertiesCtrl {
Logger log = LoggerFactory.getLogger(TypeCtrl.class);
@Autowired
HttpRestClient httpRestClient;
@RequestMapping("/getAuthModules")
@ResponseBody
public BaseResponse getAuthModules(PageRequest req, String application, String key, String tag) {
if (StringUtils.isNotBlank(key)) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.QUERY_APP_PROFILE + "?application=" + application + "&key=" + key + "&tag=" + tag, req, BaseResponse.class);
return response;
} else {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.QUERY_APP_PROFILE + "?application=" + application + "&tag=" + tag, req, BaseResponse.class);
return response;
}
}
@RequestMapping("/deleteConfigKey")
@ResponseBody
public BaseResponse deleteConfigKey(@RequestBody ProperityUpdateReq properityUpdateReq) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.DELETE_CONFIG_BY_KEY, properityUpdateReq, BaseResponse.class);
return response;
}
@RequestMapping("/updateConfigBysingle")
@ResponseBody
public BaseResponse updateConfigBysingle(@RequestBody ProperityUpdateReq properityUpdateReq) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.UPDATE_CONFIG_BY_SINGLE, properityUpdateReq, BaseResponse.class);
return response;
}
@RequestMapping("/uploadfile")
@ResponseBody
public BaseResponse uploadfile(UploadProperity req, @RequestParam("file") CommonsMultipartFile file) {
log.info("batchImport with req is {}", req);
Properties properties = new Properties();
try {
properties.load(new InputStreamReader(file.getInputStream(), "UTF-8"));
// properties.load(file.getInputStream());
req.setProperties(properties);
} catch (Exception e) {
log.error("get properity batchImport file info failed", e);
}
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.LOAD_PROPERITY_CONFIG, req, BaseResponse.class);
return response;
}
@RequestMapping("/toProfile")
public ModelAndView toAddUser(Model model) {
BaseResponse appSelected = httpRestClient.defaultGet(HttpUriContants.QUERY_APP_SELECTED, BaseResponse.class);
if (appSelected != null && appSelected.getCode() == 200 && appSelected.getData() != null) {
model.addAttribute("appSelected", appSelected.getData());
}
return new ModelAndView("properties/module");
}
// @RequestMapping("/getProjectSelected")
// public ModelAndView getProjectSelected() {
// return new ModelAndView("properties/module");
// }
@RequestMapping("/addkeytag")
@ResponseBody
public BaseResponse addkeytag(@RequestBody ProperityUpdateReq properityUpdateReq) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ADD_KEY_TAG, properityUpdateReq, BaseResponse.class);
return response;
}
@RequestMapping("/remotekeytag")
@ResponseBody
public BaseResponse remoteKeyTag(@RequestBody ProperityUpdateReq properityUpdateReq) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.DELETE_KEY_TAG, properityUpdateReq, BaseResponse.class);
return response;
}
}