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
9cf1636a
Commit
9cf1636a
authored
Oct 20, 2020
by
Sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 代码规范
parent
e9c9dddf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
59 additions
and
81 deletions
+59
-81
icp-deliver/app/base/api/impl/meta/oss.js
+1
-1
icp-deliver/app/base/controller/impl/common/uploadCtl.js
+5
-3
icp-deliver/app/base/db/cache/CacheLocker.js
+0
-22
icp-deliver/app/base/db/cache/vcodeCache.js
+1
-3
icp-deliver/app/base/db/dao.base.js
+15
-6
icp-deliver/app/base/db/impl/auth/roleDao.js
+2
-2
icp-deliver/app/base/service/impl/auth/orgSve.js
+1
-1
icp-deliver/app/base/system.js
+0
-0
icp-deliver/app/base/utils/redisClient.js
+2
-1
icp-deliver/app/base/utils/restClient.js
+25
-31
icp-deliver/dochelp/imghandle.js
+6
-10
icp-deliver/main.js
+1
-1
No files found.
icp-deliver/app/base/api/impl/meta/oss.js
View file @
9cf1636a
...
@@ -42,7 +42,7 @@ class OSSAPI extends APIBase {
...
@@ -42,7 +42,7 @@ class OSSAPI extends APIBase {
}
}
async
downfile
(
srckey
)
{
async
downfile
(
srckey
)
{
const
oss
=
System
.
getObject
(
'util.ossClient'
);
const
oss
=
System
.
getObject
(
'util.ossClient'
);
le
t
downfile
=
await
oss
.
downfile
(
srckey
).
then
(()
=>
{
cons
t
downfile
=
await
oss
.
downfile
(
srckey
).
then
(()
=>
{
return
`/tmp/
${
srckey
}
`
;
return
`/tmp/
${
srckey
}
`
;
});
});
return
downfile
;
return
downfile
;
...
...
icp-deliver/app/base/controller/impl/common/uploadCtl.js
View file @
9cf1636a
...
@@ -46,7 +46,8 @@ class UploadCtl extends CtlBase {
...
@@ -46,7 +46,8 @@ class UploadCtl extends CtlBase {
}
}
async
downfile
(
srckey
)
{
async
downfile
(
srckey
)
{
const
oss
=
system
.
getObject
(
'util.ossClient'
);
const
oss
=
system
.
getObject
(
'util.ossClient'
);
var
downfile
=
await
oss
.
downfile
(
srckey
).
then
(()
=>
{
let
downfile
;
downfile
=
await
oss
.
downfile
(
srckey
).
then
(()
=>
{
downfile
=
`/tmp/
${
srckey
}
`
;
downfile
=
`/tmp/
${
srckey
}
`
;
return
downfile
;
return
downfile
;
});
});
...
@@ -64,8 +65,9 @@ class UploadCtl extends CtlBase {
...
@@ -64,8 +65,9 @@ class UploadCtl extends CtlBase {
return
result
.
url
;
return
result
.
url
;
}
}
async
insertToFile
(
path
)
{
async
insertToFile
(
path
)
{
const
cmd
=
`
${
this
.
cmdInsertToFilePattern
}
${
path
}
`
;
const
cmd
=
`
${
this
.
cmdInsertToFilePattern
}${
path
}
`
;
return
await
this
.
restS
.
exec
(
cmd
);
const
result
=
await
this
.
restS
.
exec
(
cmd
);
return
result
;
}
}
}
}
module
.
exports
=
UploadCtl
;
module
.
exports
=
UploadCtl
;
icp-deliver/app/base/db/cache/CacheLocker.js
deleted
100644 → 0
View file @
e9c9dddf
const
CacheBase
=
require
(
'../cache.base'
);
const
system
=
require
(
'../../system'
);
// 缓存首次登录的赠送的宝币数量
class
CacheLocker
extends
CacheBase
{
constructor
()
{
super
();
this
.
prefix
=
'locker_'
;
}
async
init
(
tradekey
)
{
const
key
=
this
.
prefix
+
tradekey
;
return
this
.
redisClient
.
rpushWithEx
(
key
,
'1'
,
1800
);
}
async
enter
(
tradekey
)
{
const
key
=
this
.
prefix
+
tradekey
;
return
this
.
redisClient
.
rpop
(
key
);
}
async
release
(
tradekey
)
{
const
key
=
this
.
prefix
+
tradekey
;
return
this
.
redisClient
.
rpushWithEx
(
key
,
'1'
,
1800
);
}
}
module
.
exports
=
CacheLocker
;
icp-deliver/app/base/db/cache/vcodeCache.js
View file @
9cf1636a
...
@@ -24,9 +24,7 @@ class VCodeCache extends CacheBase {
...
@@ -24,9 +24,7 @@ class VCodeCache extends CacheBase {
const
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
const
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
if
(
!
tmplCode
&&
!
signName
)
{
if
(
!
tmplCode
&&
!
signName
)
{
this
.
smsUtil
.
sendMsg
(
mobile
,
vcode
);
this
.
smsUtil
.
sendMsg
(
mobile
,
vcode
);
}
}
else
{
// tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else
{
this
.
smsUtil
.
aliSendMsg
(
mobile
,
tmplCode
,
signName
,
JSON
.
stringify
({
code
:
vcode
}));
this
.
smsUtil
.
aliSendMsg
(
mobile
,
tmplCode
,
signName
,
JSON
.
stringify
({
code
:
vcode
}));
}
}
return
JSON
.
stringify
({
vcode
});
return
JSON
.
stringify
({
vcode
});
...
...
icp-deliver/app/base/db/dao.base.js
View file @
9cf1636a
...
@@ -48,9 +48,13 @@ class Dao {
...
@@ -48,9 +48,13 @@ class Dao {
const
en
=
null
;
const
en
=
null
;
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
whereParam
.
transaction
=
t
;
whereParam
.
transaction
=
t
;
return
await
this
.
model
.
destroy
(
whereParam
);
const
result
=
await
this
.
model
.
destroy
(
whereParam
);
return
result
}
}
return
await
this
.
model
.
destroy
(
whereParam
);
const
result
=
await
this
.
model
.
destroy
(
whereParam
);
return
result
}
}
async
delete
(
qobj
,
t
)
{
async
delete
(
qobj
,
t
)
{
let
en
=
null
;
let
en
=
null
;
...
@@ -177,9 +181,12 @@ class Dao {
...
@@ -177,9 +181,12 @@ class Dao {
}
}
async
bulkCreate
(
ids
,
t
)
{
async
bulkCreate
(
ids
,
t
)
{
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
return
await
this
.
model
.
bulkCreate
(
ids
,
{
transaction
:
t
});
const
result
=
await
this
.
model
.
bulkCreate
(
ids
,
{
transaction
:
t
});
return
result
;
}
}
return
await
this
.
model
.
bulkCreate
(
ids
);
const
result
=
await
this
.
model
.
bulkCreate
(
ids
);
return
result
;
}
}
async
updateByWhere
(
setObj
,
whereObj
,
t
)
{
async
updateByWhere
(
setObj
,
whereObj
,
t
)
{
...
@@ -200,7 +207,7 @@ class Dao {
...
@@ -200,7 +207,7 @@ class Dao {
return
this
.
db
.
query
(
sql
,
paras
);
return
this
.
db
.
query
(
sql
,
paras
);
}
}
async
customQuery
(
sql
,
paras
,
t
)
{
async
customQuery
(
sql
,
paras
,
t
)
{
let
tmpParas
=
null
;
// ||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT };
let
tmpParas
=
null
;
if
(
t
&&
t
!=
'undefined'
)
{
if
(
t
&&
t
!=
'undefined'
)
{
if
(
paras
==
null
||
paras
==
'undefined'
)
{
if
(
paras
==
null
||
paras
==
'undefined'
)
{
tmpParas
=
{
type
:
this
.
db
.
QueryTypes
.
SELECT
};
tmpParas
=
{
type
:
this
.
db
.
QueryTypes
.
SELECT
};
...
@@ -239,7 +246,9 @@ class Dao {
...
@@ -239,7 +246,9 @@ class Dao {
}
else
{
}
else
{
tmpWhere
.
raw
=
true
;
tmpWhere
.
raw
=
true
;
}
}
return
await
this
.
model
.
findAndCountAll
(
tmpWhere
);
const
result
=
await
this
.
model
.
findAndCountAll
(
tmpWhere
);
return
result
;
}
}
async
findOne
(
obj
,
attributes
=
[])
{
async
findOne
(
obj
,
attributes
=
[])
{
if
(
attributes
.
length
>
0
)
{
if
(
attributes
.
length
>
0
)
{
...
...
icp-deliver/app/base/db/impl/auth/roleDao.js
View file @
9cf1636a
...
@@ -38,10 +38,10 @@ class RoleDao extends Dao {
...
@@ -38,10 +38,10 @@ class RoleDao extends Dao {
const
self
=
this
;
const
self
=
this
;
const
u2
=
await
this
.
preCreate
(
u
);
const
u2
=
await
this
.
preCreate
(
u
);
if
(
t
)
{
if
(
t
)
{
le
t
role
=
await
this
.
model
.
create
(
u2
,
{
transaction
:
t
});
cons
t
role
=
await
this
.
model
.
create
(
u2
,
{
transaction
:
t
});
return
role
;
return
role
;
}
else
{
}
else
{
le
t
role
=
await
this
.
model
.
create
(
u2
);
cons
t
role
=
await
this
.
model
.
create
(
u2
);
return
role
;
return
role
;
}
}
}
}
...
...
icp-deliver/app/base/service/impl/auth/orgSve.js
View file @
9cf1636a
...
@@ -55,7 +55,7 @@ class OrgService extends ServiceBase {
...
@@ -55,7 +55,7 @@ class OrgService extends ServiceBase {
const
roles
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
p
.
Roles
}
}
});
const
roles
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
p
.
Roles
}
}
});
await
orgupdate
.
setRoles
(
roles
,
{
transaction
:
t
});
await
orgupdate
.
setRoles
(
roles
,
{
transaction
:
t
});
// 同时要给这个岗位下的user,更新角色 todo
// 同时要给这个岗位下的user,更新角色 todo
for
(
le
t
ud
of
usersupdate
)
{
for
(
cons
t
ud
of
usersupdate
)
{
await
ud
.
setRoles
(
roles
,
{
transaction
:
t
});
await
ud
.
setRoles
(
roles
,
{
transaction
:
t
});
}
}
}
}
...
...
icp-deliver/app/base/system.js
View file @
9cf1636a
This diff is collapsed.
Click to expand it.
icp-deliver/app/base/utils/redisClient.js
View file @
9cf1636a
...
@@ -248,7 +248,8 @@ module.exports = RedisClient;
...
@@ -248,7 +248,8 @@ module.exports = RedisClient;
// client.sismember("h","ok").then(function(r){
// client.sismember("h","ok").then(function(r){
// console.log(r);
// console.log(r);
// });
// });
// console.dir(client);ti.exec( callback )回调函数参数err:返回null或者Array,出错则返回对应命令序列链中发生错误的错误信息,这个数组中最后一个元素是源自exec本身的一个EXECABORT类型的错误
// console.dir(client);ti.exec( callback )
//回调函数参数err:返回null或者Array,出错则返回对应命令序列链中发生错误的错误信息,这个数组中最后一个元素是源自exec本身的一个EXECABORT类型的错误
// r.set("hello","oooo").then(function(result){
// r.set("hello","oooo").then(function(result){
// console.log(result);
// console.log(result);
// });
// });
...
...
icp-deliver/app/base/utils/restClient.js
View file @
9cf1636a
...
@@ -10,52 +10,46 @@ class RestClient {
...
@@ -10,52 +10,46 @@ class RestClient {
this
.
cmdDownLoadFilePattern
=
'curl -G -o {fileName} {url}'
;
this
.
cmdDownLoadFilePattern
=
'curl -G -o {fileName} {url}'
;
this
.
cmdPostPattern2
=
'curl -k -H
\'
Content-type: application/x-www-form-urlencoded
\'
-d
\'
{data}
\'
{url}'
;
this
.
cmdPostPattern2
=
'curl -k -H
\'
Content-type: application/x-www-form-urlencoded
\'
-d
\'
{data}
\'
{url}'
;
this
.
cmdPostPatternWithAK
=
'curl -k -H
\'
Content-type: application/json
\'
-H
\'
AccessKey:{ak}
\'
-d
\'
{data}
\'
{url}'
;
this
.
cmdPostPatternWithAK
=
'curl -k -H
\'
Content-type: application/json
\'
-H
\'
AccessKey:{ak}
\'
-d
\'
{data}
\'
{url}'
;
// 云帐户
// this.cmdPostPattern3="curl -k -H 'Content-type: application/x-www-form-urlencoded' -H 'dealer-id:"+settings.apiconfig.yunzhanghuDealer_id()+"' -H 'request-id:"+parseInt(Date.now() / 1000)+"_gsb"+"' -d '{data}' {url}";
// this.cmdGetPattern3 = "curl {-G} -k {url} --header 'dealer-id:"+settings.apiconfig.yunzhanghuDealer_id()+"'";
// e签宝
// this.cmdPostPattern4="curl -k -H 'Content-type: application/json' -H 'X-Tsign-Open-App-Id:"+settings.apiconfig.eSignBaoAppId()+"' -H 'X-Tsign-Open-App-Secret:"+settings.apiconfig.eSignBaoAppKey()+"' -d '{data}' {url}";
// form-data形式post data参数类型 md5=2&data=1
// form-data形式post data参数类型 md5=2&data=1
this
.
cmdPostPattern5
=
'curl -k --data
\'
{data}
\'
{url}'
;
this
.
cmdPostPattern5
=
'curl -k --data
\'
{data}
\'
{url}'
;
}
}
FetchGetCmd
(
subData
,
url
)
{
FetchGetCmd
(
subData
,
url
)
{
const
cmd
=
this
.
cmdGetPattern
.
replace
(
/
\{\-
G
\}
/g
,
'-G'
).
replace
(
/
\{
data
\}
/g
,
subData
)
const
cmd
=
this
.
cmdGetPattern
.
replace
(
/
\{\-
G
\}
/g
,
'-G'
).
replace
(
/
\{
data
\}
/g
,
subData
)
.
replace
(
/
\{
url
\}
/g
,
url
);
.
replace
(
/
\{
url
\}
/g
,
url
);
return
cmd
;
return
cmd
;
}
}
FetchPostCmd
(
subData
,
url
)
{
FetchPostCmd
(
subData
,
url
)
{
const
data
=
JSON
.
stringify
(
subData
);
const
data
=
JSON
.
stringify
(
subData
);
const
cmd
=
this
.
cmdPostPattern
.
replace
(
const
cmd
=
this
.
cmdPostPattern
.
replace
(
/
\{
data
\}
/g
,
/
\{
data
\}
/g
,
data
,
data
,
).
replace
(
/
\{
url
\}
/g
,
url
);
).
replace
(
/
\{
url
\}
/g
,
url
);
return
cmd
;
return
cmd
;
}
}
FetchPostCmdWithAK
(
subData
,
url
,
acck
)
{
FetchPostCmdWithAK
(
subData
,
url
,
acck
)
{
const
data
=
JSON
.
stringify
(
subData
);
const
data
=
JSON
.
stringify
(
subData
);
const
cmd
=
this
.
cmdPostPatternWithAK
.
replace
(
const
cmd
=
this
.
cmdPostPatternWithAK
.
replace
(
/
\{
data
\}
/g
,
/
\{
data
\}
/g
,
data
,
data
,
).
replace
(
/
\{
url
\}
/g
,
url
)
).
replace
(
/
\{
url
\}
/g
,
url
)
.
replace
(
/
\{
ak
\}
/g
,
acck
);
.
replace
(
/
\{
ak
\}
/g
,
acck
);
return
cmd
;
return
cmd
;
}
}
FetchPostCmd2
(
subData
,
url
)
{
FetchPostCmd2
(
subData
,
url
)
{
const
data
=
subData
;
const
data
=
subData
;
const
cmd
=
this
.
cmdPostPattern2
.
replace
(
const
cmd
=
this
.
cmdPostPattern2
.
replace
(
/
\{
data
\}
/g
,
/
\{
data
\}
/g
,
data
,
data
,
).
replace
(
/
\{
url
\}
/g
,
url
);
).
replace
(
/
\{
url
\}
/g
,
url
);
return
cmd
;
return
cmd
;
}
}
FetchPostCmd3
(
subData
,
url
)
{
FetchPostCmd3
(
subData
,
url
)
{
const
data
=
subData
;
const
data
=
subData
;
const
cmd
=
this
.
cmdPostPattern3
.
replace
(
const
cmd
=
this
.
cmdPostPattern3
.
replace
(
/
\{
data
\}
/g
,
/
\{
data
\}
/g
,
data
,
data
,
).
replace
(
/
\{
url
\}
/g
,
url
);
).
replace
(
/
\{
url
\}
/g
,
url
);
return
cmd
;
return
cmd
;
}
}
FetchGetCmd3
(
url
)
{
FetchGetCmd3
(
url
)
{
const
cmd
=
this
.
cmdGetPattern3
.
replace
(
/
\{\-
G
\}
/g
,
'-G'
).
replace
(
/
\{
url
\}
/g
,
url
);
const
cmd
=
this
.
cmdGetPattern3
.
replace
(
/
\{\-
G
\}
/g
,
'-G'
).
replace
(
/
\{
url
\}
/g
,
url
);
...
@@ -78,10 +72,10 @@ class RestClient {
...
@@ -78,10 +72,10 @@ class RestClient {
return
cmd
;
return
cmd
;
}
}
FetchDownLoadCmd
(
outfname
,
url
)
{
FetchDownLoadCmd
(
outfname
,
url
)
{
// console.log(this.cmdPattern);
// console.log(this.cmdPattern);
const
cmd
=
this
.
cmdDownLoadFilePattern
.
replace
(
/
\{
fileName
\}
/g
,
outfname
).
replace
(
/
\{
url
\}
/g
,
url
);
const
cmd
=
this
.
cmdDownLoadFilePattern
.
replace
(
/
\{
fileName
\}
/g
,
outfname
).
replace
(
/
\{
url
\}
/g
,
url
);
return
cmd
;
return
cmd
;
}
}
async
exec
(
cmd
)
{
async
exec
(
cmd
)
{
// await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
// await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
// 异常需要try/catch自己捕获或外部catch捕获
// 异常需要try/catch自己捕获或外部catch捕获
...
...
icp-deliver/dochelp/imghandle.js
View file @
9cf1636a
const
fs
=
require
(
'fs'
);
const
fs
=
require
(
'fs'
);
// function to encode file data to base64 encoded string
// function to encode file data to base64 encoded string
function
base64
_e
ncode
(
file
)
{
function
base64
E
ncode
(
file
)
{
// read binary data
// read binary data
const
bitmap
=
fs
.
readFileSync
(
"./imgs/sp.png"
);
const
bitmap
=
fs
.
readFileSync
(
"./imgs/sp.png"
);
// convert binary data to base64 encoded string
// convert binary data to base64 encoded string
...
@@ -10,8 +10,7 @@ function base64_encode(file) {
...
@@ -10,8 +10,7 @@ function base64_encode(file) {
}
}
// function to create file from base64 encoded string
// function to create file from base64 encoded string
function
base64_decode
(
base64str
,
file
)
{
function
base64Decode
(
base64str
,
file
)
{
// create buffer object from base64 encoded string, it is important to tell the constructor that the string is base64 encoded
const
bitmap
=
new
Buffer
(
base64str
,
'base64'
);
const
bitmap
=
new
Buffer
(
base64str
,
'base64'
);
// write buffer to file
// write buffer to file
fs
.
writeFileSync
(
file
,
bitmap
);
fs
.
writeFileSync
(
file
,
bitmap
);
...
@@ -19,7 +18,7 @@ function base64_decode(base64str, file) {
...
@@ -19,7 +18,7 @@ function base64_decode(base64str, file) {
}
}
function
getDataUrl
(
filepath
)
{
function
getDataUrl
(
filepath
)
{
const
str
=
base64
_e
ncode
(
filepath
);
const
str
=
base64
E
ncode
(
filepath
);
let
mime
=
""
;
let
mime
=
""
;
if
(
filepath
.
indexOf
(
"png"
)
>=
0
)
{
if
(
filepath
.
indexOf
(
"png"
)
>=
0
)
{
mime
=
"image/png"
;
mime
=
"image/png"
;
...
@@ -30,9 +29,6 @@ function getDataUrl(filepath) {
...
@@ -30,9 +29,6 @@ function getDataUrl(filepath) {
if
(
filepath
.
indexOf
(
"gif"
)
>=
0
)
{
if
(
filepath
.
indexOf
(
"gif"
)
>=
0
)
{
mime
=
"image/gif"
;
mime
=
"image/gif"
;
}
}
const
dataurl
=
`data:
${
mime
}
;base64,
`
+
str
;
const
dataurl
=
`data:
${
mime
}
;base64,
${
str
}
`
;
return
dataurl
;
return
dataurl
;
}
}
\ No newline at end of file
const
str
=
getDataUrl
(
"./imgs/sp.png"
);
console
.
log
(
str
);
\ No newline at end of file
icp-deliver/main.js
View file @
9cf1636a
...
@@ -29,6 +29,6 @@ environment(app);//初始化环境
...
@@ -29,6 +29,6 @@ environment(app);//初始化环境
const
server
=
http
.
createServer
(
app
);
const
server
=
http
.
createServer
(
app
);
//const socketServer = new SocketServer(server);
//const socketServer = new SocketServer(server);
server
.
listen
(
setttings
.
port
,
function
()
{
server
.
listen
(
setttings
.
port
,
function
()
{
console
.
log
(
'Express server listening on port '
+
app
.
get
(
'port'
)
);
console
.
log
(
`Express server listening on port
${
app
.
get
(
'port'
)}
`
);
});
});
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