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
d854753d
Commit
d854753d
authored
Oct 27, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
35878bad
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
247 additions
and
78 deletions
+247
-78
center-app/app/base/api/impl/action/opLog.js
+0
-0
center-app/app/base/api/impl/auth/accessAuth.js
+2
-5
center-app/app/base/db/cache.base.js
+8
-0
center-app/app/base/db/cache/appTokenByHostsCache.js
+12
-11
center-app/app/base/db/cache/appUserPinByLoginPwdCache.js
+11
-11
center-app/app/base/db/cache/appUserPinByLoginVcodeCache.js
+12
-16
center-app/app/base/db/cache/vcodeCache.js
+43
-0
center-app/app/base/db/impl/dbapp/appuserDao.js
+30
-0
center-app/app/base/db/models/dbapp/appuser.js
+1
-0
center-app/app/base/system.js
+1
-1
center-app/app/base/utils/businessManager/opPlatformUtils.js
+0
-0
center-app/app/base/utils/smsClient.js
+105
-12
center-app/app/config/settings.js
+22
-22
No files found.
center-app/app/base/api/impl/action/opLog.js
View file @
d854753d
center-app/app/base/api/impl/auth/accessAuth.js
View file @
d854753d
...
...
@@ -25,10 +25,7 @@ class AccessAuthAPI extends APIBase {
var
itemResult
=
await
this
.
appmobilemsgSve
.
getItemByUappId
(
pobj
);
var
result
=
system
.
getResult
(
null
,
"get msg error"
);
if
(
itemResult
.
status
!=
0
)
{
result
=
await
this
.
opPlatformUtils
.
fetchDefaultVCode
(
pobj
.
actionBody
.
mobile
,
pobj
.
appInfo
.
uapp_key
,
pobj
.
appInfo
.
uapp_secret
);
console
.
log
(
"--------------fetchDefaultVCode result start"
)
console
.
log
(
result
);
console
.
log
(
"--------------fetchDefaultVCode result end"
)
result
=
await
this
.
opPlatformUtils
.
fetchDefaultVCode
(
pobj
.
actionBody
.
mobile
,
pobj
.
appInfo
.
uapp_key
);
return
result
;
}
var
param
=
{
...
...
@@ -38,7 +35,7 @@ class AccessAuthAPI extends APIBase {
accessKeyId
:
itemResult
.
data
.
access_key_id
,
accessKeySecret
:
itemResult
.
data
.
access_key_secret
}
result
=
await
this
.
opPlatformUtils
.
fetchOtherVCode
(
param
,
pobj
.
appInfo
.
uapp_key
,
pobj
.
appInfo
.
uapp_secret
);
result
=
await
this
.
opPlatformUtils
.
fetchOtherVCode
(
param
,
pobj
.
appInfo
.
uapp_key
);
return
result
;
}
...
...
center-app/app/base/db/cache.base.js
View file @
d854753d
...
...
@@ -7,6 +7,14 @@ class CacheBase {
this
.
prefix
=
this
.
prefix
();
this
.
cacheCacheKeyPrefix
=
"s_sadd_appkeys:"
+
settings
.
appKey
+
"_cachekey"
;
this
.
isdebug
=
this
.
isdebug
();
this
.
md5
=
require
(
"MD5"
);
}
async
getEncryptStr
(
str
)
{
if
(
!
str
)
{
throw
new
Error
(
"字符串不能为空"
);
}
var
md5
=
this
.
md5
(
str
+
"_"
+
settings
.
salt
);
return
md5
.
toString
().
toLowerCase
();
}
isdebug
()
{
return
false
;
...
...
center-app/app/base/db/cache/appTokenByHostsCache.js
View file @
d854753d
...
...
@@ -14,6 +14,7 @@ class AppTokenByHostsCache extends CacheBase {
prefix
()
{
return
settings
.
cacheprefix
+
"_accesskey:"
;
}
//优化掉从平台中获取应用信息--sy-2020-10-21
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
var
actionBody
=
val
;
if
(
!
actionBody
)
{
...
...
@@ -29,20 +30,20 @@ class AppTokenByHostsCache extends CacheBase {
if
(
!
item
)
{
return
system
.
getResult
(
null
,
"app_hosts to data is empty !"
);
}
if
(
!
item
.
uapp_key
||
!
item
.
uapp_secret
)
{
return
system
.
getResult
(
null
,
"uapp_key or uapp_secret can not be empty !"
);
}
if
(
item
.
is_enabled
!=
1
)
{
return
system
.
getResult
(
null
,
"app_hosts to item is Disable !"
);
}
var
result
=
await
this
.
opPlatformUtils
.
getReqApiAccessKey
(
item
.
uapp_key
,
item
.
uapp_secret
);
if
(
!
result
)
{
return
system
.
getResult
(
null
,
"platform to data is empty !"
);
}
if
(
result
.
status
!=
0
)
{
return
result
;
}
item
.
token
=
result
.
data
.
accessKey
;
// if (!item.uapp_key || !item.uapp_secret) {
// return system.getResult(null, "uapp_key or uapp_secret can not be empty !");
// }
// var result = await this.opPlatformUtils.getReqApiAccessKey(item.uapp_key, item.uapp_secret);
// if (!result) {
// return system.getResult(null, "platform to data is empty !");
// }
// if (result.status != 0) {
// return result;
// }
// item.token = result.data.accessKey;
return
system
.
getResultSuccess
(
item
);
}
}
...
...
center-app/app/base/db/cache/appUserPinByLoginPwdCache.js
View file @
d854753d
...
...
@@ -13,24 +13,24 @@ class AppUserPinByLoginPwdCache extends CacheBase {
prefix
()
{
return
settings
.
cacheprefix
+
"_userPin:"
;
}
//优化掉从平台中获取应用信息--sy-2020-10-21
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
var
actionBody
=
val
.
actionBody
;
var
appInfo
=
val
.
appInfo
;
var
uUserName
=
actionBody
.
userName
;
//uUserName
var
uPassword
=
actionBody
.
password
;
//uPassword
var
uUserInfo
=
await
this
.
opPlatformUtils
.
login
(
uUserName
,
uPassword
,
appInfo
.
uapp_key
,
appInfo
.
uapp_secret
);
if
(
uUserInfo
.
status
!=
0
)
{
return
uUserInfo
;
}
//值为2010为用户名或密码错误
var
userInfo
=
await
this
.
appuserDao
.
getItemBy
ChannelUserId
(
actionBody
.
userName
,
appInfo
.
uapp_id
);
const
actionBody
=
val
.
actionBody
;
const
appInfo
=
val
.
appInfo
;
const
uUserName
=
actionBody
.
userName
;
//uUserName
const
password
=
await
this
.
getEncryptStr
(
actionBody
.
password
)
;
//uPassword
//
var uUserInfo = await this.opPlatformUtils.login(uUserName, uPassword,
//
appInfo.uapp_key, appInfo.uapp_secret);
//
if (uUserInfo.status != 0) {
//
return uUserInfo;
//
}//值为2010为用户名或密码错误
var
userInfo
=
await
this
.
appuserDao
.
getItemBy
Pwd
(
uUserName
,
password
,
appInfo
.
uapp_id
);
if
(
!
userInfo
)
{
return
system
.
getResult
(
null
,
"user to item is empty !"
);
}
if
(
userInfo
.
is_enabled
!=
1
)
{
return
system
.
getResult
(
null
,
"user to item is Disable !"
);
}
userInfo
.
userpin
=
actionBody
.
userpin
;
return
system
.
getResultSuccess
(
userInfo
);
}
}
...
...
center-app/app/base/db/cache/appUserPinByLoginVcodeCache.js
View file @
d854753d
...
...
@@ -14,31 +14,27 @@ class AppUserPinByLoginVcodeCache extends CacheBase {
return
settings
.
cacheprefix
+
"_userPin:"
;
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
var
actionBody
=
val
.
actionBody
;
var
appInfo
=
val
.
appInfo
;
var
uUserInfo
=
await
this
.
opPlatformUtils
.
loginByVCode
(
actionBody
.
mobile
,
actionBody
.
vcode
,
actionBody
.
password
,
appInfo
.
uapp_key
,
appInfo
.
uapp_secret
);
if
(
uUserInfo
.
status
!=
0
)
{
return
uUserInfo
;
}
//2030验证码校验不成功 或 注册失败
var
userInfo
=
await
this
.
appuserDao
.
getItemByChannelUserId
(
actionBody
.
mobile
,
appInfo
.
uapp_id
);
let
actionBody
=
val
.
actionBody
;
let
appInfo
=
val
.
appInfo
;
let
userInfo
=
await
this
.
appuserDao
.
getItemByChannelUserId
(
actionBody
.
mobile
,
appInfo
.
uapp_id
);
if
(
userInfo
)
{
if
(
userInfo
.
is_enabled
!=
1
)
{
return
system
.
getResult
(
null
,
"
user to item is Disable !
"
);
return
system
.
getResult
(
null
,
"
用户未启用
"
);
}
if
(
actionBody
.
reqType
==
"reg"
)
{
return
system
.
getResult
Fail
(
system
.
existUserRegFai
l
,
"已经存在此用户,注册失败"
);
if
(
actionBody
.
reqType
==
=
"reg"
)
{
return
system
.
getResult
(
nul
l
,
"已经存在此用户,注册失败"
);
}
userInfo
.
userpin
=
actionBody
.
userpin
;
return
system
.
getResultSuccess
(
userInfo
);
}
var
params
=
{
const
uPassword
=
await
this
.
getEncryptStr
((
actionBody
.
password
||
actionBody
.
mobile
));
//uPassword
let
params
=
{
uapp_id
:
appInfo
.
uapp_id
,
channel_userid
:
actionBody
.
mobile
||
""
,
channel_username
:
actionBody
.
mobile
||
""
,
channel_nickname
:
actionBody
.
nickName
||
""
,
mobile
:
actionBody
.
mobile
||
""
,
password
:
uPassword
,
org_name
:
actionBody
.
orgName
||
""
,
org_path
:
actionBody
.
orgPath
||
""
,
is_enabled
:
1
,
...
...
@@ -46,8 +42,8 @@ class AppUserPinByLoginVcodeCache extends CacheBase {
last_login_time
:
new
Date
()
};
userInfo
=
await
this
.
appuserDao
.
create
(
params
);
userInfo
.
userpin
=
actionBody
.
userpin
;
return
system
.
getResultSuccess
(
userInfo
);
params
.
password
=
""
;
return
system
.
getResultSuccess
(
params
);
}
}
module
.
exports
=
AppUserPinByLoginVcodeCache
;
center-app/app/base/db/cache/vcodeCache.js
0 → 100644
View file @
d854753d
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
const
settings
=
require
(
"../../../config/settings"
);
//缓存首次登录的赠送的宝币数量
class
VCodeCache
extends
CacheBase
{
constructor
()
{
super
();
this
.
smsUtil
=
system
.
getObject
(
"util.smsClient"
);
}
// isdebug() {
// return settings.env == "dev";
// }
desc
()
{
return
"缓存给手机发送的验证码60妙"
;
}
prefix
()
{
return
settings
.
cacheprefix
+
"g_vcode:appkey_"
;
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
//【XXX】您的验证码是:602639(5分钟内有效),工作人员不会索取,请勿泄露。-------描述在模板中配置
var
params
=
val
;
var
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
if
(
params
&&
params
.
reqType
)
{
switch
(
params
.
reqType
)
{
case
"defaultVcode"
:
const
msg
=
"您的验证码:"
+
vcode
+
",请在60秒输入完成验证,若非本人操作,请勿泄露"
this
.
smsUtil
.
sendDefaultVcodeMsg
(
params
.
mobile
,
msg
);
break
;
case
"defaultOtherVcode"
:
//暂时没有用到
this
.
smsUtil
.
aliSendMsg
(
params
.
mobile
,
params
.
tmplCode
,
params
.
signName
,
JSON
.
stringify
({
code
:
vcode
}));
break
;
case
"otherVcode"
:
this
.
smsUtil
.
aliOtherSendMsg
(
params
.
mobile
,
params
.
accessKeyId
,
params
.
accessKeySecret
,
params
.
tmplCode
,
params
.
signName
,
JSON
.
stringify
({
code
:
vcode
}));
break
;
default
:
break
;
}
}
return
system
.
getResultSuccess
({
vcode
:
vcode
});
}
}
module
.
exports
=
VCodeCache
;
center-app/app/base/db/impl/dbapp/appuserDao.js
View file @
d854753d
...
...
@@ -27,5 +27,35 @@ class AppuserDao extends Dao {
raw
:
true
});
}
/**
* 通过密码进行登录
* @param {*} channel_userid
* @param {*} password
* @param {*} uapp_id
*/
async
getItemByPwd
(
channel_userid
,
password
,
uapp_id
)
{
return
this
.
model
.
findOne
({
where
:
{
channel_userid
:
channel_userid
,
password
:
password
,
uapp_id
:
uapp_id
},
attributes
:
[
"id"
,
"uapp_id"
,
"channel_userid"
,
"channel_username"
,
"channel_nickname"
,
"open_id"
,
"head_url"
,
"mobile"
,
"org_name"
,
"org_path"
,
"email"
,
"is_admin"
,
"is_super"
,
"is_enabled"
],
raw
:
true
});
}
}
module
.
exports
=
AppuserDao
;
center-app/app/base/db/models/dbapp/appuser.js
View file @
d854753d
...
...
@@ -13,6 +13,7 @@ module.exports = (db, DataTypes) => {
org_name
:
DataTypes
.
STRING
(
255
),
org_path
:
DataTypes
.
STRING
(
255
),
email
:
DataTypes
.
STRING
(
50
),
password
:
DataTypes
.
STRING
(
255
),
is_admin
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
,
...
...
center-app/app/base/system.js
View file @
d854753d
...
...
@@ -294,7 +294,7 @@ Date.prototype.Format = function (fmt) { //author: meizz
System
.
exTime
=
4
*
3600
;
//缓存过期时间,4小时
System
.
shortExTime
=
300
;
//
300
System
.
shortExTime
=
300
;
//
缓存过期时间,5分钟
//缓存失效
System
.
cacheInvalidation
=
-
88
;
...
...
center-app/app/base/utils/businessManager/opPlatformUtils.js
View file @
d854753d
This diff is collapsed.
Click to expand it.
center-app/app/base/utils/smsClient.js
View file @
d854753d
const
system
=
require
(
"../system"
);
class
SmsClient
{
constructor
(){
this
.
smsTeml
=
"http://123.57.156.109:4103/api/Send"
;
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
const
system
=
require
(
"../system"
);
const
Core
=
require
(
'@alicloud/pop-core'
);
class
SmsClient
{
constructor
()
{
this
.
smsTeml
=
"http://123.57.156.109:4103/api/Send"
;
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
aliclient
=
new
Core
({
accessKeyId
:
'LTAI4FtNp3wcqFzaADvo1WtZ'
,
accessKeySecret
:
'VBKn1Anx4UmMF0LKNz7PVaCFG1phcg'
,
endpoint
:
'https://dysmsapi.aliyuncs.com'
,
apiVersion
:
'2017-05-25'
});
}
async
sendMsg
(
to
,
content
){
var
txtObj
=
{
"appId"
:
8
,
"mobilePhone"
:
to
,
"content"
:
content
/**
* 公司宝阿里云发送
* @param {*} mobile 手机号
* @param {*} tmplcode 模板编码
* @param {*} signName 短信头签名
* @param {*} jsonContent 内容
*/
async
aliSendMsg
(
mobile
,
tmplcode
,
signName
,
jsonContent
)
{
var
params
=
{
"RegionId"
:
"default"
,
"PhoneNumbers"
:
mobile
,
"SignName"
:
signName
,
"TemplateCode"
:
tmplcode
,
"TemplateParam"
:
jsonContent
}
return
this
.
restClient
.
execPost
(
txtObj
,
this
.
smsTeml
);
var
requestOption
=
{
method
:
'POST'
};
this
.
aliclient
.
request
(
'SendSms'
,
params
,
requestOption
).
then
((
result
)
=>
{
console
.
log
(
JSON
.
stringify
(
result
));
},
(
ex
)
=>
{
console
.
log
(
ex
);
})
}
/**
* 合作方阿里云发送
* @param {*} mobile 手机号
* @param {*} accessKeyId 阿里云key
* @param {*} accessKeySecret 阿里云密钥
* @param {*} tmplcode 模板编码
* @param {*} signName 短信头签名
* @param {*} jsonContent 内容
*/
async
aliOtherSendMsg
(
mobile
,
accessKeyId
,
accessKeySecret
,
tmplcode
,
signName
,
jsonContent
)
{
var
params
=
{
"RegionId"
:
"default"
,
"PhoneNumbers"
:
mobile
,
"SignName"
:
signName
,
"TemplateCode"
:
tmplcode
,
"TemplateParam"
:
jsonContent
};
var
requestOption
=
{
method
:
'POST'
};
var
otherAliclient
=
new
Core
({
accessKeyId
:
accessKeyId
,
accessKeySecret
:
accessKeySecret
,
endpoint
:
'https://dysmsapi.aliyuncs.com'
,
apiVersion
:
'2017-05-25'
});
otherAliclient
.
request
(
'SendSms'
,
params
,
requestOption
).
then
((
result
)
=>
{
console
.
log
(
JSON
.
stringify
(
result
));
},
(
ex
)
=>
{
console
.
log
(
ex
);
});
}
/**
* 公司宝默认的短信发送
* @param {*} mobile 手机号
* @param {*} content 内容
*/
async
sendDefaultVcodeMsg
(
mobile
,
content
)
{
var
txtObj
=
{
"appId"
:
8
,
"mobilePhone"
:
mobile
,
"content"
:
content
}
return
this
.
restClient
.
execPost
(
txtObj
,
this
.
smsTeml
);
}
async
getUidStr
(
len
,
radix
)
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
var
uuid
=
[],
i
;
radix
=
radix
||
chars
.
length
;
if
(
len
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
else
{
var
r
;
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
if
(
!
uuid
[
i
])
{
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
return
uuid
.
join
(
''
);
}
}
module
.
exports
=
SmsClient
;
module
.
exports
=
SmsClient
;
// var sms=new SmsClient();
// sms.aliSendMsg("13381139519","SMS_173946419","iboss",JSON.stringify({code:"hello"}));
center-app/app/config/settings.js
View file @
d854753d
var
path
=
require
(
'path'
);
var
ENVINPUT
=
{
DB_HOST
:
process
.
env
.
DB_HOST
,
DB_PORT
:
process
.
env
.
DB_PORT
,
DB_USER
:
process
.
env
.
DB_USER
,
DB_PWD
:
process
.
env
.
DB_PWD
,
DB_NAME
:
process
.
env
.
CENTER_APP_DB_NAME
,
REDIS_HOST
:
process
.
env
.
REDIS_HOST
,
REDIS_PORT
:
process
.
env
.
REDIS_PORT
,
REDIS_PWD
:
process
.
env
.
REDIS_PWD
,
REDIS_DB
:
process
.
env
.
CENTER_APP_REDIS_DB
,
APP_ENV
:
process
.
env
.
APP_ENV
?
process
.
env
.
APP_ENV
:
"dev"
var
ENVINPUT
=
{
DB_HOST
:
process
.
env
.
DB_HOST
,
DB_PORT
:
process
.
env
.
DB_PORT
,
DB_USER
:
process
.
env
.
DB_USER
,
DB_PWD
:
process
.
env
.
DB_PWD
,
DB_NAME
:
process
.
env
.
CENTER_APP_DB_NAME
,
REDIS_HOST
:
process
.
env
.
REDIS_HOST
,
REDIS_PORT
:
process
.
env
.
REDIS_PORT
,
REDIS_PWD
:
process
.
env
.
REDIS_PWD
,
REDIS_DB
:
process
.
env
.
CENTER_APP_REDIS_DB
,
APP_ENV
:
process
.
env
.
APP_ENV
?
process
.
env
.
APP_ENV
:
"dev"
};
var
settings
=
{
env
:
ENVINPUT
.
APP_ENV
,
env
:
ENVINPUT
.
APP_ENV
,
appKey
:
"201911061250"
,
secret
:
"f99d413b767f09b5dff0b3610366cc46"
,
salt
:
"%iatpD1gcxz7iF#B"
,
...
...
@@ -79,10 +79,10 @@ var settings = {
return
localsettings
.
redis
;
}
else
{
return
{
host
:
ENVINPUT
.
REDIS_HOST
,
port
:
ENVINPUT
.
REDIS_PORT
,
password
:
ENVINPUT
.
REDIS_PWD
,
db
:
ENVINPUT
.
REDIS_DB
,
host
:
ENVINPUT
.
REDIS_HOST
,
port
:
ENVINPUT
.
REDIS_PORT
,
password
:
ENVINPUT
.
REDIS_PWD
,
db
:
ENVINPUT
.
REDIS_DB
,
};
}
},
...
...
@@ -92,10 +92,10 @@ var settings = {
return
localsettings
.
database
;
}
else
{
return
{
dbname
:
ENVINPUT
.
DB_NAME
,
user
:
ENVINPUT
.
DB_USER
,
password
:
ENVINPUT
.
DB_PWD
,
config
:
{
dbname
:
ENVINPUT
.
DB_NAME
,
user
:
ENVINPUT
.
DB_USER
,
password
:
ENVINPUT
.
DB_PWD
,
config
:
{
host
:
ENVINPUT
.
DB_HOST
,
dialect
:
'mysql'
,
operatorsAliases
:
false
,
...
...
@@ -105,8 +105,8 @@ var settings = {
acquire
:
90000000
,
idle
:
1000000
},
debug
:
false
,
dialectOptions
:
{
debug
:
false
,
dialectOptions
:
{
requestTimeout
:
999999
,
// instanceName:'DEV'
}
//设置MSSQL超时时间
...
...
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