Commit 6f878baf authored by ZZH's avatar ZZH

company name support mult lang 2024-06-04

parent 3e61f540
...@@ -364,3 +364,14 @@ async def load_monitor_names(mtids, lang): ...@@ -364,3 +364,14 @@ async def load_monitor_names(mtids, lang):
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
return {r["mtid"]: r[lang] for r in return {r["mtid"]: r[lang] for r in
await conn.fetchall(sql, (tuple(mtids),))} await conn.fetchall(sql, (tuple(mtids),))}
async def load_compy_name(cid, lang):
shortname, fullname = "", ""
sql = f"SELECT * FROM power_iot.company_name WHERE cid=%s;"
async with MysqlUtil() as conn:
rlt = await conn.fetchone(sql, (cid,))
if rlt:
shortname = rlt.get(f"short_{lang}")
fullname = rlt.get(f"full_{lang}")
return shortname, fullname
# -*- coding:utf-8 -*-
from pot_libs.logger import log from pot_libs.logger import log
from pot_libs.mysql_util.mysql_util import MysqlUtil from pot_libs.mysql_util.mysql_util import MysqlUtil
from pot_libs.sanic_api import summary from pot_libs.sanic_api import summary
...@@ -18,6 +19,9 @@ from unify_api.modules.users.procedures.user_product_auth import \ ...@@ -18,6 +19,9 @@ from unify_api.modules.users.procedures.user_product_auth import \
from unify_api.modules.users.dao.current_user_info_dao import ( from unify_api.modules.users.dao.current_user_info_dao import (
load_compy_info, load_compy_logo load_compy_info, load_compy_logo
) )
from unify_api.modules.common.dao.common_dao import (
load_user_lang, load_compy_name
)
@summary("用户权限信息") @summary("用户权限信息")
...@@ -45,8 +49,16 @@ async def get_product_auth_info(request): ...@@ -45,8 +49,16 @@ async def get_product_auth_info(request):
if res_pro: if res_pro:
# 3. 返回 # 3. 返回
infos = [] infos = []
lang = await load_user_lang(user_id)
for key, value in res_pro.items(): for key, value in res_pro.items():
company_info = await load_compy_info(key) company_info = await load_compy_info(key)
if lang != "zh_CN":
shortname, fullname = await load_compy_name(key, lang)
if shortname:
company_info["shortname"] = shortname
if fullname:
company_info["fullname"] = fullname
logo_info = await load_compy_logo(key) logo_info = await load_compy_logo(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:
......
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