File tree 1 file changed +37
-0
lines changed
src/backend/src/repository/typeorm/todo/queryService 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Connection , Repository } from 'typeorm' ;
2
+ import {
3
+ TodoQueryService ,
4
+ DeadlineNearingTodosQuery ,
5
+ DeadlineNearingTodosQueryResult ,
6
+ AllTodosQuery ,
7
+ } from 'domain-model' ;
8
+
9
+ import { Todo as OrmTodo , OrmTodoFactory } from '../entity/Todo' ;
10
+
11
+ export class GqlTodoQueryService implements TodoQueryService {
12
+ private dbConnection : Connection ;
13
+ private repository : Repository < OrmTodo > ;
14
+
15
+ constructor ( dbConnection : Connection ) {
16
+ this . dbConnection = dbConnection ;
17
+ this . repository = this . dbConnection . getRepository ( OrmTodo ) ;
18
+ }
19
+
20
+ public async all ( _query : AllTodosQuery ) {
21
+ // FIXME
22
+ return { todos : null } ;
23
+ }
24
+
25
+ public async allDeadlineNearingTodos ( _query : DeadlineNearingTodosQuery ) {
26
+ // TODO: queryを検査
27
+
28
+ // FIXME: conditionを正しく設定
29
+ const result = await this . repository . find ( { } ) ;
30
+ if ( ! result ) return { todos : null } ;
31
+
32
+ const res : DeadlineNearingTodosQueryResult = {
33
+ todos : result . map ( ( todo ) => OrmTodoFactory . toDto ( todo ) ) ,
34
+ } ;
35
+ return res ;
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments