Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
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
wmvm
ts-api-demo
Commits
b2a5f4da
Commit
b2a5f4da
authored
Jan 03, 2025
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产管理后台-oss 修改
parent
be44fd95
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
34 deletions
+21
-34
mUserRealName.service.ts
src/functional/mvc/service/mUserRealName.service.ts
+4
-4
OSSUtils.ts
src/utils/OSSUtils.ts
+17
-30
No files found.
src/functional/mvc/service/mUserRealName.service.ts
View file @
b2a5f4da
...
...
@@ -298,7 +298,7 @@ async function updateImageUrl(dbRealNameInfo: any) {
let
identityFrondSide
=
dbRealNameInfo
.
identity_frond_side
;
if
(
identityFrondSide
)
{
if
(
!
identityFrondSide
.
includes
(
"http"
))
{
dbRealNameInfo
.
identity_frond_side_small
=
await
ossUtils
.
resizeWithWaterMark
(
identityFrondSide
,
"KTX"
,
3
00
);
dbRealNameInfo
.
identity_frond_side_small
=
await
ossUtils
.
resizeWithWaterMark
(
identityFrondSide
,
"KTX"
,
2
00
);
dbRealNameInfo
.
identity_frond_side
=
await
ossUtils
.
withWaterMark
(
identityFrondSide
,
"KTX"
);
}
else
{
...
...
@@ -313,7 +313,7 @@ async function updateImageUrl(dbRealNameInfo: any) {
let
identityOtherSide
=
dbRealNameInfo
.
identity_other_side
;
if
(
identityOtherSide
)
{
if
(
!
identityOtherSide
.
includes
(
"http"
))
{
dbRealNameInfo
.
identity_other_side_small
=
await
ossUtils
.
resizeWithWaterMark
(
identityOtherSide
,
"KTX"
,
3
00
);
dbRealNameInfo
.
identity_other_side_small
=
await
ossUtils
.
resizeWithWaterMark
(
identityOtherSide
,
"KTX"
,
2
00
);
dbRealNameInfo
.
identity_other_side
=
await
ossUtils
.
withWaterMark
(
identityOtherSide
,
"KTX"
);
}
else
{
...
...
@@ -329,7 +329,7 @@ async function updateImageUrl(dbRealNameInfo: any) {
let
identityInHand
=
dbRealNameInfo
.
identity_in_hand
;
if
(
identityInHand
)
{
if
(
!
identityInHand
.
includes
(
"http"
))
{
dbRealNameInfo
.
identity_in_hand_small
=
await
ossUtils
.
resizeWithWaterMark
(
identityInHand
,
"KTX"
,
3
00
);
dbRealNameInfo
.
identity_in_hand_small
=
await
ossUtils
.
resizeWithWaterMark
(
identityInHand
,
"KTX"
,
2
00
);
dbRealNameInfo
.
identity_in_hand
=
await
ossUtils
.
withWaterMark
(
identityInHand
,
"KTX"
);
}
else
{
...
...
@@ -345,7 +345,7 @@ async function updateImageUrl(dbRealNameInfo: any) {
let
latestPhoto
=
dbRealNameInfo
.
latest_photo
;
if
(
latestPhoto
)
{
if
(
!
latestPhoto
.
includes
(
"http"
))
{
dbRealNameInfo
.
latest_photo_small
=
await
ossUtils
.
resizeWithWaterMark
(
latestPhoto
,
"KTX"
,
3
00
);
dbRealNameInfo
.
latest_photo_small
=
await
ossUtils
.
resizeWithWaterMark
(
latestPhoto
,
"KTX"
,
2
00
);
dbRealNameInfo
.
latest_photo
=
await
ossUtils
.
withWaterMark
(
latestPhoto
,
"KTX"
);
}
else
{
...
...
src/utils/OSSUtils.ts
View file @
b2a5f4da
...
...
@@ -2,38 +2,20 @@ let { ossUtils } = require('@madex/ex-js-common');
let
{
logger
}
=
require
(
'@madex/ex-js-public'
);
const
sizeOf
=
require
(
'image-size'
);
const
axios
=
require
(
"axios"
);
/**
* 获取访问链接
* @param url
*/
export
const
getKycImageUrl
=
async
function
(
url
:
string
)
{
return
await
getSignatureUrl
(
url
)
}
/**
*
获取签名后的图片链接
*
* @param url
* @param style
* @param text
* @param font_size
*/
async
function
getSignatureUrl
(
url
:
string
,
style
?:
string
|
any
)
{
let
res
:
string
|
any
;
let
newUrl
=
url
.
replace
(
/^
\/
+/
,
''
);
if
(
style
)
{
res
=
await
ossUtils
.
getUrlResize
(
newUrl
,
style
);
}
else
{
res
=
await
ossUtils
.
getUrl
(
newUrl
);
}
return
res
;
}
export
const
resizeWithWaterMark
=
async
function
(
url
:
string
,
text
:
string
,
font_size
?:
number
)
{
let
style
=
await
watermarkStyle
(
text
,
font_size
?
font_size
:
60
)
return
await
getSignatureUrl
(
url
,
style
)
;
let
waterUrl
=
await
getWatermarkUrl
(
url
,
text
,
font_size
?
font_size
:
60
)
return
waterUrl
;
}
export
cons
t
getImageWidth
=
async
function
(
urlStr
:
string
)
{
le
t
getImageWidth
=
async
function
(
urlStr
:
string
)
{
try
{
let
response
=
await
axios
({
url
:
urlStr
,
...
...
@@ -51,7 +33,7 @@ export const getImageWidth = async function (urlStr: string) {
}
export
const
withWaterMark
=
async
function
(
url
:
string
,
text
:
string
)
{
let
imgUrl
=
await
getKycImage
Url
(
url
);
let
imgUrl
=
await
ossUtils
.
get
Url
(
url
);
let
imageWidth
=
await
getImageWidth
(
imgUrl
);
if
(
imageWidth
<=
0
)
{
imageWidth
=
1000
;
...
...
@@ -60,15 +42,20 @@ export const withWaterMark = async function (url: string, text: string) {
if
(
fontSize
>
999
)
{
fontSize
=
999
;
}
let
style
=
await
watermarkStyle
(
text
,
fontSize
);
return
await
getSignatureUrl
(
url
,
style
)
;
let
waterUrl
=
await
getWatermarkUrl
(
url
,
text
,
fontSize
);
return
waterUrl
;
}
export
const
watermarkStyle
=
async
function
(
text
:
string
,
font_size
?:
number
)
{
/**
* 获取带水印的图片地址
* @param url url
* @param text 水印文案
* @param size 水印大小
*/
let
getWatermarkUrl
=
async
function
(
url
:
string
,
text
:
string
,
size
?:
number
)
{
let
base64
=
Buffer
.
from
(
text
).
toString
(
'base64'
);
let
textWatermark
=
base64
.
replace
(
"+"
,
"-"
).
replace
(
'/'
,
'_'
).
replace
(
"="
,
""
);
return
"/watermark,text_"
+
textWatermark
+
",g_center,x_10,y_10,t_10,fill_1,color_FFFFFF,size_"
+
font_size
?
font_size
:
""
;
return
ossUtils
.
getUrlWatermark
(
url
,
textWatermark
,
size
)
;
}
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