Commit eac907a7 by Aeolus

update

parent fd44bcc2
...@@ -56,5 +56,5 @@ AGENT_STATUS = { ...@@ -56,5 +56,5 @@ AGENT_STATUS = {
ACCOUNT_STATUS = { ACCOUNT_STATUS = {
'on_use': 1, 'on_use': 1,
'delete': 2 'delete': -1
} }
...@@ -152,14 +152,15 @@ def get_account_list(): ...@@ -152,14 +152,15 @@ def get_account_list():
keyword = json_data.get("keyword", None) keyword = json_data.get("keyword", None)
select_sql = """select admin_account.user_name, admin_account.phone, admin_account.level, admin_account.status, select_sql = """select admin_account.user_name, admin_account.phone, admin_account.level, admin_account.status,
admin_account.comment,admin_account.parent_id,admin_account.rate, admin_account.created_at, admin_account.updated_at, admin_account.last_login, admin_account.comment,admin_account.parent_id,admin_account.rate, admin_account.created_at,
admin_account.id admin_account.updated_at,admin_account.id, admin_account.user_no
""" """
count_sql = "select count(admin_account.id) as total_count" count_sql = "select count(admin_account.id) as total_count"
from_sql = " from admin_account where admin_account.id in ( select admin_account.id " from_sql = " from admin_account where admin_account.id in ( select admin_account.id "
from_sql += " from admin_account " from_sql += " from admin_account "
where_sql = " where 0=0 and admin_account.level < {} and admin_account.parent = {}".format(g.user.level, g.user.id) where_sql = " where 0=0 and admin_account.level > {} and admin_account.parent_id = {}".format(g.user.level,
g.user.id)
if keyword: if keyword:
where_sql += """ where_sql += """
and CONCAT(admin_account.user_name,admin_account.phone) LIKE '%{keyword}%' and CONCAT(admin_account.user_name,admin_account.phone) LIKE '%{keyword}%'
...@@ -176,15 +177,16 @@ def get_account_list(): ...@@ -176,15 +177,16 @@ def get_account_list():
else: else:
total_count = count_result.total_count total_count = count_result.total_count
print(select_sql + from_sql + where_sql + order_sql + limit_sql)
result = db.session.execute(select_sql + from_sql + where_sql + order_sql + limit_sql).fetchall() result = db.session.execute(select_sql + from_sql + where_sql + order_sql + limit_sql).fetchall()
return_data = [] return_data = []
for info in result: for info in result:
return_data.append( return_data.append(
{"user_name": info.user_name, "phone": info.phone, "level": info.level, "status": info.status, {"user_name": info.user_name, "phone": info.phone, "level": info.level, "status": info.status,
"comment": info.comment, "admin_id": info.id, "comment": info.comment, "user_id": info.id, "user_no": info.user_no,
"create_time": info.created_at.strftime("%Y-%m-%d %H:%M:%S") if info.last_login else "", "create_time": info.created_at.strftime("%Y-%m-%d %H:%M:%S"),
"update_time": info.updated_at.strftime("%Y-%m-%d %H:%M:%S") if info.last_login else "", "update_time": info.updated_at.strftime("%Y-%m-%d %H:%M:%S"),
}) })
return BaseResponse({"list": return_data, "page": page, "pageSize": page_size, "total_count": total_count}) return BaseResponse({"list": return_data, "page": page, "pageSize": page_size, "total_count": total_count})
...@@ -198,13 +200,14 @@ def get_account_detail(): ...@@ -198,13 +200,14 @@ def get_account_detail():
admin_info = g.user admin_info = g.user
else: else:
admin_info = AdminAccount.query.filter(AdminAccount.phone == phone, admin_info = AdminAccount.query.filter(AdminAccount.phone == phone,
AdminAccount.level < g.user.level, AdminAccount.level > g.user.level,
AdminAccount.parent_id == g.user.id).first() AdminAccount.parent_id == g.user.id).first()
if not admin_info: if not admin_info:
return BaseResponse(**ACCOUNT_NOT_EXISTS_ERROR) return BaseResponse(**ACCOUNT_NOT_EXISTS_ERROR)
user_info = { user_info = {
"admin_no": admin_info.admin_no, "user_id": admin_info.id,
"user_no": admin_info.user_no,
"user_name": admin_info.user_name, "user_name": admin_info.user_name,
"phone": admin_info.phone, "phone": admin_info.phone,
"level": admin_info.level, "level": admin_info.level,
...@@ -220,7 +223,7 @@ def edit_user(): ...@@ -220,7 +223,7 @@ def edit_user():
json_data = request.get_json() json_data = request.get_json()
old_phone = json_data['old_phone'] if 'old_phone' in json_data else '' old_phone = json_data['old_phone'] if 'old_phone' in json_data else ''
new_phone = json_data['new_phone'] if 'new_phone' in json_data else '' new_phone = json_data['new_phone'] if 'new_phone' in json_data else ''
user_name = json_data['name'] if 'name' in json_data else 'SSW' user_name = json_data['user_name'] if 'user_name' in json_data else 'SSW'
password = json_data['password'] if 'password' in json_data else '' password = json_data['password'] if 'password' in json_data else ''
comment = json_data['comment'] if 'comment' in json_data else '' comment = json_data['comment'] if 'comment' in json_data else ''
level = json_data['level'] if 'level' in json_data else '' level = json_data['level'] if 'level' in json_data else ''
...@@ -240,7 +243,7 @@ def edit_user(): ...@@ -240,7 +243,7 @@ def edit_user():
admin_info.level = int(level) admin_info.level = int(level)
else: else:
admin_info = AdminAccount.query.filter(AdminAccount.phone == old_phone, admin_info = AdminAccount.query.filter(AdminAccount.phone == old_phone,
AdminAccount.level < g.user.level, AdminAccount.level > g.user.level,
AdminAccount.parent_id == g.user.id AdminAccount.parent_id == g.user.id
).first() ).first()
if not admin_info: if not admin_info:
...@@ -267,7 +270,7 @@ def delete_user(): ...@@ -267,7 +270,7 @@ def delete_user():
return BaseResponse(**PHONE_NOT_NULL_ERROR) return BaseResponse(**PHONE_NOT_NULL_ERROR)
admin_info = AdminAccount.query.filter(AdminAccount.phone == phone, admin_info = AdminAccount.query.filter(AdminAccount.phone == phone,
AdminAccount.level < g.user.level).first() AdminAccount.level > g.user.level).first()
if not admin_info: if not admin_info:
return BaseResponse(**ACCOUNT_NOT_EXISTS_ERROR) return BaseResponse(**ACCOUNT_NOT_EXISTS_ERROR)
......
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