文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit d9e6094e by 李严凡

Merge branch 'develop' of https://gitlab.redhtc.com/Berlincen/DA-Platform into develop

parents 0af53ad2 fa852445
......@@ -67,9 +67,13 @@ export default {
}
this.$store.commit('setUserInfo', userInfo)
// 登录接口
this.axios.post('/signin', {
userName: this.userName,
this.axios({
method: 'post',
url: 'http://localhost:9100/user/signin',
data: {
userName: this.username,
password: this.password
}
}).then(res => {
if (res.code === 1) {
// 存储用户ID和身份
......@@ -88,7 +92,7 @@ export default {
this.$store.commit('setUserInfo', userInfo)
this.axios.post('/signup', {
userName: this.userName,
userName: this.username,
password: this.password,
email: this.email
}).then(res => {
......
from peewee import *
import json
mysql = MySQLDatabase(
'sys',
......@@ -45,6 +44,7 @@ def register(username, pwd, email):
return Result(0, "userName is repeat", {})
else:
User.create(userName=username, password=pwd, mail=email)
try:
tmp = User.get(User.userName == username)
data = {
'userId': tmp.usrId,
......@@ -53,12 +53,14 @@ def register(username, pwd, email):
'identity': tmp.type
}
return Result(1, "", data)
except:
return Result(-1, "DoesNotExit", {})
def login(username, pwd):
u = User.get(User.userName == username)
if (u.password == pwd):
try:
tmp = User.get(User.userName == username)
if (tmp.password == pwd):
data = {
'userId': tmp.usrId,
'username': tmp.userName,
......@@ -68,9 +70,12 @@ def login(username, pwd):
return Result(1, "", data)
else:
return Result(0, "wrong userName/password", {})
except:
return Result(-1, "DoesNotExit", {})
def personnal_information(id):
try:
tmp = User.get(User.usrId == id)
data = {
'userName': tmp.userName,
......@@ -85,51 +90,74 @@ def personnal_information(id):
'taskNumber': tmp.postNum
}
return Result(1, "", data)
except:
return Result(-1, "DoesNotExit", {})
def set_type(id, type):
try:
tmp = User.get(User.usrId == id)
tmp.type = type
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_image_score(id, score):
try:
tmp = User.get(User.usrId == id)
tmp.imageScore = tmp.imageScore + score
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def setImageAccuracy(id, acuuracy):
try:
tmp = User.get(User.usrId == id)
tmp.imageAccuracy = tmp.imageAccuracy + acuuracy
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_text_score(id, score):
try:
tmp = User.get(User.usrId == id)
tmp.textScore = tmp.textScore + score
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def setTextAccuracy(id, acuuracy):
try:
tmp = User.get(User.usrId == id)
tmp.textAccuracy = tmp.textAccuracy + acuuracy
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_post_score(id, score):
try:
tmp = User.get(User.usrId == id)
tmp.postScore = tmp.postScore + score
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_post_num(id, num):
try:
tmp = User.get(User.usrId == id)
tmp.postNum = tmp.postNum + num
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
if __name__ == '__main__':
User.register('tom', '123', '32@qq.com')
User.register('tom', '123', '32@qq.com')
print(User.personnal_information(2))
register('tom', '123', '32@qq.com')
register('tom', '123', '32@qq.com')
print(personnal_information(2).code)
from flask import Flask
from flask_cors import CORS
# from views.uploadDownload import uploadDownload
# from views.textAnnotation import textAnnotation
from views.user import user
app = Flask(__name__)
CORS(app)
# app.register_blueprint(textAnnotation)
# app.register_blueprint(uploadDownload)
app.register_blueprint(user)
@app.route("/")
def hello_world():
return "hello"
......
......@@ -11,14 +11,20 @@ def register():
username = request.args['userName']
password = request.args['password']
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"])
def signup():
username = request.args['userName']
password = request.args['password']
ret = User.login(username, password)
def signin():
data = request.get_json(silent=True)
print(data['userName'])
ret = User.login(data['userName'], data['password'])
res = {
'code': ret.code,
'message': ret.message,
......@@ -30,4 +36,10 @@ def signup():
@user.route("/personalInformation", methods=["GET"])
def personnal_information():
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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment