Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DA-Platform
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
文档服务地址:
http://47.92.0.57:3000/
周报索引地址:
http://47.92.0.57:3000/s/NruNXRYmV
Open sidebar
Berlin
DA-Platform
Commits
fa852445
Commit
fa852445
authored
May 30, 2020
by
李景熙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录前后端连接
parent
eb8b2bfd
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
15 deletions
+62
-15
Login.vue
DAPlatform-front/src/components/Login.vue
+7
-3
User.py
DAPlatform/Dao/User.py
+34
-6
User.cpython-37.pyc
DAPlatform/Dao/__pycache__/User.cpython-37.pyc
+0
-0
app.py
DAPlatform/app.py
+3
-0
user.cpython-37.pyc
DAPlatform/views/__pycache__/user.cpython-37.pyc
+0
-0
user.py
DAPlatform/views/user.py
+18
-6
No files found.
DAPlatform-front/src/components/Login.vue
View file @
fa852445
...
@@ -67,9 +67,13 @@ export default {
...
@@ -67,9 +67,13 @@ export default {
}
}
this
.
$store
.
commit
(
'setUserInfo'
,
userInfo
)
this
.
$store
.
commit
(
'setUserInfo'
,
userInfo
)
// 登录接口
// 登录接口
this
.
axios
.
post
(
'/signin'
,
{
this
.
axios
({
userName
:
this
.
userName
,
method
:
'post'
,
url
:
'http://localhost:9100/user/signin'
,
data
:
{
userName
:
this
.
username
,
password
:
this
.
password
password
:
this
.
password
}
}).
then
(
res
=>
{
}).
then
(
res
=>
{
if
(
res
.
code
===
1
)
{
if
(
res
.
code
===
1
)
{
// 存储用户ID和身份
// 存储用户ID和身份
...
@@ -88,7 +92,7 @@ export default {
...
@@ -88,7 +92,7 @@ export default {
this
.
$store
.
commit
(
'setUserInfo'
,
userInfo
)
this
.
$store
.
commit
(
'setUserInfo'
,
userInfo
)
this
.
axios
.
post
(
'/signup'
,
{
this
.
axios
.
post
(
'/signup'
,
{
userName
:
this
.
user
N
ame
,
userName
:
this
.
user
n
ame
,
password
:
this
.
password
,
password
:
this
.
password
,
email
:
this
.
email
email
:
this
.
email
}).
then
(
res
=>
{
}).
then
(
res
=>
{
...
...
DAPlatform/Dao/User.py
View file @
fa852445
from
peewee
import
*
from
peewee
import
*
import
json
mysql
=
MySQLDatabase
(
mysql
=
MySQLDatabase
(
'sys'
,
'sys'
,
...
@@ -45,6 +44,7 @@ def register(username, pwd, email):
...
@@ -45,6 +44,7 @@ def register(username, pwd, email):
return
Result
(
0
,
"userName is repeat"
,
{})
return
Result
(
0
,
"userName is repeat"
,
{})
else
:
else
:
User
.
create
(
userName
=
username
,
password
=
pwd
,
mail
=
email
)
User
.
create
(
userName
=
username
,
password
=
pwd
,
mail
=
email
)
try
:
tmp
=
User
.
get
(
User
.
userName
==
username
)
tmp
=
User
.
get
(
User
.
userName
==
username
)
data
=
{
data
=
{
'userId'
:
tmp
.
usrId
,
'userId'
:
tmp
.
usrId
,
...
@@ -53,12 +53,14 @@ def register(username, pwd, email):
...
@@ -53,12 +53,14 @@ def register(username, pwd, email):
'identity'
:
tmp
.
type
'identity'
:
tmp
.
type
}
}
return
Result
(
1
,
""
,
data
)
return
Result
(
1
,
""
,
data
)
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
login
(
username
,
pwd
):
def
login
(
username
,
pwd
):
u
=
User
.
get
(
User
.
userName
==
username
)
try
:
if
(
u
.
password
==
pwd
):
tmp
=
User
.
get
(
User
.
userName
==
username
)
tmp
=
User
.
get
(
User
.
userName
==
username
)
if
(
tmp
.
password
==
pwd
):
data
=
{
data
=
{
'userId'
:
tmp
.
usrId
,
'userId'
:
tmp
.
usrId
,
'username'
:
tmp
.
userName
,
'username'
:
tmp
.
userName
,
...
@@ -68,9 +70,12 @@ def login(username, pwd):
...
@@ -68,9 +70,12 @@ def login(username, pwd):
return
Result
(
1
,
""
,
data
)
return
Result
(
1
,
""
,
data
)
else
:
else
:
return
Result
(
0
,
"wrong userName/password"
,
{})
return
Result
(
0
,
"wrong userName/password"
,
{})
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
personnal_information
(
id
):
def
personnal_information
(
id
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
data
=
{
data
=
{
'userName'
:
tmp
.
userName
,
'userName'
:
tmp
.
userName
,
...
@@ -85,51 +90,74 @@ def personnal_information(id):
...
@@ -85,51 +90,74 @@ def personnal_information(id):
'taskNumber'
:
tmp
.
postNum
'taskNumber'
:
tmp
.
postNum
}
}
return
Result
(
1
,
""
,
data
)
return
Result
(
1
,
""
,
data
)
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
set_type
(
id
,
type
):
def
set_type
(
id
,
type
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
.
type
=
type
tmp
.
type
=
type
tmp
.
save
()
tmp
.
save
()
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
add_image_score
(
id
,
score
):
def
add_image_score
(
id
,
score
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
.
imageScore
=
tmp
.
imageScore
+
score
tmp
.
imageScore
=
tmp
.
imageScore
+
score
tmp
.
save
()
tmp
.
save
()
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
setImageAccuracy
(
id
,
acuuracy
):
def
setImageAccuracy
(
id
,
acuuracy
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
.
imageAccuracy
=
tmp
.
imageAccuracy
+
acuuracy
tmp
.
imageAccuracy
=
tmp
.
imageAccuracy
+
acuuracy
tmp
.
save
()
tmp
.
save
()
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
add_text_score
(
id
,
score
):
def
add_text_score
(
id
,
score
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
.
textScore
=
tmp
.
textScore
+
score
tmp
.
textScore
=
tmp
.
textScore
+
score
tmp
.
save
()
tmp
.
save
()
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
setTextAccuracy
(
id
,
acuuracy
):
def
setTextAccuracy
(
id
,
acuuracy
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
.
textAccuracy
=
tmp
.
textAccuracy
+
acuuracy
tmp
.
textAccuracy
=
tmp
.
textAccuracy
+
acuuracy
tmp
.
save
()
tmp
.
save
()
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
add_post_score
(
id
,
score
):
def
add_post_score
(
id
,
score
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
.
postScore
=
tmp
.
postScore
+
score
tmp
.
postScore
=
tmp
.
postScore
+
score
tmp
.
save
()
tmp
.
save
()
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
def
add_post_num
(
id
,
num
):
def
add_post_num
(
id
,
num
):
try
:
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
=
User
.
get
(
User
.
usrId
==
id
)
tmp
.
postNum
=
tmp
.
postNum
+
num
tmp
.
postNum
=
tmp
.
postNum
+
num
tmp
.
save
()
tmp
.
save
()
except
:
return
Result
(
-
1
,
"DoesNotExit"
,
{})
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
User
.
register
(
'tom'
,
'123'
,
'32@qq.com'
)
register
(
'tom'
,
'123'
,
'32@qq.com'
)
User
.
register
(
'tom'
,
'123'
,
'32@qq.com'
)
register
(
'tom'
,
'123'
,
'32@qq.com'
)
print
(
User
.
personnal_information
(
2
)
)
print
(
personnal_information
(
2
)
.
code
)
DAPlatform/Dao/__pycache__/User.cpython-37.pyc
View file @
fa852445
No preview for this file type
DAPlatform/app.py
View file @
fa852445
from
flask
import
Flask
from
flask
import
Flask
from
flask_cors
import
CORS
# from views.uploadDownload import uploadDownload
# from views.uploadDownload import uploadDownload
# from views.textAnnotation import textAnnotation
# from views.textAnnotation import textAnnotation
from
views.user
import
user
from
views.user
import
user
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
CORS
(
app
)
# app.register_blueprint(textAnnotation)
# app.register_blueprint(textAnnotation)
# app.register_blueprint(uploadDownload)
# app.register_blueprint(uploadDownload)
app
.
register_blueprint
(
user
)
app
.
register_blueprint
(
user
)
@app.route
(
"/"
)
@app.route
(
"/"
)
def
hello_world
():
def
hello_world
():
return
"hello"
return
"hello"
...
...
DAPlatform/views/__pycache__/user.cpython-37.pyc
View file @
fa852445
No preview for this file type
DAPlatform/views/user.py
View file @
fa852445
...
@@ -11,14 +11,20 @@ def register():
...
@@ -11,14 +11,20 @@ def register():
username
=
request
.
args
[
'userName'
]
username
=
request
.
args
[
'userName'
]
password
=
request
.
args
[
'password'
]
password
=
request
.
args
[
'password'
]
email
=
request
.
args
[
'email'
]
email
=
request
.
args
[
'email'
]
return
User
.
register
(
username
,
password
,
email
)
ret
=
User
.
register
(
username
,
password
,
email
)
res
=
{
'code'
:
ret
.
code
,
'message'
:
ret
.
message
,
'data'
:
ret
.
data
}
return
json
.
dumps
(
res
)
@user.route
(
"/signin"
,
methods
=
[
"Post"
])
@user.route
(
"/signin"
,
methods
=
[
"Post"
])
def
sign
up
():
def
sign
in
():
username
=
request
.
args
[
'userName'
]
data
=
request
.
get_json
(
silent
=
True
)
p
assword
=
request
.
args
[
'password'
]
p
rint
(
data
[
'userName'
])
ret
=
User
.
login
(
username
,
password
)
ret
=
User
.
login
(
data
[
'userName'
],
data
[
'password'
]
)
res
=
{
res
=
{
'code'
:
ret
.
code
,
'code'
:
ret
.
code
,
'message'
:
ret
.
message
,
'message'
:
ret
.
message
,
...
@@ -30,4 +36,10 @@ def signup():
...
@@ -30,4 +36,10 @@ def signup():
@user.route
(
"/personalInformation"
,
methods
=
[
"GET"
])
@user.route
(
"/personalInformation"
,
methods
=
[
"GET"
])
def
personnal_information
():
def
personnal_information
():
userId
=
request
.
args
[
'userId'
]
userId
=
request
.
args
[
'userId'
]
return
User
.
personnal_information
(
userId
)
ret
=
User
.
personnal_information
(
userId
)
res
=
{
'code'
:
ret
.
code
,
'message'
:
ret
.
message
,
'data'
:
ret
.
data
}
return
json
.
dumps
(
res
)
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