Commit 052b0cb2 by Guojunfeng

对接云天励飞接口-获取指定id的图片、人脸信息、根据小图获取大图

parent 25875f0b
package com.founder.ytlf.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.founder.commonutils.publicEntity.MapRestResult;
import com.founder.commonutils.util.HttpClient;
import com.founder.commonutils.util.TokenUtils;
import com.founder.servicebase.logs.OperLog;
import com.founder.servicebase.logs.OperationType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* 云天接口管理 前端控制器
......@@ -30,5 +38,79 @@ public class YtlfController {
String accessToken = TokenUtils.getYtgsToken();
return MapRestResult.build(202,"成功获取token信息",accessToken);
}
@OperLog(message = "根据id获取图片信息",operation = OperationType.QUERY)
@ApiOperation(value = "根据id获取图片信息")
@GetMapping("/getPicById/{id}")
public MapRestResult getPicById_yunTian(@PathVariable String id){
try {
String ytToken = TokenUtils.getYtgsToken();
//url应该写在配置文件中
String url = "http://26.3.12.56:8083/api/intellif/image/" + id;
CloseableHttpClient httpClient = HttpClients.createDefault();
String auth = "Bearer " + ytToken;
String result = "";
Map<String,String> header = new HashMap<>();
header.put("Authorization",auth);
try {
result = HttpClient.doGet(url,header,null);
} catch (Exception e) {
e.printStackTrace();
}
//JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"查询结果为",result);
} catch (Exception e) {
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
@OperLog(message = "获取指定id的人脸信息",operation = OperationType.QUERY)
@ApiOperation(value = "获取指定id的人脸信息")
@GetMapping("/getFaceByFaceId/{FaceId}")
public MapRestResult getFaceByFaceId(@PathVariable Long FaceId){
try{
String accessToken = TokenUtils.getYtgsToken();
String url = "http://26.3.12.56:8083/api/intellif/face/"+FaceId;
String Authorization = "Bearer "+accessToken;
Map header = new HashMap<String,String>();
header.put("Authorization",Authorization);
String result = null;
try {
result = HttpClient.doGet(url,header,null);
}catch (Exception e){
e.printStackTrace();
}
JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"成功获取指定id的人脸信息",jsonObject);
}catch (Exception e){
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
@OperLog(message = "根据小图获取大图信息",operation = OperationType.QUERY)
@ApiOperation(value = "根据小图获取大图信息")
@GetMapping("/getImageByFaceId/{FaceId}")
public MapRestResult getImageByFaceId(@PathVariable Long FaceId){
try{
String accessToken = TokenUtils.getYtgsToken();
String url = "http://26.3.12.56:8083/api/intellif/image/face/"+FaceId;
String Authorization = "Bearer "+accessToken;
Map header = new HashMap<String,String>();
header.put("Authorization",Authorization);
String result = null;
try {
result = HttpClient.doGet(url,header,null);
}catch (Exception e){
e.printStackTrace();
}
JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"成功根据小图获取大图信息",jsonObject);
}catch (Exception e){
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment