File tree Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,13 @@ export interface IPostDTO {
7
7
updated_at ?: string ,
8
8
}
9
9
10
- export interface IPostInputDTO {
10
+ export interface ICreatePostDTO {
11
11
title : string ,
12
12
body : string ,
13
13
user_id : number ,
14
+ }
15
+
16
+ export interface IUpdatePostDTO {
17
+ title : string ,
18
+ body : string ,
14
19
}
Original file line number Diff line number Diff line change 1
- import { IPostInputDTO , IPostDTO } from "../dtos/postDTO"
1
+ import { ICreatePostDTO , IPostDTO } from "../dtos/postDTO"
2
2
3
3
export default class PostMapper {
4
4
public static toDTO ( data : any ) : IPostDTO
@@ -13,7 +13,7 @@ export default class PostMapper{
13
13
}
14
14
}
15
15
16
- public static toInputDTO ( data : any ) : IPostInputDTO
16
+ public static toInputDTO ( data : any ) : ICreatePostDTO
17
17
{
18
18
return {
19
19
title : data . title ,
Original file line number Diff line number Diff line change 1
- import { IPostDTO , IPostInputDTO } from "../../dtos/postDTO"
1
+ import { IPostDTO , ICreatePostDTO , IUpdatePostDTO } from "../../dtos/postDTO"
2
2
3
3
export default interface IPostRepositoryInterface {
4
4
all ( ) : Promise < IPostDTO [ ] >
5
5
find ( id : number ) : Promise < IPostDTO >
6
- create ( data : IPostInputDTO ) : Promise < IPostDTO >
7
- update ( id : number , data : IPostInputDTO ) : Promise < IPostDTO >
6
+ create ( data : ICreatePostDTO ) : Promise < IPostDTO >
7
+ update ( id : number , data : IUpdatePostDTO ) : Promise < IPostDTO >
8
8
delete ( id : number ) : Promise < any >
9
9
}
Original file line number Diff line number Diff line change 1
1
import IPostRepositoryInterface from '../interfaces/postInterface'
2
2
import { injectable } from "inversify"
3
3
import { Post } from "../../entity/Post"
4
- import { IPostDTO , IPostInputDTO } from "../../dtos/postDTO"
4
+ import { IPostDTO , ICreatePostDTO , IUpdatePostDTO } from "../../dtos/postDTO"
5
5
import PostMapper from "../../mappers/PostMapper"
6
6
7
7
@@ -20,7 +20,7 @@ export default class PostRepository implements IPostRepositoryInterface {
20
20
return PostMapper . toDTO ( post ) ;
21
21
}
22
22
23
- public async create ( data : IPostInputDTO ) : Promise < IPostDTO > {
23
+ public async create ( data : ICreatePostDTO ) : Promise < IPostDTO > {
24
24
const post = new Post ( ) ;
25
25
post . title = data . title ;
26
26
post . body = data . body ;
@@ -29,7 +29,7 @@ export default class PostRepository implements IPostRepositoryInterface {
29
29
return PostMapper . toDTO ( post ) ;
30
30
}
31
31
32
- public async update ( id :number , data : IPostInputDTO ) : Promise < IPostDTO > {
32
+ public async update ( id :number , data : IUpdatePostDTO ) : Promise < IPostDTO > {
33
33
const post = await Post . findOne ( id ) ;
34
34
if ( typeof data . title !== 'undefined' || data . title !== null ) { post . title = data . title }
35
35
if ( typeof data . body !== 'undefined' || data . body !== null ) { post . body = data . body }
You can’t perform that action at this time.
0 commit comments