fix: update app tag error

pull/20618/head
Novice 12 months ago
parent 275e86a26c
commit ca5dcb1917

@ -46,6 +46,8 @@ class TagService:
@staticmethod @staticmethod
def get_tag_by_tag_name(tag_type: str, current_tenant_id: str, tag_name: str) -> list: def get_tag_by_tag_name(tag_type: str, current_tenant_id: str, tag_name: str) -> list:
if not tag_type or not tag_name:
return []
tags = ( tags = (
db.session.query(Tag) db.session.query(Tag)
.filter(Tag.name == tag_name, Tag.tenant_id == current_tenant_id, Tag.type == tag_type) .filter(Tag.name == tag_name, Tag.tenant_id == current_tenant_id, Tag.type == tag_type)
@ -73,7 +75,7 @@ class TagService:
@staticmethod @staticmethod
def save_tags(args: dict) -> Tag: def save_tags(args: dict) -> Tag:
if TagService.get_tag_by_tag_name(args["type"], current_user.current_tenant_id, args["name"]): if TagService.get_tag_by_tag_name(args.get("type", ""), current_user.current_tenant_id, args.get("name", "")):
raise ValueError("Tag name already exists") raise ValueError("Tag name already exists")
tag = Tag( tag = Tag(
id=str(uuid.uuid4()), id=str(uuid.uuid4()),
@ -88,7 +90,7 @@ class TagService:
@staticmethod @staticmethod
def update_tags(args: dict, tag_id: str) -> Tag: def update_tags(args: dict, tag_id: str) -> Tag:
if TagService.get_tag_by_tag_name(args["type"], current_user.current_tenant_id, args["name"]): if TagService.get_tag_by_tag_name(args.get("type", ""), current_user.current_tenant_id, args.get("name", "")):
raise ValueError("Tag name already exists") raise ValueError("Tag name already exists")
tag = db.session.query(Tag).filter(Tag.id == tag_id).first() tag = db.session.query(Tag).filter(Tag.id == tag_id).first()
if not tag: if not tag:

Loading…
Cancel
Save