Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
map-parent
Commits
052b0cb2
Commit
052b0cb2
authored
Mar 19, 2021
by
Guojunfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接云天励飞接口-获取指定id的图片、人脸信息、根据小图获取大图
parent
25875f0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
serviceapi/imageapi/src/main/java/com/founder/ytlf/controller/YtlfController.java
+82
-0
No files found.
serviceapi/imageapi/src/main/java/com/founder/ytlf/controller/YtlfController.java
View file @
052b0cb2
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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment