-
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 #105 from Mouwf/feature/add-reply-function
リプライ機能を追加した
- Loading branch information
Showing
82 changed files
with
3,897 additions
and
298 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import PostInteractor from "../../libraries/post/post-interactor"; | ||
|
||
/** | ||
* リプライを行うアクション。 | ||
*/ | ||
export default class ReplyMessageAction { | ||
/** | ||
* リプライを行うアクションを生成する。 | ||
* @param postInteractor 投稿に関する処理を行うクラス。 | ||
*/ | ||
constructor( | ||
private readonly postInteractor: PostInteractor, | ||
) { | ||
} | ||
|
||
/** | ||
* リプライを行う。 | ||
* @param replierId リプライ者ID。 | ||
* @param originalPostId リプライ先投稿ID。 | ||
* @param originalReplyId リプライ先リプライID。 | ||
* @param content リプライ内容。 | ||
*/ | ||
public async reply(replierId: number, originalPostId: number, originalReplyId: number | null, content: string): Promise<number> { | ||
const replyId = await this.postInteractor.reply(replierId, originalPostId, originalReplyId, content); | ||
return replyId; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import systemMessages from "../../messages/system-messages"; | ||
import PostContent from '../../models/post/post-content'; | ||
import IPostContentRepository from '../../repositories/post/i-post-content-repository'; | ||
|
||
/** | ||
* 投稿を取得するクラス。 | ||
*/ | ||
export default class PostFetcher { | ||
/** | ||
* 投稿を取得するクラスを生成する。 | ||
* @param postContentRepository 投稿を取得するリポジトリ。 | ||
*/ | ||
constructor( | ||
private readonly postContentRepository: IPostContentRepository, | ||
) { | ||
} | ||
|
||
/** | ||
* 指定された投稿を取得する。 | ||
* @param postId 投稿ID。 | ||
* @returns 取得した投稿。 | ||
*/ | ||
public async fetchPostById(postId: number): Promise<PostContent> { | ||
try { | ||
const post = await this.postContentRepository.getById(postId); | ||
return post; | ||
} catch (error) { | ||
console.error(error); | ||
if (error instanceof TypeError) throw new Error(systemMessages.error.networkError); | ||
throw new Error(systemMessages.error.postRetrievalFailed); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import systemMessages from "../../messages/system-messages"; | ||
import ReplyContent from "../../models/post/reply-content"; | ||
import IReplyContentRepository from "../../repositories/post/i-reply-content-repository"; | ||
|
||
|
||
/** | ||
* 複数のリプライを取得するクラス。 | ||
*/ | ||
export default class RepliesFetcher { | ||
/** | ||
* 複数のリプライを取得するクラスを生成する。 | ||
* @param replyContentRepository リプライ内容リポジトリ。 | ||
*/ | ||
constructor( | ||
private readonly replyContentRepository: IReplyContentRepository, | ||
) { | ||
} | ||
|
||
/** | ||
* 指定された投稿の全てのリプライを取得する。 | ||
* @param postId 投稿ID。 | ||
* @returns 指定された投稿の全てのリプライ。 | ||
*/ | ||
public async fetchAllByPostId(postId: number): Promise<ReplyContent[]> { | ||
try { | ||
const replies = await this.replyContentRepository.getAllByPostId(postId); | ||
return replies; | ||
} catch (error) { | ||
console.error(error); | ||
if (error instanceof TypeError) throw new Error(systemMessages.error.networkError); | ||
throw new Error(systemMessages.error.replyRetrievalFailed); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import systemMessages from "../../messages/system-messages"; | ||
import ReplyContent from "../../models/post/reply-content"; | ||
import IReplyContentRepository from "../../repositories/post/i-reply-content-repository"; | ||
|
||
/** | ||
* リプライを取得するクラス。 | ||
*/ | ||
export default class ReplyFetcher { | ||
/** | ||
* リプライを取得するクラスを生成する。 | ||
* @param replyContentRepository リプライ内容リポジトリ。 | ||
*/ | ||
constructor( | ||
private readonly replyContentRepository: IReplyContentRepository, | ||
) { | ||
} | ||
|
||
/** | ||
* 指定されたリプライを取得する。 | ||
* @param replyId リプライID。 | ||
* @returns 取得したリプライ。 | ||
*/ | ||
public async fetchReplyById(replyId: number): Promise<ReplyContent> { | ||
try { | ||
const reply = await this.replyContentRepository.getById(replyId); | ||
return reply; | ||
} catch (error) { | ||
console.error(error); | ||
if (error instanceof TypeError) throw new Error(systemMessages.error.networkError); | ||
throw new Error(systemMessages.error.replyRetrievalFailed); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import PostFetcher from "../../libraries/post/post-fetcher"; | ||
import PostContent from "../../models/post/post-content"; | ||
|
||
/** | ||
* 投稿を取得するローダー。 | ||
*/ | ||
export default class PostLoader { | ||
/** | ||
* 投稿を取得するローダーを生成する。 | ||
* @param postFetcher 投稿を取得するクラス。 | ||
*/ | ||
constructor( | ||
private readonly postFetcher: PostFetcher, | ||
) { | ||
} | ||
|
||
/** | ||
* 指定された投稿を取得する。 | ||
* @param postId 投稿ID。 | ||
* @returns 取得した投稿。 | ||
*/ | ||
public async getPostById(postId: number): Promise<PostContent> { | ||
const post = await this.postFetcher.fetchPostById(postId); | ||
return post; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import RepliesFetcher from "../../libraries/post/replies-fetcher"; | ||
import ReplyContent from "../../models/post/reply-content"; | ||
|
||
/** | ||
* 指定された投稿の全てのリプライを取得するローダー。 | ||
*/ | ||
export default class RepliesLoader { | ||
/** | ||
* 指定された投稿の全てのリプライを取得するローダーを生成する。 | ||
* @param repliesFetcher 複数のリプライを取得するクラス。 | ||
*/ | ||
constructor( | ||
private readonly repliesFetcher: RepliesFetcher, | ||
) { | ||
} | ||
|
||
/** | ||
* 指定された投稿の全てのリプライを取得する。 | ||
* @param postId 投稿ID。 | ||
* @returns 指定された投稿の全てのリプライ。 | ||
*/ | ||
public async getAllRepliesByPostId(postId: number): Promise<ReplyContent[]> { | ||
const replies = await this.repliesFetcher.fetchAllByPostId(postId); | ||
return replies; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import ReplyFetcher from "../../libraries/post/reply-fetcher"; | ||
import ReplyContent from "../../models/post/reply-content"; | ||
|
||
/** | ||
* リプライを取得するローダー。 | ||
*/ | ||
export default class ReplyLoader { | ||
/** | ||
* リプライを取得するローダーを生成する。 | ||
* @param replyFetcher リプライを取得するクラス。 | ||
*/ | ||
constructor( | ||
private readonly replyFetcher: ReplyFetcher, | ||
) { | ||
} | ||
|
||
/** | ||
* 指定されたリプライを取得する。 | ||
* @param replyId リプライID。 | ||
* @returns 取得したリプライ。 | ||
*/ | ||
public async getReplyById(replyId: number): Promise<ReplyContent> { | ||
const reply = await this.replyFetcher.fetchReplyById(replyId); | ||
return reply; | ||
} | ||
} |
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
Oops, something went wrong.