相似匹配接口
This commit is contained in:
@@ -3,9 +3,11 @@ from fastapi import APIRouter
|
||||
from app.api import api_test
|
||||
from app.api import api_outfit_matcher
|
||||
from app.api import api_attribute
|
||||
from app.api import api_similar_match
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
router.include_router(api_test.router, tags=["test"], prefix="/test")
|
||||
router.include_router(api_outfit_matcher.router, tags=["outfit_matcher"], prefix="/api/outfit_matcher")
|
||||
router.include_router(api_attribute.router, tags=["attribute"], prefix="/api/attribute")
|
||||
router.include_router(api_similar_match.router, tags=["similar_match"], prefix="/api/similar_match")
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import logging
|
||||
import time
|
||||
|
||||
from fastapi import APIRouter
|
||||
from app.schemas.outfit_matcher import SimilarMatchMItem
|
||||
from app.service.utils.decorator import RunTime
|
||||
|
||||
logger = logging.getLogger()
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@RunTime
|
||||
@router.post("similar_match")
|
||||
def similar_match(request_item: SimilarMatchMItem):
|
||||
|
||||
pass
|
||||
25
app/api/api_similar_match.py
Normal file
25
app/api/api_similar_match.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import logging
|
||||
import time
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.schemas.similar_match import SimilarMatchMItem
|
||||
from app.service.similar_match.service import SimilarMatch
|
||||
from app.service.utils.decorator import RunTime
|
||||
|
||||
logger = logging.getLogger()
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@RunTime
|
||||
@router.post("similar_match")
|
||||
def similar_match(request_item: SimilarMatchMItem):
|
||||
try:
|
||||
if request_item.result_number <= 0:
|
||||
raise KeyError("result number can't be less than 0")
|
||||
service = SimilarMatch(request_item)
|
||||
search_response = service.match_features()
|
||||
return {"message": "ok", "data": search_response}
|
||||
except KeyError as e:
|
||||
logger.warning(str(e))
|
||||
return {"message": "result number can't be less than 0", "data": []}
|
||||
Reference in New Issue
Block a user