Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
306f230a
Commit
306f230a
authored
May 09, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
1a3a3fe3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
center-app/app/base/api/impl/auth/accessAuth.js
+6
-0
center-app/app/base/service/impl/utilsSve/utilsappSve.js
+53
-0
No files found.
center-app/app/base/api/impl/auth/accessAuth.js
View file @
306f230a
...
@@ -5,6 +5,12 @@ class AccessAuthAPI extends APIBase {
...
@@ -5,6 +5,12 @@ class AccessAuthAPI extends APIBase {
super
();
super
();
this
.
opPlatformUtils
=
system
.
getObject
(
"util.businessManager.opPlatformUtils"
);
this
.
opPlatformUtils
=
system
.
getObject
(
"util.businessManager.opPlatformUtils"
);
this
.
appmobilemsgSve
=
system
.
getObject
(
"service.dbapp.appmobilemsgSve"
);
this
.
appmobilemsgSve
=
system
.
getObject
(
"service.dbapp.appmobilemsgSve"
);
this
.
utilsappSve
=
system
.
getObject
(
"service.utilsSve.utilsappSve"
);
}
async
getOssInfo
(
pobj
,
qobj
,
req
)
{
//获取oss信息
var
result
=
await
this
.
utilsappSve
.
getAppOssInfo
(
pobj
);
return
result
;
}
}
async
getTokenByHosts
(
pobj
,
qobj
,
req
)
{
async
getTokenByHosts
(
pobj
,
qobj
,
req
)
{
...
...
center-app/app/base/service/impl/utilsSve/utilsappSve.js
0 → 100644
View file @
306f230a
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
AppServiceBase
=
require
(
"../../app.base"
);
const
crypto
=
require
(
"crypto"
);
//商标查询操作
class
UtilsAppSve
extends
AppServiceBase
{
constructor
()
{
super
();
this
.
appDao
=
system
.
getObject
(
"db.dbapp.appDao"
);
}
async
getAppOssInfo
(
pobj
)
{
var
uapp_id
=
Number
(
pobj
.
appInfo
.
uapp_id
||
0
);
var
sql
=
"SSELECT uapp_id,access_key_id,access_key_secret,file_url FROM `p_app_oss` WHERE is_enabled=1 and uapp_id in(:uapp_id)"
;
var
paramWhere
=
{
uapp_id
:
[
uapp_id
,
22
]
};
var
list
=
await
this
.
appDao
(
sql
,
paramWhere
);
if
(
!
list
)
{
return
system
.
getResult
(
null
,
"oss info to data is empty !"
);
}
var
ossIndex
=
list
.
findIndex
(
f
=>
f
.
uapp_id
==
uapp_id
);
if
(
ossIndex
<
0
)
{
ossIndex
=
list
.
findIndex
(
f
=>
f
.
uapp_id
==
22
);
}
if
(
ossIndex
<
0
)
{
return
system
.
getResult
(
null
,
"oss info to data is empty ! ! !"
);
}
var
ossItem
=
list
[
ossIndex
];
var
bucket
=
pobj
.
actionBody
.
bucket
||
"gsb-zc"
;
//oss 桶(即文件目录)
var
end
=
new
Date
().
getTime
()
+
36000000
;
//10小时-毫秒
var
expiration
=
new
Date
(
end
).
toISOString
()
var
policyText
=
{
"expiration"
:
expiration
,
"conditions"
:
[
[
"content-length-range"
,
0
,
1048576000
],
[
"starts-with"
,
"$key"
,
"zc"
]
]
};
var
b
=
new
Buffer
(
JSON
.
stringify
(
policyText
));
var
policyBase64
=
b
.
toString
(
'base64'
);
var
signature
=
crypto
.
createHmac
(
'sha1'
,
ossItem
.
access_key_secret
).
update
(
policyBase64
).
digest
().
toString
(
'base64'
);
//base64
var
data
=
{
OSSAccessKeyId
:
ossItem
.
access_key_id
,
policy
:
policyBase64
,
Signature
:
signature
,
Bucket
:
bucket
,
success_action_status
:
201
,
url
:
ossItem
.
file_url
};
return
system
.
getResultSuccess
(
data
);
}
}
module
.
exports
=
UtilsAppSve
;
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