@@ -3,21 +3,15 @@ import Visitor from '../../service/visitor';
33import VisitorRepository from '../../model/visitorRepository' ;
44import { BadRequestError , ServerError } from '../../service/error' ;
55import errorResposne from '../module/error' ;
6- import { VisitorCmtDto , VisitorCmtEntity } from './visitor' ;
6+ import { VisitorCmtDto } from './visitor' ;
77
88/**
9- * @typedef {Object } ResBody
10- * @property {number } statusCode
11- * @property {number } todayCount
12- * @property {number } totalCount
13- * @property {string } todayDate
14- */
15-
16- /**
17- * api description
9+ * Visitor increase and lookup API
1810 * @url /apis/visitor/count
1911 * @method patch
20- * @prooperty {ResBody} res.body
12+ * @resBody `{ statusCode: number, todayCount: number, totalCount: number, todayDate: string }`
13+ * success response body
14+ * @resBody `{ statusCode: number, msg: string }` fail response body
2115 */
2216const updateAndGetVisitor = async ( req : Request , res : Response ) => {
2317 try {
@@ -32,18 +26,12 @@ const updateAndGetVisitor = async (req: Request, res: Response) => {
3226} ;
3327
3428/**
35- * @typedef {Object } ResBody
36- * @property {number } statusCode
37- * @property {number } commentId
38- * @property {string } msg
39- */
40-
41- /**
42- * api description
29+ * Visit comment generation API
4330 * @url /apis/visitor/comment
4431 * @method post
45- * @property {VisitorCmtDto } req.body
46- * @returns {Promise<Response<ResBody>> }
32+ * @reqBody `{ nickname: string, password: string, description: string }`
33+ * @resBody `{ statusCode: number, commendId: number, msg: string }` success response body
34+ * @resBody `{ statusCode: number, msg: string }` fail response body
4735 */
4836const createVisitComment = async ( req : Request , res : Response ) => {
4937 const RequestVisitorComment : VisitorCmtDto = Object . assign ( req . body ) ;
@@ -71,22 +59,17 @@ const createVisitComment = async (req: Request, res: Response) => {
7159} ;
7260
7361/**
74- * @typedef {Object } ResBody
75- * @property {number } statusCode
76- * @property {string } msg
77- */
78-
79- /**
80- * api description
81- * @url /apis/visitor/comment/{id}
62+ * API for editing visited comments
63+ * @url /apis/visitor/comment/:id
8264 * @method patch
83- * @param {VisitorCmtDto } req.body
84- * @returns {Promise<Response<ResBody>> }
65+ * @reqParams `{ id: number }` Unique number of edit comment
66+ * @reqBody `{ password: string, description: string }`
67+ * @resBody `{ statusCode: number, msg: string }` success or fail response body
8568 */
8669const updateVisitCommentById = async ( req : Request , res : Response ) => {
8770 const { id : visitorCommentId } = req . params ;
8871
89- const requestVisitorComment = Object . assign ( req . body ) ;
72+ const requestVisitorComment : VisitorCmtDto = Object . assign ( req . body ) ;
9073
9174 try {
9275 const visitor = new Visitor ( new VisitorRepository ( ) , requestVisitorComment ) ;
@@ -103,18 +86,20 @@ const updateVisitCommentById = async (req: Request, res: Response) => {
10386} ;
10487
10588/**
106- * api description
89+ * All visit comment lookup APIs
10790 * @url /apis/visitor/comments
10891 * @method get
109- * @returns {Promise<Response<VisitorCmtEntity>> }
92+ * @resBody `{ statusCode: number, visitorComments: [{id: number, nickname: string,
93+ description: string, date: string }] }` success response body
94+ * @resBody `{ statusCode: number, mesg: string }` fail response body
11095 */
11196const getVisitorComments = async ( req : Request , res : Response ) => {
11297 try {
11398 const visitor = new Visitor ( new VisitorRepository ( ) ) ;
11499
115- const response = await visitor . getVisitorComments ( ) ;
100+ const { visitorComments } = await visitor . getVisitorComments ( ) ;
116101
117- return res . status ( 200 ) . json ( { statusCode : 200 , ... response } ) ;
102+ return res . status ( 200 ) . json ( { statusCode : 200 , visitorComments } ) ;
118103 } catch ( err ) {
119104 return errorResposne ( err , res ) ;
120105 }
@@ -127,10 +112,12 @@ const getVisitorComments = async (req: Request, res: Response) => {
127112 */
128113
129114/**
130- * api description
131- * @url /apis/visitor/comment/{id}
115+ * Visit comment delete API
116+ * @url /apis/visitor/comment/:id
132117 * @method delete
133- * @returns {Promise<Response<ResBody>> }
118+ * @reqParams `{ id: number }` Unique ID of the target to be deleted
119+ * @resBody `{ statusCode: number, msg: string }` success response body
120+ * @resBody `{ statusCode: number, msg: string }` fail response body
134121 */
135122const deleteVisitorCommentById = async ( req : Request , res : Response ) => {
136123 try {
0 commit comments