Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
unify_api2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chaonan
unify_api2
Commits
6f878baf
Commit
6f878baf
authored
Jun 04, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
company name support mult lang 2024-06-04
parent
3e61f540
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
common_dao.py
unify_api/modules/common/dao/common_dao.py
+11
-0
product_auth.py
unify_api/modules/users/views/product_auth.py
+12
-0
No files found.
unify_api/modules/common/dao/common_dao.py
View file @
6f878baf
...
@@ -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
unify_api/modules/users/views/product_auth.py
View file @
6f878baf
# -*- 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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment