Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
mentha
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
1
Merge Requests
1
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
rank
mentha
Commits
8496709e
Commit
8496709e
authored
Mar 04, 2021
by
李小芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改标签
parent
34d5c14b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
40 deletions
+45
-40
tag.py
talos/services/tag.py
+45
-40
No files found.
talos/services/tag.py
View file @
8496709e
...
...
@@ -187,43 +187,51 @@ class TagService(ServiceBase):
result
=
cls
.
call_rpc
(
'api/tag/tag/query'
,
name
=
name
,
count
=
count
)
return
result
def
get_
sub_
tag_by_name
(
cls
,
name
):
def
get_tag_by_name
(
cls
,
name
):
try
:
all_tags
=
[]
client
=
LibraryGrpcClient
(
settings
.
BRAIN_SERVER
,
settings
.
BRAIN_PORT
)
res
=
client
.
findBy
Tag
Name
(
word
=
name
)
res
=
client
.
findByName
(
word
=
name
)
res_dict
=
json_format
.
MessageToDict
(
res
)
if
res
:
stringValue
=
res
.
get
(
"Entry"
,
{})
.
get
(
"content"
,
{})
tag_id
=
stringValue
.
get
(
"tag_id"
)
tag_name
=
stringValue
.
get
(
"tag_name"
)
tag_type
=
stringValue
.
get
(
"tag_type"
)
is_online
=
stringValue
.
get
(
"is_online"
)
recommend_type
=
stringValue
.
get
(
"recommend_type"
)
all_tags
.
append
({
"tag_id"
:
tag_id
,
"tag_name"
:
tag_name
,
"tag_type"
:
tag_type
,
"is_online"
:
is_online
,
"recommend_type"
:
recommend_type
})
if
res_dict
:
for
item
in
res_dict
.
get
(
"Entry"
,
[]):
is_online
=
item
.
get
(
"content"
,
{})
.
get
(
"is_online"
)
.
get
(
"intValue"
)
tag_id
=
item
.
get
(
"content"
,
{})
.
get
(
"id"
)
.
get
(
"intValue"
)
tag_name
=
item
.
get
(
"content"
,
{})
.
get
(
"name"
)
.
get
(
"stringValue"
)
recommend_type
=
item
.
get
(
"content"
,
{})
.
get
(
"recommend_type"
)
.
get
(
"stringValue"
)
tag_type
=
item
.
get
(
"content"
,
{})
.
get
(
"tag_type"
)
.
get
(
"stringValue"
)
if
is_online
==
True
:
all_tags
.
append
(
{
"tag_id"
:
tag_id
,
"tag_name"
:
tag_name
,
"tag_type"
:
tag_type
,
"is_online"
:
is_online
,
"recommend_type"
:
recommend_type
})
else
:
pass
return
all_tags
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_
sub_
tag_by_id
(
cls
,
tag_id
):
def
get_tag_by_id
(
cls
,
tag_id
):
try
:
all_tags
=
[]
client
=
LibraryGrpcClient
(
settings
.
BRAIN_SERVER
,
settings
.
BRAIN_PORT
)
res
=
res
=
client
.
findBy
Tag
Id
(
tagId
=
tag_id
)
res
=
res
=
client
.
findById
(
tagId
=
tag_id
)
res_dict
=
json_format
.
MessageToDict
(
res
)
if
res_dict
:
stringValue
=
res_dict
.
get
(
"Entry"
,
{})
for
item
in
stringValue
:
data
=
item
.
get
(
"content"
,
{})
.
get
(
"data"
,
{})
.
get
(
"stringValue"
,
{})
tag_id
=
data
.
get
(
"tag_id"
)
tag_name
=
data
.
get
(
"tag_name"
)
tag_type
=
data
.
get
(
"tag_type"
)
is_online
=
data
.
get
(
"is_online"
)
recommend_type
=
data
.
get
(
"recommend_type"
)
all_tags
.
append
(
{
"tag_id"
:
tag_id
,
"tag_name"
:
tag_name
,
"tag_type"
:
tag_type
,
"is_online"
:
is_online
,
"recommend_type"
:
recommend_type
})
for
item
in
res_dict
.
get
(
"Entry"
,
[]):
is_online
=
item
.
get
(
"content"
,
{})
.
get
(
"is_online"
)
.
get
(
"intValue"
)
tag_id
=
item
.
get
(
"content"
,
{})
.
get
(
"id"
)
.
get
(
"intValue"
)
tag_name
=
item
.
get
(
"content"
,
{})
.
get
(
"name"
)
.
get
(
"stringValue"
)
recommend_type
=
item
.
get
(
"content"
,
{})
.
get
(
"recommend_type"
)
.
get
(
"stringValue"
)
tag_type
=
item
.
get
(
"content"
,
{})
.
get
(
"tag_type"
)
.
get
(
"stringValue"
)
if
is_online
==
True
:
all_tags
.
append
(
{
"tag_id"
:
tag_id
,
"tag_name"
:
tag_name
,
"tag_type"
:
tag_type
,
"is_online"
:
is_online
,
"recommend_type"
:
recommend_type
})
else
:
pass
return
all_tags
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
...
...
@@ -233,17 +241,15 @@ class TagService(ServiceBase):
# 测试环境
all_tags
=
[]
client
=
LibraryGrpcClient
(
settings
.
BRAIN_SERVER
,
settings
.
BRAIN_PORT
)
res
=
client
.
findBy
Tag
Ids
(
tagIds
=
tag_ids
)
res
=
client
.
findByIds
(
tagIds
=
tag_ids
)
res_dict
=
json_format
.
MessageToDict
(
res
)
if
res_dict
:
for
item
in
res_dict
.
get
(
"Entry"
,
[]):
stringValue
=
item
.
get
(
"content"
,
{})
.
get
(
"data"
,
{})
.
get
(
"stringValue"
,
{})
print
(
stringValue
)
tag_id
=
stringValue
.
get
(
"tag_id"
)
tag_name
=
stringValue
.
get
(
"tag_name"
)
tag_type
=
stringValue
.
get
(
"tag_type"
)
is_online
=
stringValue
.
get
(
"is_online"
)
recommend_type
=
stringValue
.
get
(
"recommend_type"
)
is_online
=
item
.
get
(
"content"
,
{})
.
get
(
"is_online"
)
.
get
(
"intValue"
)
tag_id
=
item
.
get
(
"content"
,
{})
.
get
(
"id"
)
.
get
(
"intValue"
)
tag_name
=
item
.
get
(
"content"
,
{})
.
get
(
"name"
)
.
get
(
"stringValue"
)
recommend_type
=
item
.
get
(
"content"
,
{})
.
get
(
"recommend_type"
)
.
get
(
"stringValue"
)
tag_type
=
item
.
get
(
"content"
,
{})
.
get
(
"tag_type"
)
.
get
(
"stringValue"
)
if
is_online
==
True
:
all_tags
.
append
(
{
"tag_id"
:
tag_id
,
"tag_name"
:
tag_name
,
"tag_type"
:
tag_type
,
"is_online"
:
is_online
,
...
...
@@ -255,20 +261,19 @@ class TagService(ServiceBase):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_
sub_
tag_by_names
(
cls
,
names
):
def
get_tag_by_names
(
cls
,
names
):
try
:
all_tags
=
[]
client
=
LibraryGrpcClient
(
settings
.
BRAIN_SERVER
,
settings
.
BRAIN_PORT
)
res_dict
=
client
.
findBy
TagNames
(
words
=
names
)
res_dict
=
client
.
findBy
NameList
(
words
=
names
)
res_dict
=
json_format
.
MessageToDict
(
res_dict
)
if
res_dict
:
for
item
in
res_dict
.
get
(
"Entry"
,
[]):
stringValue
=
item
.
get
(
"Entry"
,
{})
.
get
(
"content"
,
{})
.
get
(
"data"
,
{})
.
get
(
"stringValue"
,
{})
tag_id
=
stringValue
.
get
(
"tag_id"
)
tag_name
=
stringValue
.
get
(
"tag_name"
)
tag_type
=
stringValue
.
get
(
"tag_type"
)
is_online
=
stringValue
.
get
(
"is_online"
)
recommend_type
=
stringValue
.
get
(
"recommend_type"
)
is_online
=
item
.
get
(
"content"
,
{})
.
get
(
"is_online"
)
.
get
(
"intValue"
)
tag_id
=
item
.
get
(
"content"
,
{})
.
get
(
"id"
)
.
get
(
"intValue"
)
tag_name
=
item
.
get
(
"content"
,
{})
.
get
(
"name"
)
.
get
(
"stringValue"
)
recommend_type
=
item
.
get
(
"content"
,
{})
.
get
(
"recommend_type"
)
.
get
(
"stringValue"
)
tag_type
=
item
.
get
(
"content"
,
{})
.
get
(
"tag_type"
)
.
get
(
"stringValue"
)
if
is_online
==
True
:
all_tags
.
append
(
{
"tag_id"
:
tag_id
,
"tag_name"
:
tag_name
,
"tag_type"
:
tag_type
,
"is_online"
:
is_online
,
...
...
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