Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
付智勇
/
koa2_Sequelize_project
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
付智勇
8 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ca5e3529eba543ab1903f1d6d2c63adbd4128b33
ca5e3529
1 parent
440d8cbe
no message
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
23 行增加
和
7 行删除
controller/userController.js
routes/upload.js
services/userService.js
util/tokenUtil.js
views/index.html
controller/userController.js
查看文件 @
ca5e352
...
...
@@ -104,7 +104,8 @@ userController.prototype.login = async(ctx, next) =>{
userMobile
:
userData
.
userMobile
,
userEmail
:
userData
.
userEmail
,
token
:
userData
.
token
,
createTime
:
userData
.
createTime
createTime
:
userData
.
createTime
,
userPhoto
:
userData
.
userPhoto
}
if
(
!
userData
.
code
){
return
userBack
;
...
...
routes/upload.js
查看文件 @
ca5e352
...
...
@@ -47,12 +47,13 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => {
}
ctx
.
response
.
status
=
200
;
ctx
.
body
=
{
fileUrl
:
'http://localhost:10000/'
+
ctx
.
req
.
file
.
originalname
code
:
200
,
fileUrl
:
path
+
ctx
.
req
.
file
.
originalname
}
}
catch
(
error
)
{
console
.
log
(
error
)
ctx
.
response
.
status
=
400
;
ctx
.
body
=
{
msg
:
error
}
ctx
.
body
=
{
code
:
400
,
msg
:
error
}
}
})
...
...
services/userService.js
查看文件 @
ca5e352
...
...
@@ -5,6 +5,8 @@ var sequelize = require('../config');
var
tokenUtil
=
require
(
'../util/tokenUtil'
);
var
co
=
require
(
'co'
);
const
emailUtil
=
require
(
'../util/emailUtil'
)
const
attachmentModel
=
require
(
'../model/attachmentModel'
)
function
userService
(){
...
...
@@ -45,12 +47,19 @@ userService.prototype.login = async(loginName,pw,userEmail) => {
{
loginName
:
loginName
}
];
let
User
=
await
userModel
.
find
({
where
:{
$or
:
queryData
}})
let
attachment
=
await
attachmentModel
.
findOne
({
where
:{
businessId
:
User
.
id
}})
if
(
!
User
){
return
{
code
:
300
,
msg
:
'用户不存在'
}
}
else
if
(
User
.
password
!=
saitMd5
.
md5
(
pw
)){
return
{
code
:
300
,
msg
:
'密码不正确'
}
}
let
token
=
await
tokenUtil
.
getSession
(
User
);
if
(
attachment
){
token
.
userPhoto
=
attachment
.
path
}
else
{
token
.
userPhoto
=
null
}
console
.
dir
(
token
)
return
token
}
catch
(
err
){
console
.
log
(
err
)
...
...
util/tokenUtil.js
查看文件 @
ca5e352
...
...
@@ -15,7 +15,6 @@ module.exports = new JwtSession() ;
* @param cb
*/
JwtSession
.
prototype
.
getSession
=
(
users
)
=>
{
console
.
log
(
users
)
var
expiresIn
=
60
*
60
*
1000
;
var
payload
=
{};
payload
.
id
=
users
.
id
;
...
...
views/index.html
查看文件 @
ca5e352
...
...
@@ -7,9 +7,8 @@
<script
src=
"http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"
></script>
</head>
<body>
<form
action=
"/upload/upLoadDoc?businessId=0aJeQOYgLAo5yB1mE14Rvzb69V7mpZKD&category=1"
method=
"post"
enctype=
"multipart/form-data"
>
<form
action=
"/upload/upLoadDoc?businessId=0aJeQOYgLAo5yB1mE14Rvzb69V7mpZKD&category=1"
method=
"post"
enctype=
"multipart/form-data"
target=
"http://baidu.com"
>
<input
type=
"file"
name=
"file"
/>
<input
type=
"text"
value=
"1212"
name=
"class"
>
<input
type=
"submit"
value=
"ok"
/>
</form>
<button
onclick=
"window.open('/record')"
>
asdas
</button>
...
...
@@ -17,6 +16,13 @@
</body>
<script>
function
saveReport
()
{
// jquery 表单提交
$
(
"#showDataForm"
).
ajaxSubmit
(
function
(
message
)
{
console
.
log
(
message
)
});
return
false
;
// 必须返回false,否则表单会自己再做一次提交操作,并且页面跳转
}
</script>
</html>
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论