Skip to content

Commit

Permalink
[BE#453] auth type null문제, GET요청에 body를 query로 (#454)
Browse files Browse the repository at this point in the history
* fix: auth_type에러

* fix: timezone get 에러

* fix: datetime으로 변경

* fix: swagger도 datetime으로 변경
  • Loading branch information
yeongbinim authored Dec 13, 2023
1 parent cb23e68 commit a07e4c5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions BE/src/auth/google.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
): Promise<any> {
const user = {
email: email.emails[0].value,
auth_type: 'google',
};
done(null, user);
}
Expand Down
24 changes: 12 additions & 12 deletions BE/src/mates/mates.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ export class MatesController {
@ApiCreatedResponse({
description: 'OK',
})
@ApiBody({
schema: {
properties: {
date: {
type: 'datetime',
example: '2023-11-22T14:00:00+09:00',
description: '날짜',
},
},
},
@ApiQuery({
name: 'datetime',
example: '2023-11-22T14:00:00',
description: '날짜',
})
@ApiQuery({
name: 'timezone',
example: '+09:00',
description: '타임존',
})
@ApiOperation({ summary: '모든 친구들 조회하기 (완)' })
getMates(
@User('id') user_id: number,
@Body('date') date: string,
@Query('datetime') datetime: string,
@Query('timezone') timezone: string,
): Promise<object> {
return this.matesService.getMates(user_id, date);
return this.matesService.getMates(user_id, datetime, timezone);
}

@Get('/status')
Expand Down
13 changes: 10 additions & 3 deletions BE/src/mates/mates.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ export class MatesService {
};
}

async getMates(user_id: number, date: string): Promise<object[]> {
const offset = date.split(/\d\d:\d\d:\d\d/)[1];
async getMates(
user_id: number,
datetime: string,
timezone: string,
): Promise<object[]> {
if (!user_id || !datetime || !timezone) {
throw new BadRequestException('인자의 형식이 잘못되었습니다.');
}
const offset = timezone[0] === ' ' ? `+${timezone.trim()}` : timezone;

const nowUserTime = moment(date)
const nowUserTime = moment(`${datetime}${timezone}`)
.utcOffset(offset)
.format('YYYY-MM-DD HH:mm:ss');

Expand Down

0 comments on commit a07e4c5

Please sign in to comment.