需求:
移动端的值班经理视图调用了三个接口,需要在移动段的应用下加上三个接口的路由,分别是:
/xxx-mvc/dutyView/getProviderSysDeal
/xxx-mvc/dutyView/getSysAlarmData
/xxx-mvc/dutyView/getSysStaffInfo
package com.xxx.xxx.mvcmobile.controller;import com.alibaba.fastjson.JSONObject;
import com.chinalife.amp.mvcmobile.config.ServerRestUrlConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;import java.util.HashMap;
import java.util.Map;/*** Created by xxx on 2019/02/12.*/
@RestController
@RequestMapping("/dutyView")
public class AmpDutyViewController {private final static Logger logger = LoggerFactory.getLogger(AmpDutyViewController.class);@AutowiredServerRestUrlConfig serverRestUrlConfig;@AutowiredRestTemplate restTemplate;/*** 获取系统交易量* @param map* @return*/@RequestMapping(value = "/getProviderSysDeal",method = RequestMethod.POST)public String getProviderSysDeal(@RequestBody Map<String,Object> map){logger.info("XxxDutyViewController--->getProviderSysDeal入参:"+map.toString());String restResult = "";try {String url = "http://"+serverRestUrlConfig.getIp_xxxservicestatistic()+":"+serverRestUrlConfig.getPort_xxxservicestatistic()+"/"+serverRestUrlConfig.getXxx_servicestatistic()+"/getProviderSysDealTop";logger.info("XxxDutyViewController--->getProviderSysDeal地址:"+url);restResult= restTemplate.postForEntity(url, map, String.class).getBody();} catch (Exception e) {// TODO: handle exceptionMap<String, String> result = new HashMap<String, String>();result.put("messageCode", serverRestUrlConfig.getMessage_code());result.put("info", e.getMessage());restResult = JSONObject.toJSONString(result);logger.error("XxxDutyViewController--->getProviderSysDeal结束:异常"+e.getMessage());return restResult;}logger.info("XxxDutyViewController--->getProviderSysDeal结束:出参"+restResult);return restResult;}/*** 获取应用的告警数据(告警总数和响尾蛇告警)* @param map* @return*/@RequestMapping(value = "/getSysAlarmData",method = RequestMethod.POST)public String getSysAlarmData(@RequestBody Map<String,Object> map){logger.info("XxxDutyViewController--->getSysAlarmData入参:"+map.toString());String restResult = "";try {String url = "http://"+serverRestUrlConfig.getIp_ampalarmquery()+":"+serverRestUrlConfig.getPort_ampalarmquery()+"/"+serverRestUrlConfig.getAmp_alarmquery()+"/getSysAlarmData";logger.info("XxxDutyViewController--->getSysAlarmData地址:"+url);restResult= restTemplate.postForEntity(url, map, String.class).getBody();} catch (Exception e) {// TODO: handle exceptionMap<String, String> result = new HashMap<String, String>();result.put("messageCode", serverRestUrlConfig.getMessage_code());result.put("info", e.getMessage());restResult = JSONObject.toJSONString(result);logger.error("XxxDutyViewController--->getSysAlarmData结束:异常"+e.getMessage());return restResult;}logger.info("XxxDutyViewController--->getSysAlarmData结束:出参"+restResult);return restResult;}/*** 获取应用下的人员信息* @param map* @return*/@RequestMapping(value = "/getSysStaffInfo",method = RequestMethod.POST)public String getSysStaffInfo(@RequestBody Map<String,Object> map){logger.info("XxxDutyViewController--->getSysStaffInfo入参:"+map.toString());String restResult = "";try {String url = "http://"+serverRestUrlConfig.getIp_ampmanage()+":"+serverRestUrlConfig.getPort_ampmanage()+"/"+serverRestUrlConfig.getXxx_manage()+"/getStaffInfoBySysCode";logger.info("AmpDutyViewController--->getSysStaffInfo地址:"+url);restResult= restTemplate.postForEntity(url, map, String.class).getBody();} catch (Exception e) {// TODO: handle exceptionMap<String, String> result = new HashMap<String, String>();result.put("messageCode", serverRestUrlConfig.getMessage_code());result.put("info", e.getMessage());restResult = JSONObject.toJSONString(result);logger.error("XxxDutyViewController--->getSysStaffInfo结束:异常"+e.getMessage());return restResult;}logger.info("XxxDutyViewController--->getSysStaffInfo结束:出参"+restResult);return restResult;}
}
思路:其实就是将原有代码进行了复制粘贴!
其他:
基于内网,GitLab结合Eclipse的使用:
- 项目下载
- 下载项目后,导入工程,利用maven
3.下载更新代码, pull
4.上传修改后的代码,commit