Commit b5a2ec41 authored by ZZH's avatar ZZH

update 2023-7-31

parent 2bb7528c
...@@ -31,7 +31,7 @@ async def update_userinfo_dao(user_id, alias, real_alias): ...@@ -31,7 +31,7 @@ async def update_userinfo_dao(user_id, alias, real_alias):
async def update_user_auth_dao(user_id, sql): async def update_user_auth_dao(user_id, sql):
sql = f"update user set {sql} where user_id=%s and is_delete=0" sql = f"update user set {sql} where user_id=%s and is_delete=0"
log.info(sql % (user_id, )) log.info(sql % (user_id,))
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
await conn.execute(sql, args=(user_id,)) await conn.execute(sql, args=(user_id,))
...@@ -46,7 +46,7 @@ async def update_password_dao(phone, password): ...@@ -46,7 +46,7 @@ async def update_password_dao(phone, password):
async def search_user_by_wechat_id_dao(wechat_id): async def search_user_by_wechat_id_dao(wechat_id):
sql = "select * from user where wechat_id = %s and is_delete=0" sql = "select * from user where wechat_id = %s and is_delete=0"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
data = await conn.fetchone(sql, args=(wechat_id, )) data = await conn.fetchone(sql, args=(wechat_id,))
return data return data
...@@ -86,7 +86,7 @@ async def search_user_product_auth_dao(user_id): ...@@ -86,7 +86,7 @@ async def search_user_product_auth_dao(user_id):
sql = "select product,cid_ext,proxy,uassistant_auth" \ sql = "select product,cid_ext,proxy,uassistant_auth" \
" from user_product_auth where user_id = %s " " from user_product_auth where user_id = %s "
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
data = await conn.fetchall(sql, args=(user_id, )) data = await conn.fetchall(sql, args=(user_id,))
return data return data
...@@ -129,7 +129,7 @@ async def insert_product_auth_dao(user_id, product, cid_ext, proxy=None, ...@@ -129,7 +129,7 @@ async def insert_product_auth_dao(user_id, product, cid_ext, proxy=None,
async def is_having_wechat_id(wechat_id): async def is_having_wechat_id(wechat_id):
sql = "select user_id from user where wechat_id = %s and is_delete=0" sql = "select user_id from user where wechat_id = %s and is_delete=0"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
data = await conn.fetchone(sql, args=(wechat_id, )) data = await conn.fetchone(sql, args=(wechat_id,))
return data return data
...@@ -150,3 +150,17 @@ async def update_user_info_by_wechat_id(real_name, unit, job, passwd, phone, ...@@ -150,3 +150,17 @@ async def update_user_info_by_wechat_id(real_name, unit, job, passwd, phone,
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
await conn.execute(sql, args=(real_name, unit, job, passwd, phone, await conn.execute(sql, args=(real_name, unit, job, passwd, phone,
wechat_id)) wechat_id))
async def load_compy_info(cid):
sql = f"select cid, shortname, fullname, industry, province " \
f"from company where cid = %s;"
async with MysqlUtil() as conn:
return await conn.fetchone(sql, args=(int(cid),))
async def load_compy_logo(cid):
sql = f"SELECT p.logo from proxy p left join company_proxy_map c " \
f"on p.proxy_id = c.proxy where c.cid = %s;"
async with MysqlUtil() as conn:
return await conn.fetchone(sql, args=(int(cid),))
...@@ -16,6 +16,9 @@ from sanic import response ...@@ -16,6 +16,9 @@ from sanic import response
from unify_api.modules.users.procedures.jwt_user import jwt_user from unify_api.modules.users.procedures.jwt_user import jwt_user
from unify_api.modules.users.procedures.user_product_auth import \ from unify_api.modules.users.procedures.user_product_auth import \
get_product_auth get_product_auth
from unify_api.modules.users.dao.current_user_info_dao import (
load_compy_info, load_compy_logo
)
@summary("用户权限信息") @summary("用户权限信息")
...@@ -44,19 +47,8 @@ async def get_product_auth_info(request): ...@@ -44,19 +47,8 @@ async def get_product_auth_info(request):
# 3. 返回 # 3. 返回
infos = [] infos = []
for key, value in res_pro.items(): for key, value in res_pro.items():
sql = ( company_info = await load_compy_info(key)
"select cid, shortname, fullname, industry, province " logo_info = await load_compy_logo(key)
"from company where cid = %s"
)
async with MysqlUtil() as conn:
company_info = await conn.fetchone(sql=sql, args=(int(key),))
# 增加获取logo url逻辑
logo_sql = (
"SELECT p.logo from proxy p left join company_proxy_map c "
"on p.proxy_id = c.proxy where c.cid = %s"
)
async with MysqlUtil() as conn:
logo_info = await conn.fetchone(sql=logo_sql, args=(int(key),))
logo_name = logo_info.get("logo") if logo_info else 'qkyn' logo_name = logo_info.get("logo") if logo_info else 'qkyn'
if product_id == 2: if product_id == 2:
pa = ProductAuth(ext_modules=value, **company_info) pa = ProductAuth(ext_modules=value, **company_info)
......
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