1- import { Body , Controller , Get , Post , Route , SuccessResponse , Tags , Response , Request , Middlewares , Query } from 'tsoa' ;
1+ import { Body , Controller , Get , Post , Route , SuccessResponse , Tags , Response , Request , Middlewares , Query , Patch } from 'tsoa' ;
22import { ITsoaErrorResponse , ITsoaSuccessResponse , TsoaSuccessResponse } from '../config/tsoaResponse' ;
33import { Request as ExpressRequest } from 'express' ;
44import { exceedLimitError , nonData , nonPostComment , postTodayError } from './coffeeChat.Message' ;
@@ -338,4 +338,116 @@ export class HomeController extends Controller {
338338 return new TsoaSuccessResponse < CoffeeChatRecordDetail > ( result ) ;
339339 } ;
340340
341+ /**
342+ * Coffect coffeeChat Home API.
343+ *
344+ * @summary 커피챗 일정등록 API
345+ * @param body 유저 Token
346+ * @returns 요청 성공 여부
347+ */
348+ @Patch ( 'fixCoffeeChatSchedule' )
349+ @Middlewares ( verify )
350+ @SuccessResponse ( '200' , '정상적으로 커피챗 일정을 수정하였습니다다.' )
351+ @Response < ITsoaErrorResponse > (
352+ 400 ,
353+ 'Bad Request' ,
354+ {
355+ resultType : 'FAIL' ,
356+ error : {
357+ errorCode : 'HE402' ,
358+ reason : '내용이 누락되었습니다.' ,
359+ data : null
360+ } ,
361+ success : null
362+ } )
363+ @Response < ITsoaErrorResponse > (
364+ 500 ,
365+ 'Internal Server Error' ,
366+ {
367+ resultType : 'FAIL' ,
368+ error : {
369+ errorCode : 'HE500' ,
370+ reason : '서버 오류가 발생했습니다.' ,
371+ data : null
372+ } ,
373+ success : null
374+ } )
375+ public async fixCoffeeChatSchedule (
376+ @Request ( ) req : ExpressRequest ,
377+ @Body ( ) body : {
378+ coffectId : number ;
379+ coffeeDate : Date ;
380+ location : string ;
381+ time : Date ;
382+ } ,
383+ ) :Promise < ITsoaSuccessResponse < string > > {
384+ const userId = req . decoded . index ;
385+ const { coffectId, coffeeDate, location, time } = body ;
386+
387+ if ( coffectId === null ) {
388+ throw new nonPostComment ( '커피챗 일정 번호가 누락되었습니다.' ) ;
389+ } else if ( coffeeDate === null ) {
390+ throw new nonPostComment ( '일정이 누락되었습니다.' ) ;
391+ } else if ( location === null ) {
392+ throw new nonPostComment ( '위치가 누락되었습니다.' ) ;
393+ } else if ( time === null ) {
394+ throw new nonPostComment ( '시간이 누락되었습니다.' ) ;
395+ }
396+
397+ const result = await this . homeService . fixCoffeeChatScheduleService ( userId , coffectId , coffeeDate , location , time ) ;
398+
399+ return new TsoaSuccessResponse < string > ( '정상적으로 커피챗 일정을 등록했습니다.' ) ;
400+ } ;
401+
402+ /**
403+ * Coffect coffeeChat Home API.
404+ *
405+ * @summary 커피챗 승낙 API
406+ * @param body 유저 Token
407+ * @returns 요청 성공 여부
408+ */
409+ @Patch ( 'acceptCoffeeChat' )
410+ @Middlewares ( verify )
411+ @SuccessResponse ( '200' , '성공적으로 커피챗을 승낙했습니다.' )
412+ @Response < ITsoaErrorResponse > (
413+ 400 ,
414+ 'Bad Request' ,
415+ {
416+ resultType : 'FAIL' ,
417+ error : {
418+ errorCode : 'HE404' ,
419+ reason : '존재하지 않는 커피챗 일정입니다.' ,
420+ data : null
421+ } ,
422+ success : null
423+ } )
424+ @Response < ITsoaErrorResponse > (
425+ 500 ,
426+ 'Internal Server Error' ,
427+ {
428+ resultType : 'FAIL' ,
429+ error : {
430+ errorCode : 'HE500' ,
431+ reason : '서버 오류가 발생했습니다.' ,
432+ data : null
433+ } ,
434+ success : null
435+ } )
436+ public async acceptCoffeeChat (
437+ @Request ( ) req : ExpressRequest ,
438+ @Body ( ) body : {
439+ coffectId : number ;
440+ } ,
441+ ) :Promise < ITsoaSuccessResponse < string > > {
442+ const userId = req . decoded . index ;
443+ const { coffectId } = body ;
444+
445+ if ( coffectId === null ) {
446+ throw new nonData ( '존재하지 않는 커피챗입니다.' ) ;
447+ }
448+
449+ await this . homeService . acceptCoffeeChatService ( userId , coffectId ) ;
450+
451+ return new TsoaSuccessResponse < string > ( '정상적으로 커피챗을 승낙했습니다.' ) ;
452+ } ;
341453}
0 commit comments