Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jyzb_local_platform
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
赵剑炜
jyzb_local_platform
Commits
902183f3
Commit
902183f3
authored
Oct 16, 2023
by
Seniorious
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增图片下载接口
parent
6be37453
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
78 行增加
和
2 行删除
+78
-2
BaseInfoController.cs
WebApiNET6-master/APIs/Controllers/BaseInfoController.cs
+66
-2
PictureReq.cs
WebApiNET6-master/APIs/Req/PictureReq.cs
+10
-0
Police.cs
WebApiNET6-master/Models/Table/Police.cs
+2
-0
没有找到文件。
WebApiNET6-master/APIs/Controllers/BaseInfoController.cs
View file @
902183f3
...
@@ -40,6 +40,62 @@ namespace APIs.Controllers
...
@@ -40,6 +40,62 @@ namespace APIs.Controllers
}
}
/// <summary>
/// <summary>
/// 人员照片下载
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
ApiResult
>
DownloadPicture
([
FromForm
]
DownloadPicReq
req
)
{
try
{
var
pic
=
await
_policeService
.
QueryOne
(
p
=>
!
string
.
IsNullOrEmpty
(
p
.
picUrl
)
&&
p
.
picUrl
.
Equals
(
req
.
picUrl
));
//不存在
if
(
pic
==
null
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"照片不存在"
,
};
return
error
;
}
//读取图片
byte
[]
imageBytes
;
string
url
=
pic
.
picUrl
;
using
(
FileStream
fileStream
=
new
FileStream
(
url
,
FileMode
.
Open
))
{
using
(
BinaryReader
reader
=
new
BinaryReader
(
fileStream
))
{
imageBytes
=
reader
.
ReadBytes
((
int
)
fileStream
.
Length
);
}
}
var
res
=
new
DownloadPicRes
()
{
picture
=
imageBytes
};
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
res
};
return
src
;
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
error
;
}
}
/// <summary>
/// 人员照片上传
/// 人员照片上传
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
...
@@ -82,13 +138,16 @@ namespace APIs.Controllers
...
@@ -82,13 +138,16 @@ namespace APIs.Controllers
//更新警员照片地址
//更新警员照片地址
police
.
picUrl
=
filePath
;
police
.
picUrl
=
filePath
;
police
.
updateTime
=
DateTime
.
Now
;
police
.
updateTime
=
DateTime
.
Now
;
police
.
picUpdateTime
=
police
.
updateTime
;
bool
rs
=
await
_policeService
.
Update
(
police
);
bool
rs
=
await
_policeService
.
Update
(
police
);
var
reply
=
new
UploadPictureReply
()
{
picUrl
=
filePath
,
updateTime
=
(
DateTime
)
police
.
picUpdateTime
};
var
src
=
rs
?
new
ApiResult
var
src
=
rs
?
new
ApiResult
{
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
filePath
data
=
reply
}
:
new
ApiResult
}
:
new
ApiResult
{
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
...
@@ -105,11 +164,16 @@ namespace APIs.Controllers
...
@@ -105,11 +164,16 @@ namespace APIs.Controllers
{
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
msg
=
ex
.
Message
,
};
};
return
error
;
return
error
;
}
}
}
}
class
UploadPictureReply
{
public
string
picUrl
{
get
;
set
;
}
public
DateTime
updateTime
{
get
;
set
;
}
}
/// <summary>
/// <summary>
/// 新增基础信息
/// 新增基础信息
...
...
WebApiNET6-master/APIs/Req/PictureReq.cs
View file @
902183f3
...
@@ -5,4 +5,14 @@
...
@@ -5,4 +5,14 @@
public
string
policeId
{
get
;
set
;
}
public
string
policeId
{
get
;
set
;
}
public
IFormFile
picture
{
get
;
set
;
}
public
IFormFile
picture
{
get
;
set
;
}
}
}
public
class
DownloadPicReq
{
public
string
picUrl
{
get
;
set
;
}
}
public
class
DownloadPicRes
{
public
byte
[]
picture
{
get
;
set
;
}
}
}
}
WebApiNET6-master/Models/Table/Police.cs
View file @
902183f3
...
@@ -29,5 +29,7 @@ namespace Models.Table
...
@@ -29,5 +29,7 @@ namespace Models.Table
public
String
?
sex
{
get
;
set
;
}
public
String
?
sex
{
get
;
set
;
}
public
String
?
faceInfo
{
get
;
set
;
}
public
String
?
faceInfo
{
get
;
set
;
}
public
String
?
fingerInfo
{
get
;
set
;
}
public
String
?
fingerInfo
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"pic_update_time"
)]
public
DateTime
?
picUpdateTime
{
get
;
set
;
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论