Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
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
方斌
51business
Commits
013a49cd
Commit
013a49cd
authored
Apr 28, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
192a29a0
Pipeline
#6657
passed with stage
in 9 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
1 deletion
+153
-1
sys_user.js
app/model/gjj/sys_user.js
+82
-0
user.js
app/service/user.js
+46
-0
config.local.js
config/config.local.js
+12
-0
config.prod.js
config/config.prod.js
+13
-1
No files found.
app/model/gjj/sys_user.js
0 → 100644
View file @
013a49cd
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
SysUser
=
app
.
gjjModel
.
define
(
'sys_suer'
,
{
sid
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
passport
:
{
type
:
STRING
,
allowNull
:
false
},
yys_cid
:
{
type
:
INTEGER
,
allowNull
:
true
},
cv
:
{
type
:
STRING
,
allowNull
:
true
},
ov
:
{
type
:
STRING
,
allowNull
:
false
},
place_cid
:
{
type
:
INTEGER
,
allowNull
:
false
},
apns
:
{
type
:
STRING
,
allowNull
:
true
},
phone
:
{
type
:
STRING
,
allowNull
:
true
},
time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
regtime
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'regtime'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
read_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'read_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
}
},
{
timestamps
:
false
,
tableName
:
'sys_user'
,
});
SysUser
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
SysUser
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
return
SysUser
;
};
app/service/user.js
0 → 100644
View file @
013a49cd
// app/service/user.js
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
class
UserService
extends
Service
{
/**
* 通过用户编号获取手机号(校验token)
* @param {*} data user_sid
* @param {*} data token
*/
async
get_phone_by_user_sid
(
data
)
{
const
{
ctx
}
=
this
;
let
ret
=
{
phone
:
''
}
if
(
!
data
.
user_sid
||
!
data
.
token
)
{
return
ret
;
}
//校验用户和token匹配问题
let
userSid
=
data
.
user_sid
;
let
token
=
data
.
token
;
let
authToken
=
await
ctx
.
helper
.
md5
(
String
(
userSid
)
+
moment
().
format
(
'MDYYYY'
)
+
'f74jkdsy83sjf'
,
'utf8'
);
ctx
.
logger
.
info
(
'get_phone_by_user_sid_params:'
+
JSON
.
stringify
(
data
));
ctx
.
logger
.
info
(
'authToken:'
+
authToken
);
if
(
token
!=
authToken
)
{
let
authTokenYesterday
=
await
ctx
.
helper
.
md5
(
String
(
userSid
)
+
moment
().
subtract
(
1
,
'days'
).
format
(
'MDYYYY'
)
+
'f74jkdsy83sjf'
,
'utf8'
);
if
(
authToken
!=
authTokenYesterday
)
{
return
ret
;
}
}
//根据主键查找用户信息
let
filter
=
{
where
:
{
sid
:
userSid
}
};
let
userInfo
=
await
ctx
.
gjjModel
.
SysUser
.
one
(
filter
);
ctx
.
logger
.
info
(
'get_phone_by_user_sid:'
+
JSON
.
stringify
(
userInfo
));
if
(
userInfo
===
null
)
{
return
ret
;
}
ret
.
phone
=
userInfo
.
passport
;
return
ret
;
}
}
module
.
exports
=
UserService
;
\ No newline at end of file
config/config.local.js
View file @
013a49cd
...
...
@@ -66,6 +66,18 @@ module.exports = appInfo => {
password
:
'ppD1sDSutHG83T2s1Ue3k'
,
port
:
3306
,
},
{
//公积金数据库
timezone
:
'+08:00'
,
delegate
:
'gjjModel'
,
baseDir
:
'model/gjj'
,
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'devgjj'
,
username
:
'devgjj'
,
password
:
'jianbing2014GG'
,
port
:
3306
,
},
],
};
...
...
config/config.prod.js
View file @
013a49cd
...
...
@@ -14,7 +14,7 @@ module.exports = appInfo => {
dir
:
'/jianbing/logs/51business'
,
};
// add your config here
config
.
middleware
=
[
'errorHandler'
,
'deviceLogin'
,
'deviceInit'
,
'responseSet'
];
config
.
middleware
=
[
'errorHandler'
,
'deviceLogin'
,
'deviceInit'
,
'responseSet'
];
// 是否启用csrf安全
config
.
security
=
{
...
...
@@ -40,6 +40,18 @@ module.exports = appInfo => {
password
:
process
.
env
.
MYSQL_BLOCK_PWD
,
port
:
3306
,
},
{
//公积金数据库
timezone
:
'+08:00'
,
delegate
:
'gjjModel'
,
baseDir
:
'model/gjj'
,
dialect
:
'mysql'
,
host
:
process
.
env
.
MYSQL_GJJ_HOST
,
database
:
process
.
env
.
MYSQL_GJJ_DB_NAME
,
username
:
process
.
env
.
MYSQL_GJJ_USER
,
password
:
process
.
env
.
MYSQL_GJJ_PWD
,
port
:
3306
,
},
// {
// // 东八时区
// timezone: '+08:00',
...
...
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