-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from takeYY/feat/openapi-response
【更新】OpenAPIのレスポンスを定義
- Loading branch information
Showing
47 changed files
with
1,386 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
api/src/application/film_record/query/interface/film_record_query_domain_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
# 標準ライブラリ | ||
from abc import ABC, abstractmethod | ||
|
||
# 独自ライブラリ | ||
from src.domain.film_record import FilmRecordEntity | ||
|
||
|
||
class IFilmRecordQueryDomainService(ABC): | ||
@abstractmethod | ||
def get_film_records(self): | ||
def get_film_records(self) -> list[FilmRecordEntity]: | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,43 @@ | ||
# 標準ライブラリ | ||
from abc import ABC, abstractmethod | ||
from logging import getLogger | ||
|
||
# 外部ライブラリ | ||
from pyknp import Juman | ||
|
||
# 独自ライブラリ | ||
from schemas.word.word import Word | ||
from src.schemas.jumanpp import JumanppResult, WordRequest | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class JumanppApplication(ABC): | ||
@abstractmethod | ||
async def morphological_analysis(self, target: Word) -> dict[str, str]: | ||
async def morphological_analysis( | ||
self, | ||
target: WordRequest, | ||
) -> list[JumanppResult]: | ||
raise NotImplementedError | ||
|
||
|
||
class ImplJumanppApplication(JumanppApplication): | ||
def __init__(self): | ||
print("application init") | ||
logger.info("jumanpp application init") | ||
|
||
async def morphological_analysis(self, word: Word) -> dict[str, str]: | ||
async def morphological_analysis( | ||
self, | ||
word: WordRequest, | ||
) -> list[JumanppResult]: | ||
try: | ||
print("application analysis") | ||
logger.info("application analysis") | ||
|
||
juman = Juman() | ||
result = juman.analysis(word.target) | ||
result_list = result.mrph_list() | ||
|
||
return dict( | ||
status="success", | ||
result=result_list, | ||
) | ||
except Exception as e: | ||
print(e) | ||
return dict( | ||
status="error", | ||
result=str(e), | ||
) | ||
result_list: list[JumanppResult] = result.mrph_list() | ||
if not result_list: | ||
raise ValueError("形態素解析結果がありません.") | ||
|
||
return result_list | ||
|
||
except Exception: | ||
raise |
5 changes: 4 additions & 1 deletion
5
api/src/domain/film_record/film/genre/film_genre_repository.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# 標準ライブラリ | ||
from abc import ABC, abstractmethod | ||
|
||
# 外部ライブラリ | ||
from dataclass_wizard.type_def import JSONObject | ||
|
||
|
||
class IFilmGenreRepository(ABC): | ||
@abstractmethod | ||
def get_genres(self): | ||
def get_genres(self) -> JSONObject: | ||
raise NotImplementedError |
5 changes: 4 additions & 1 deletion
5
api/src/domain/film_record/film/series/film_series_repository.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# 標準ライブラリ | ||
from abc import ABC, abstractmethod | ||
|
||
# 外部ライブラリ | ||
from dataclass_wizard.type_def import JSONObject | ||
|
||
|
||
class IFilmSeriesRepository(ABC): | ||
@abstractmethod | ||
def get_series(self): | ||
def get_series(self) -> JSONObject: | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
api/src/domain/film_record/watch_history/watch_history_repository.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
# 標準ライブラリ | ||
from abc import ABC, abstractmethod | ||
|
||
# 外部ライブラリ | ||
from dataclass_wizard.type_def import JSONObject | ||
|
||
|
||
class IFilmWatchHistoryRepository(ABC): | ||
@abstractmethod | ||
def get_film_watch_history(self): | ||
def get_film_watch_history(self) -> JSONObject: | ||
raise NotImplementedError |
5 changes: 4 additions & 1 deletion
5
api/src/domain/film_record/watch_medium/watch_medium_repository.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# 標準ライブラリ | ||
from abc import ABC, abstractmethod | ||
|
||
# 外部ライブラリ | ||
from dataclass_wizard.type_def import JSONObject | ||
|
||
|
||
class IWatchMediumRepository(ABC): | ||
@abstractmethod | ||
def get_watch_media(self): | ||
def get_watch_media(self) -> JSONObject: | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 17 additions & 8 deletions
25
api/src/infrastructure/film_record/genre/film_genre_repository.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
# 標準ライブラリ | ||
import os | ||
from logging import getLogger | ||
|
||
# 外部ライブラリ | ||
from dataclass_wizard.type_def import JSONObject | ||
from notion_client import Client | ||
from notion_client.typing import SyncAsync | ||
|
||
# 独自ライブラリ | ||
from src.domain.film_record.film.genre import IFilmGenreRepository | ||
|
||
# 定数 | ||
NOTION_TOKEN = os.environ["NOTION_TOKEN"] | ||
FILM_GENRE_DB_ID = os.environ["FILM_GENRE_DB_ID"] | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class ImplFilmGenreRepository(IFilmGenreRepository): | ||
def __init__(self): | ||
pass | ||
# Notionの設定 | ||
self.notion = Client(auth=NOTION_TOKEN) | ||
self.notion_film_genre_id = FILM_GENRE_DB_ID | ||
|
||
def get_genres(self): | ||
def get_genres(self) -> SyncAsync[JSONObject]: | ||
"""Notionから映画ジャンルデータを取得する""" | ||
logger.info("Notionから映画ジャンルを取得する処理: 開始") | ||
query: dict[str, str] = dict(database_id=self.notion_film_genre_id) | ||
logger.info("Notionから映画ジャンルを取得する処理: 終了") | ||
|
||
notion_token = os.environ["NOTION_TOKEN"] | ||
notion = Client(auth=notion_token) | ||
notion_film_genre_id: str = os.environ["FILM_GENRE_DB_ID"] | ||
|
||
query: dict[str, str] = dict(database_id=notion_film_genre_id) | ||
return notion.databases.query(**query) | ||
return self.notion.databases.query(**query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.