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
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
34 additions
and
56 deletions
+34
-56
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
+1
-1
icp-deliver/app/base/utils/redisClient.js
+2
-1
icp-deliver/app/base/utils/restClient.js
+0
-6
icp-deliver/dochelp/imghandle.js
+5
-9
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 {
}
async
downfile
(
srckey
)
{
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
downfile
;
...
...
icp-deliver/app/base/controller/impl/common/uploadCtl.js
View file @
9cf1636a
...
...
@@ -46,7 +46,8 @@ class UploadCtl extends CtlBase {
}
async
downfile
(
srckey
)
{
const
oss
=
system
.
getObject
(
'util.ossClient'
);
var
downfile
=
await
oss
.
downfile
(
srckey
).
then
(()
=>
{
let
downfile
;
downfile
=
await
oss
.
downfile
(
srckey
).
then
(()
=>
{
downfile
=
`/tmp/
${
srckey
}
`
;
return
downfile
;
});
...
...
@@ -64,8 +65,9 @@ class UploadCtl extends CtlBase {
return
result
.
url
;
}
async
insertToFile
(
path
)
{
const
cmd
=
`
${
this
.
cmdInsertToFilePattern
}
${
path
}
`
;
return
await
this
.
restS
.
exec
(
cmd
);
const
cmd
=
`
${
this
.
cmdInsertToFilePattern
}${
path
}
`
;
const
result
=
await
this
.
restS
.
exec
(
cmd
);
return
result
;
}
}
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 {
const
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
if
(
!
tmplCode
&&
!
signName
)
{
this
.
smsUtil
.
sendMsg
(
mobile
,
vcode
);
}
// tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else
{
}
else
{
this
.
smsUtil
.
aliSendMsg
(
mobile
,
tmplCode
,
signName
,
JSON
.
stringify
({
code
:
vcode
}));
}
return
JSON
.
stringify
({
vcode
});
...
...
icp-deliver/app/base/db/dao.base.js
View file @
9cf1636a
...
...
@@ -48,9 +48,13 @@ class Dao {
const
en
=
null
;
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
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
)
{
let
en
=
null
;
...
...
@@ -177,9 +181,12 @@ class Dao {
}
async
bulkCreate
(
ids
,
t
)
{
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
)
{
...
...
@@ -200,7 +207,7 @@ class Dao {
return
this
.
db
.
query
(
sql
,
paras
);
}
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
(
paras
==
null
||
paras
==
'undefined'
)
{
tmpParas
=
{
type
:
this
.
db
.
QueryTypes
.
SELECT
};
...
...
@@ -239,7 +246,9 @@ class Dao {
}
else
{
tmpWhere
.
raw
=
true
;
}
return
await
this
.
model
.
findAndCountAll
(
tmpWhere
);
const
result
=
await
this
.
model
.
findAndCountAll
(
tmpWhere
);
return
result
;
}
async
findOne
(
obj
,
attributes
=
[])
{
if
(
attributes
.
length
>
0
)
{
...
...
icp-deliver/app/base/db/impl/auth/roleDao.js
View file @
9cf1636a
...
...
@@ -38,10 +38,10 @@ class RoleDao extends Dao {
const
self
=
this
;
const
u2
=
await
this
.
preCreate
(
u
);
if
(
t
)
{
le
t
role
=
await
this
.
model
.
create
(
u2
,
{
transaction
:
t
});
cons
t
role
=
await
this
.
model
.
create
(
u2
,
{
transaction
:
t
});
return
role
;
}
else
{
le
t
role
=
await
this
.
model
.
create
(
u2
);
cons
t
role
=
await
this
.
model
.
create
(
u2
);
return
role
;
}
}
...
...
icp-deliver/app/base/service/impl/auth/orgSve.js
View file @
9cf1636a
...
...
@@ -55,7 +55,7 @@ class OrgService extends ServiceBase {
const
roles
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
p
.
Roles
}
}
});
await
orgupdate
.
setRoles
(
roles
,
{
transaction
:
t
});
// 同时要给这个岗位下的user,更新角色 todo
for
(
le
t
ud
of
usersupdate
)
{
for
(
cons
t
ud
of
usersupdate
)
{
await
ud
.
setRoles
(
roles
,
{
transaction
:
t
});
}
}
...
...
icp-deliver/app/base/system.js
View file @
9cf1636a
...
...
@@ -255,7 +255,7 @@ class System {
return
x
[
0
];
}
return
'localhost'
;
};
}
/**
...
...
icp-deliver/app/base/utils/redisClient.js
View file @
9cf1636a
...
...
@@ -248,7 +248,8 @@ module.exports = RedisClient;
// client.sismember("h","ok").then(function(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){
// console.log(result);
// });
...
...
icp-deliver/app/base/utils/restClient.js
View file @
9cf1636a
...
...
@@ -10,12 +10,6 @@ class RestClient {
this
.
cmdDownLoadFilePattern
=
'curl -G -o {fileName} {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.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
this
.
cmdPostPattern5
=
'curl -k --data
\'
{data}
\'
{url}'
;
}
...
...
icp-deliver/dochelp/imghandle.js
View file @
9cf1636a
const
fs
=
require
(
'fs'
);
// function to encode file data to base64 encoded string
function
base64
_e
ncode
(
file
)
{
function
base64
E
ncode
(
file
)
{
// read binary data
const
bitmap
=
fs
.
readFileSync
(
"./imgs/sp.png"
);
// convert binary data to base64 encoded string
...
...
@@ -10,8 +10,7 @@ function base64_encode(file) {
}
// function to create file from base64 encoded string
function
base64_decode
(
base64str
,
file
)
{
// create buffer object from base64 encoded string, it is important to tell the constructor that the string is base64 encoded
function
base64Decode
(
base64str
,
file
)
{
const
bitmap
=
new
Buffer
(
base64str
,
'base64'
);
// write buffer to file
fs
.
writeFileSync
(
file
,
bitmap
);
...
...
@@ -19,7 +18,7 @@ function base64_decode(base64str, file) {
}
function
getDataUrl
(
filepath
)
{
const
str
=
base64
_e
ncode
(
filepath
);
const
str
=
base64
E
ncode
(
filepath
);
let
mime
=
""
;
if
(
filepath
.
indexOf
(
"png"
)
>=
0
)
{
mime
=
"image/png"
;
...
...
@@ -30,9 +29,6 @@ function getDataUrl(filepath) {
if
(
filepath
.
indexOf
(
"gif"
)
>=
0
)
{
mime
=
"image/gif"
;
}
const
dataurl
=
`data:
${
mime
}
;base64,
`
+
str
;
const
dataurl
=
`data:
${
mime
}
;base64,
${
str
}
`
;
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);//初始化环境
const
server
=
http
.
createServer
(
app
);
//const socketServer = new SocketServer(server);
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