update 接口相关
This commit is contained in:
parent
109d459115
commit
c396d78b01
|
@ -96,3 +96,37 @@ class TagsImpl(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
return '关联成功'
|
return '关联成功'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def associate_api(**kwargs):
|
||||||
|
"""关联接口"""
|
||||||
|
data = kwargs['data']
|
||||||
|
|
||||||
|
obj = TagObj.AssociateApi()
|
||||||
|
obj.api_id = data['api_id']
|
||||||
|
obj.api_name = data['api_name']
|
||||||
|
|
||||||
|
for item in data['tags_id']:
|
||||||
|
DB_TEST.update_single_data_by_add(
|
||||||
|
'模型数据',
|
||||||
|
'标签数据',
|
||||||
|
{'标签ID': item},
|
||||||
|
{"关联接口": obj.fields_toggle()}
|
||||||
|
)
|
||||||
|
|
||||||
|
return '关联成功'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def cancel_associate_api(**kwargs):
|
||||||
|
"""取消关联接口"""
|
||||||
|
tag_id = kwargs['tag_id']
|
||||||
|
api_id = kwargs['api_id']
|
||||||
|
|
||||||
|
DB_TEST.update_single_data_by_pull(
|
||||||
|
'模型数据',
|
||||||
|
'标签数据',
|
||||||
|
{'标签ID': tag_id},
|
||||||
|
{"关联接口": {"接口ID": api_id}}
|
||||||
|
)
|
||||||
|
|
||||||
|
return '取消关联成功'
|
||||||
|
|
|
@ -77,10 +77,21 @@ class TagObj(SpecObject):
|
||||||
"func_name": "函数名称"
|
"func_name": "函数名称"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AssociateApi(SpecObject):
|
||||||
|
"""关联接口"""
|
||||||
|
api_id = ValidateAttr(field='api_id', type=str)
|
||||||
|
api_name = ValidateAttr(field='api_name', type=str)
|
||||||
|
|
||||||
|
fields_map = {
|
||||||
|
"api_id": "接口ID",
|
||||||
|
"api_name": "接口名称"
|
||||||
|
}
|
||||||
|
|
||||||
tag_id = ValidateAttr(field='tag_id', type=str)
|
tag_id = ValidateAttr(field='tag_id', type=str)
|
||||||
tag_field = ValidateAttr(field='tag_field', type=str)
|
tag_field = ValidateAttr(field='tag_field', type=str)
|
||||||
tag_category = ValidateAttr(field='tag_category', type=str)
|
tag_category = ValidateAttr(field='tag_category', type=str)
|
||||||
associate_func = ValidateAttr(field='associate_func', instance_list=AssociateFunc)
|
associate_func = ValidateAttr(field='associate_func', instance_list=AssociateFunc)
|
||||||
|
associate_api = ValidateAttr(field='associate_api', instance_list=AssociateApi)
|
||||||
create_date = ValidateAttr(field='create_date', func=Validate.date_format)
|
create_date = ValidateAttr(field='create_date', func=Validate.date_format)
|
||||||
|
|
||||||
fields_map = {
|
fields_map = {
|
||||||
|
@ -88,5 +99,6 @@ class TagObj(SpecObject):
|
||||||
"tag_field": "标签名称",
|
"tag_field": "标签名称",
|
||||||
"tag_category": "标签类别",
|
"tag_category": "标签类别",
|
||||||
"associate_func": "关联函数",
|
"associate_func": "关联函数",
|
||||||
|
"associate_api": "关联接口",
|
||||||
"create_date": "创建日期"
|
"create_date": "创建日期"
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,3 +68,32 @@ def associate_func_route():
|
||||||
|
|
||||||
except APIReturnError as e:
|
except APIReturnError as e:
|
||||||
return {"info": e.__str__()}, e.status_code
|
return {"info": e.__str__()}, e.status_code
|
||||||
|
|
||||||
|
|
||||||
|
@tags_route.route('/associate_api', methods=['POST'])
|
||||||
|
def associate_api_route():
|
||||||
|
"""关联接口"""
|
||||||
|
try:
|
||||||
|
RouteParamsCheck(request.json, ["tags_id", "api_id", "api_name"]).required()
|
||||||
|
data = request.json
|
||||||
|
impl = TagsImpl()
|
||||||
|
result = impl.associate_api(data=data)
|
||||||
|
return {"info": "关联接口", "result": result}, 200
|
||||||
|
|
||||||
|
except APIReturnError as e:
|
||||||
|
return {"info": e.__str__()}, e.status_code
|
||||||
|
|
||||||
|
|
||||||
|
@tags_route.route('/cancel_associate_api', methods=['GET'])
|
||||||
|
def cancel_associate_api_route():
|
||||||
|
"""取消关联接口"""
|
||||||
|
try:
|
||||||
|
RouteParamsCheck(request.args, ["tag_id", "api_id"]).required()
|
||||||
|
tag_id = request.args['tag_id']
|
||||||
|
api_id = request.args['api_id']
|
||||||
|
impl = TagsImpl()
|
||||||
|
result = impl.cancel_associate_api(tag_id=tag_id, api_id=api_id)
|
||||||
|
return {"info": "关联接口", "result": result}, 200
|
||||||
|
|
||||||
|
except APIReturnError as e:
|
||||||
|
return {"info": e.__str__()}, e.status_code
|
||||||
|
|
Loading…
Reference in New Issue