File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { TYPES } from "../types"
2
+ import IPostRepositoryInterface from "../repositories/interfaces/postInterface"
3
+ import { inject , injectable } from "inversify"
4
+ import { ICreatePostDTO , IUpdatePostDTO } from "../dtos/postDTO"
5
+
6
+
7
+ @injectable ( )
8
+ export default class PostService {
9
+ public postRepo : IPostRepositoryInterface
10
+
11
+ constructor ( @inject ( TYPES . IPostRepositoryInterface ) postRepo : IPostRepositoryInterface ) {
12
+ this . postRepo = postRepo ;
13
+ }
14
+
15
+ public async getAll ( ) {
16
+ return await this . postRepo . all ( ) ;
17
+ }
18
+
19
+ public async find ( id : number ) {
20
+ return await this . postRepo . find ( id ) ;
21
+ }
22
+
23
+ public async create ( inputData : ICreatePostDTO ) {
24
+ return await this . postRepo . create ( inputData ) ;
25
+ }
26
+
27
+ public async update ( id : number , inputData : IUpdatePostDTO ) {
28
+ return await this . postRepo . update ( id , inputData ) ;
29
+ }
30
+
31
+ public async delete ( id ) {
32
+ await this . postRepo . delete ( id ) ;
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ import { TYPES } from "../types"
2
+ import IUserRepositoryInterface from "../repositories/interfaces/userInterface"
3
+ import { inject , injectable } from "inversify"
4
+ import { IUserDTO } from "../dtos/userDTO"
5
+
6
+
7
+ @injectable ( )
8
+ export default class userService {
9
+ public userRepo : IUserRepositoryInterface
10
+
11
+ constructor ( @inject ( TYPES . IUserRepositoryInterface ) userRepo : IUserRepositoryInterface ) {
12
+ this . userRepo = userRepo ;
13
+ }
14
+
15
+ public async getAll ( ) : Promise < IUserDTO [ ] > {
16
+ return await this . userRepo . all ( ) ;
17
+ }
18
+
19
+ public async find ( id : number ) : Promise < IUserDTO > {
20
+ return await this . userRepo . find ( id ) ;
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments