@@ -18,216 +18,40 @@ export class UserController {
1818
1919 constructor ( @inject ( Types . UserService ) private userService : UserService ) { }
2020
21- /**
22- * @swagger
23- * /user:
24- * get:
25- * tags:
26- * - User
27- * summary: List all users
28- * description: Returns users
29- * security:
30- * - JWT: []
31- * responses:
32- * 200:
33- * description: List of all users
34- * schema:
35- * type: object
36- * title: UserResponse
37- * properties:
38- * success:
39- * type: boolean
40- * message:
41- * type: string
42- * data:
43- * type: array
44- * items:
45- * $ref: "#/definitions/User"
46- */
4721 @Get ( '/' )
4822 public async findAll ( @Response ( ) res : my . Response ) : Promise < any > {
4923 log . debug ( 'findAll' ) ;
5024 const users = await this . userService . findAll ( ) ;
5125 return res . found ( users . toJSON ( ) ) ;
5226 }
5327
54- /**
55- * @swagger
56- * /user:
57- * post:
58- * tags:
59- * - User
60- * summary: Create new user
61- * description: Creates new user and returns him
62- * security:
63- * - JWT: []
64- * parameters:
65- * - in: "body"
66- * name: "body"
67- * required: true
68- * schema:
69- * $ref: "#/definitions/NewUser"
70- * responses:
71- * 200:
72- * description: New user
73- * schema:
74- * type: object
75- * title: UserResponse
76- * properties:
77- * success:
78- * type: boolean
79- * message:
80- * type: string
81- * data:
82- * $ref: "#/definitions/User"
83- */
8428 @Post ( '/' )
8529 public async create ( @Response ( ) res : my . Response , @RequestBody ( ) body : any ) : Promise < any > {
8630 log . debug ( 'create ' , body ) ;
8731 const user = await this . userService . create ( body ) ;
8832 return res . created ( user . toJSON ( ) ) ;
8933 }
9034
91- /**
92- * @swagger
93- * /user/me:
94- * get:
95- * tags:
96- * - User
97- * summary: Get logged in user
98- * description: Returns logged in user
99- * security:
100- * - JWT: []
101- * responses:
102- * 200:
103- * description: User
104- * schema:
105- * type: object
106- * title: UserResponse
107- * properties:
108- * success:
109- * type: boolean
110- * message:
111- * type: string
112- * data:
113- * type: object
114- * $ref: "#/definitions/User"
115- */
11635 @Get ( '/me' , populateUser )
11736 public async findMe ( @Request ( ) req : my . Request , @Response ( ) res : my . Response ) : Promise < any > {
11837 log . debug ( 'findMe' ) ;
11938 return res . found ( req . user ) ;
12039 }
12140
122- /**
123- * @swagger
124- * /user/{id}:
125- * get:
126- * tags:
127- * - User
128- * summary: Get user
129- * description: Returns a user
130- * security:
131- * - JWT: []
132- * responses:
133- * 200:
134- * description: User
135- * schema:
136- * type: object
137- * title: UserResponse
138- * properties:
139- * success:
140- * type: boolean
141- * message:
142- * type: string
143- * data:
144- * type: object
145- * $ref: "#/definitions/User"
146- */
14741 @Get ( '/:id' )
14842 public async findOne ( @Response ( ) res : my . Response , @RequestParam ( 'id' ) id : string ) : Promise < any > {
14943 log . debug ( 'findOne ' , id ) ;
15044 const user = await this . userService . findOne ( parseInt ( id , 10 ) ) ;
15145 return res . found ( user . toJSON ( ) ) ;
15246 }
15347
154- /**
155- * @swagger
156- * /user/{id}:
157- * put:
158- * tags:
159- * - User
160- * summary: Update user
161- * description: Returns a user
162- * security:
163- * - JWT: []
164- * parameters:
165- * - name: "id"
166- * in: "path"
167- * description: "ID of user to return"
168- * required: true
169- * type: "integer"
170- * format: "int64"
171- * - in: "body"
172- * name: "body"
173- * description: "User object"
174- * required: true
175- * schema:
176- * $ref: "#/definitions/NewUser"
177- * responses:
178- * 200:
179- * description: User
180- * schema:
181- * type: object
182- * title: UserResponse
183- * properties:
184- * success:
185- * type: boolean
186- * message:
187- * type: string
188- * data:
189- * type: object
190- * $ref: "#/definitions/User"
191- */
19248 @Put ( '/:id' )
19349 public async update ( @Response ( ) res : my . Response , @RequestParam ( 'id' ) id : string , @RequestBody ( ) body : any ) : Promise < any > {
19450 log . debug ( 'update ' , body ) ;
19551 const user = await this . userService . update ( parseInt ( id , 10 ) , body ) ;
19652 return res . updated ( user . toJSON ( ) ) ;
19753 }
19854
199- /**
200- * @swagger
201- * /user/{id}:
202- * delete:
203- * tags:
204- * - User
205- * summary: Delete user
206- * description: Returns a user
207- * security:
208- * - JWT: []
209- * parameters:
210- * - name: "id"
211- * in: "path"
212- * description: "ID of user to return"
213- * required: true
214- * type: "integer"
215- * format: "int64"
216- * responses:
217- * 200:
218- * description: User
219- * schema:
220- * type: object
221- * title: UserResponse
222- * properties:
223- * success:
224- * type: boolean
225- * message:
226- * type: string
227- * data:
228- * type: object
229- * example:
230- */
23155 @Delete ( '/:id' )
23256 public async destroy ( @Response ( ) res : my . Response , @RequestParam ( 'id' ) id : string ) : Promise < any > {
23357 log . debug ( 'destroy ' , id ) ;
0 commit comments