Skip to content

Commit

Permalink
Merge pull request #61 from Fam-Story/fix/57-omit-fcmtoken
Browse files Browse the repository at this point in the history
Feat: FCM 토큰 새로고침 및 Dto 수정
  • Loading branch information
synoti21 authored Nov 30, 2023
2 parents 20d6b7b + 689182e commit 1be1420
Show file tree
Hide file tree
Showing 33 changed files with 165 additions and 637 deletions.
2 changes: 0 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
UserModule,
FamilyMemberModule,
FamilyScheduleModule,
PhotoModule,
PostModule,
InteractionModule,
} from './module';
Expand All @@ -21,7 +20,6 @@ import { ConfigModule } from '@nestjs/config';
MysqlModule,
FamilyMemberModule,
FamilyScheduleModule,
PhotoModule,
PostModule,
InteractionModule,
AuthModule,
Expand Down
18 changes: 18 additions & 0 deletions src/domain/family_member/dto/request/get-family-info.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { IsNotEmpty, IsNumber, IsString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class GetFamilyInfoDto {
@ApiProperty({ example: 1, description: '가족 고유 ID', nullable: false })
@IsNotEmpty()
@IsNumber()
readonly familyMemberId: number;

@ApiProperty({
example: 'ausdifh.daifu0wierj',
description: '가족 멤버의 FCM 토큰',
nullable: false,
})
@IsNotEmpty()
@IsString()
readonly fcmToken: string;
}
11 changes: 6 additions & 5 deletions src/domain/family_member/family-member.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { CustomApiCreatedResponse } from '../../common/api/response-created.deco
import { CustomApiOKResponse } from '../../common/api/response-ok.decorator';
import { ResponseFamilyDto } from '../family';
import { JwtServiceAuthGuard } from '../../auth/guards/jwt-service-auth.guard';
import { GetFamilyInfoDto } from './dto/request/get-family-info.dto';

@ApiTags('가족 멤버 API')
@Controller('api/family-member')
Expand Down Expand Up @@ -133,16 +134,16 @@ export class FamilyMemberController {
);
}

//가족 정보 반환
@Get('/family')
//가족 정보 반환 (FCM 토큰까지 같이 보내기로 변경)
@Post('/family')
@ApiOperation({
summary: '[가족 구성원] 가족 구성원이 속한 가족의 정보 조회',
description: '가족 구성원이 속한 가족 정보를 반환한다.',
})
@CustomApiOKResponse(ResponseFamilyDto, '가족 정보를 반환한다.')
async findFamilyByMemberId(@Query('familyMemberId') familyMemberId: number) {
@CustomApiCreatedResponse(ResponseFamilyDto, '가족 정보를 반환한다.')
async findFamilyByMemberId(@Body() getFamilyInfoDto: GetFamilyInfoDto) {
const responseFamilyDto: ResponseFamilyDto =
await this.familyMemberService.findFamilyByMemberId(familyMemberId);
await this.familyMemberService.findFamilyByMemberId(getFamilyInfoDto);
return CustomApiResponse.success(
ResponseCode.FAMILY_READ_SUCCESS,
responseFamilyDto,
Expand Down
11 changes: 9 additions & 2 deletions src/domain/family_member/family-member.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { UserException } from '../../common/exception/user.exception';
import { ResponseFamilyDto } from '../family';
import { FamilyMemberException } from '../../common/exception/family-member.exception';
import { FamilyException } from '../../common/exception/family.exception';
import { GetFamilyInfoDto } from './dto/request/get-family-info.dto';

@Injectable()
export class FamilyMemberService {
Expand Down Expand Up @@ -111,16 +112,22 @@ export class FamilyMemberService {

//가족 구성원 ID를 통한 가족 정보 반환
async findFamilyByMemberId(
familyMemberId: number,
getFamilyInfoDto: GetFamilyInfoDto,
): Promise<ResponseFamilyDto> {
const familyMember = await this.familyMemberRepository.findOne({
where: { id: familyMemberId },
where: { id: getFamilyInfoDto.familyMemberId },
relations: ['family'], // Family 테이블과 Join
});

if (!familyMember) {
throw new FamilyMemberException(ResponseCode.FAMILY_MEMBER_NOT_FOUND);
}

// 가족 구성원의 FCM 토큰 업데이트
await this.familyMemberRepository.update(familyMember.id, {
fcmToken: getFamilyInfoDto.fcmToken,
});

return ResponseFamilyDto.from(familyMember.family);
}

Expand Down
3 changes: 0 additions & 3 deletions src/domain/photo/dto/index.ts

This file was deleted.

27 changes: 0 additions & 27 deletions src/domain/photo/dto/request/create-photo.dto.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/domain/photo/dto/request/update-photo.dto.ts

This file was deleted.

45 changes: 0 additions & 45 deletions src/domain/photo/dto/response/response-photo.dto.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/domain/photo/index.ts

This file was deleted.

92 changes: 0 additions & 92 deletions src/domain/photo/photo.controller.ts

This file was deleted.

89 changes: 0 additions & 89 deletions src/domain/photo/photo.service.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/domain/post/dto/request/create-post.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class CreatePostDto {
@IsNumber()
readonly srcMemberId: number;

@ApiProperty({ example: 1, description: '포스트를 작성한 가족의 고유 ID' })
@IsNotEmpty()
@IsNumber()
readonly familyId: number;

@ApiProperty({ example: '푸앙이', description: '포스트의 제목' })
@IsNotEmpty()
@IsString()
Expand Down
2 changes: 2 additions & 0 deletions src/domain/post/dto/request/update-post.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreatePostDto } from './create-post.dto';
import { IsNotEmpty, IsNumber } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class UpdatePostDto extends PartialType(CreatePostDto) {
@ApiProperty({ example: 1, description: '포스트의 고유 ID' })
@IsNotEmpty()
@IsNumber()
postId: number;
Expand Down
Loading

0 comments on commit 1be1420

Please sign in to comment.