文档服务地址: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 { ...@@ -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',
password: this.password url: 'http://localhost:9100/user/signin',
data: {
userName: this.username,
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.userName, userName: this.username,
password: this.password, password: this.password,
email: this.email email: this.email
}).then(res => { }).then(res => {
......
from peewee import * from peewee import *
import json
mysql = MySQLDatabase( mysql = MySQLDatabase(
'sys', 'sys',
...@@ -45,91 +44,120 @@ def register(username, pwd, email): ...@@ -45,91 +44,120 @@ 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)
tmp = User.get(User.userName == username) try:
data = { tmp = User.get(User.userName == username)
'userId': tmp.usrId, data = {
'username': tmp.userName, 'userId': tmp.usrId,
'email': tmp.mail, 'username': tmp.userName,
'identity': tmp.type 'email': tmp.mail,
} '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 = {
'userId': tmp.usrId,
'username': tmp.userName,
'email': tmp.mail,
'identity': tmp.type
}
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 = { data = {
'userName': tmp.userName,
'userId': tmp.usrId, 'userId': tmp.usrId,
'username': tmp.userName,
'email': tmp.mail, 'email': tmp.mail,
'identity': tmp.type 'identity': tmp.type,
'imageIntegration': tmp.imageScore,
'imageAccuracy': tmp.imageAccuracy,
'textIntegration': tmp.textScore,
'textAccuracy': tmp.textAccuracy,
'releaseTaskIntegration': tmp.postScore,
'taskNumber': tmp.postNum
} }
return Result(1, "", data) return Result(1, "", data)
else: except:
return Result(0, "wrong userName/password", {}) return Result(-1, "DoesNotExit", {})
def personnal_information(id):
tmp = User.get(User.usrId == id)
data = {
'userName': tmp.userName,
'userId': tmp.usrId,
'email': tmp.mail,
'identity': tmp.type,
'imageIntegration': tmp.imageScore,
'imageAccuracy': tmp.imageAccuracy,
'textIntegration': tmp.textScore,
'textAccuracy': tmp.textAccuracy,
'releaseTaskIntegration': tmp.postScore,
'taskNumber': tmp.postNum
}
return Result(1, "", data)
def set_type(id, type): def set_type(id, type):
tmp = User.get(User.usrId == id) try:
tmp.type = type tmp = User.get(User.usrId == id)
tmp.save() tmp.type = type
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_image_score(id, score): def add_image_score(id, score):
tmp = User.get(User.usrId == id) try:
tmp.imageScore = tmp.imageScore + score tmp = User.get(User.usrId == id)
tmp.save() tmp.imageScore = tmp.imageScore + score
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def setImageAccuracy(id, acuuracy): def setImageAccuracy(id, acuuracy):
tmp = User.get(User.usrId == id) try:
tmp.imageAccuracy = tmp.imageAccuracy + acuuracy tmp = User.get(User.usrId == id)
tmp.save() tmp.imageAccuracy = tmp.imageAccuracy + acuuracy
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_text_score(id, score): def add_text_score(id, score):
tmp = User.get(User.usrId == id) try:
tmp.textScore = tmp.textScore + score tmp = User.get(User.usrId == id)
tmp.save() tmp.textScore = tmp.textScore + score
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def setTextAccuracy(id, acuuracy): def setTextAccuracy(id, acuuracy):
tmp = User.get(User.usrId == id) try:
tmp.textAccuracy = tmp.textAccuracy + acuuracy tmp = User.get(User.usrId == id)
tmp.save() tmp.textAccuracy = tmp.textAccuracy + acuuracy
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_post_score(id, score): def add_post_score(id, score):
tmp = User.get(User.usrId == id) try:
tmp.postScore = tmp.postScore + score tmp = User.get(User.usrId == id)
tmp.save() tmp.postScore = tmp.postScore + score
tmp.save()
except:
return Result(-1, "DoesNotExit", {})
def add_post_num(id, num): def add_post_num(id, num):
tmp = User.get(User.usrId == id) try:
tmp.postNum = tmp.postNum + num tmp = User.get(User.usrId == id)
tmp.save() tmp.postNum = tmp.postNum + num
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)
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"
......
...@@ -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 signup(): def signin():
username = request.args['userName'] data = request.get_json(silent=True)
password = request.args['password'] print(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)
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