Compare commits
No commits in common. 'c76981e2e26a9d5046f53e93a13e31c5e906613f' and '1b66257c05a1a96fcecea512ef940e4322e6656b' have entirely different histories.
c76981e2e2
...
1b66257c05
@ -1,20 +0,0 @@
|
|||||||
package com.internal.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {
|
|
||||||
* "data": {
|
|
||||||
* "name": "车辆1",
|
|
||||||
* "tid": 685621293,
|
|
||||||
* "sid": 936178
|
|
||||||
* },
|
|
||||||
* "errcode": 10000,
|
|
||||||
* "errdetail": null,
|
|
||||||
* "errmsg": "OK"
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class TerminalResponse {
|
|
||||||
private String tid;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.taxi.servicedriveruser.remote;
|
|
||||||
|
|
||||||
import com.internal.dto.ResponseResult;
|
|
||||||
import com.internal.dto.TerminalResponse;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
@FeignClient("service-map")
|
|
||||||
public interface ServiceMapClient {
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST,value = "/terminal/addTerminal")
|
|
||||||
ResponseResult<TerminalResponse> addTerminal(@RequestParam String name);
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.taxi.servicemap.controller;
|
|
||||||
|
|
||||||
import com.internal.dto.ResponseResult;
|
|
||||||
import com.internal.dto.TerminalResponse;
|
|
||||||
import com.taxi.servicemap.service.TerminalService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/terminal")
|
|
||||||
public class TerminalController {
|
|
||||||
@Autowired
|
|
||||||
TerminalService terminalService;
|
|
||||||
@PostMapping("/addTerminal")
|
|
||||||
public ResponseResult<TerminalResponse> addTerminal(String name){
|
|
||||||
return terminalService.addTerminal(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
package com.taxi.servicemap.remote;
|
|
||||||
|
|
||||||
import com.internal.contant.AmapConfigConstant;
|
|
||||||
import com.internal.dto.ResponseResult;
|
|
||||||
import com.internal.dto.ServiceMapResponse;
|
|
||||||
import com.internal.dto.TerminalResponse;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class TerminalClient {
|
|
||||||
@Value("${amap.key}")
|
|
||||||
private String amapKey;
|
|
||||||
|
|
||||||
@Value("${amap.sid}")
|
|
||||||
private String sid;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RestTemplate restTemplate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {
|
|
||||||
* "code": 1,
|
|
||||||
* "message": "success",
|
|
||||||
* "data": {
|
|
||||||
* "tid": "685651163"
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ResponseResult<TerminalResponse> addTerminal(String name){
|
|
||||||
//拼接请求的URL
|
|
||||||
StringBuilder url = new StringBuilder();
|
|
||||||
url.append(AmapConfigConstant.TERMINAL_MAP_ADD_URL);
|
|
||||||
url.append("?");
|
|
||||||
url.append("key="+amapKey);
|
|
||||||
url.append("&");
|
|
||||||
url.append("sid="+sid);
|
|
||||||
url.append("&");
|
|
||||||
url.append("name="+name);
|
|
||||||
|
|
||||||
ResponseEntity<String> forEntity =
|
|
||||||
restTemplate.postForEntity(url.toString(),null,String.class);
|
|
||||||
String bodyStr = forEntity.getBody();
|
|
||||||
JSONObject result = JSONObject.fromObject(bodyStr);
|
|
||||||
TerminalResponse terminalResponse = new TerminalResponse();
|
|
||||||
/**
|
|
||||||
* {
|
|
||||||
* "data": {
|
|
||||||
* "name": "车辆1",
|
|
||||||
* "tid": 685621293,
|
|
||||||
* "sid": 936178
|
|
||||||
* },
|
|
||||||
* "errcode": 10000,
|
|
||||||
* "errdetail": null,
|
|
||||||
* "errmsg": "OK"
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
if(result.has("data")){
|
|
||||||
JSONObject data = result.getJSONObject("data");
|
|
||||||
if(data != null && data.has("tid")){
|
|
||||||
String sid = data.getString("tid");
|
|
||||||
terminalResponse.setTid(sid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ResponseResult.success(terminalResponse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.taxi.servicemap.service;
|
|
||||||
|
|
||||||
import com.internal.dto.ResponseResult;
|
|
||||||
import com.internal.dto.TerminalResponse;
|
|
||||||
import com.taxi.servicemap.remote.TerminalClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class TerminalService {
|
|
||||||
@Autowired
|
|
||||||
TerminalClient terminalClient;
|
|
||||||
|
|
||||||
public ResponseResult<TerminalResponse> addTerminal(String name){
|
|
||||||
return terminalClient.addTerminal(name);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue