Skip to content

Commit

Permalink
Merge branch 'develop' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondanythings committed Jan 14, 2024
2 parents 1fef4c2 + 0e5a8ea commit aa4fd85
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 3 deletions.
50 changes: 47 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { LetterModule } from './letters/letter.module';
import { AppController } from './app.controller';
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
import { MailsModule } from './mails/mails.module';
import { StatisticsModule } from './statistics/statistics.module';
@Module({
imports: [
PrometheusModule.register(),
Expand Down Expand Up @@ -39,6 +40,7 @@ import { MailsModule } from './mails/mails.module';
CommonModule,
LetterModule,
MailsModule,
StatisticsModule,
],
controllers: [AppController],
providers: [],
Expand Down
39 changes: 39 additions & 0 deletions src/statistics/dto/create-statistic.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ApiProperty } from '@nestjs/swagger';
import {
IsEnum,
IsNumber,
IsOptional,
IsString,
IsUUID,
} from 'class-validator';
import { LETTER_TYPE } from 'src/letters/entities/letter.entity';

export class CreateKakaoShareStatisticRequestDto {
@ApiProperty({
description: `
카카오톡 공유 메세지가 전달된 채딩방의 타입
MemoChat: 나와의 채팅방
DirectChat: 다른 사용자와의 1:1 채팅방
MultiChat: 다른 사용자들과의 그룹 채팅방
OpenDirectChat: 1:1 오픈채팅방
OpenMultiChat: 그룹 오픈채팅방`,
})
@IsString()
CHAT_TYPE: string;
@ApiProperty()
@IsString()
HASH_CHAT_ID: string;
@ApiProperty()
@IsNumber()
TEMPLATE_ID: number;

@ApiProperty()
@IsOptional()
@IsUUID('all')
letterId?: string;

@ApiProperty({ description: '답장하기 일 경우, 답장하는 메일의 아이디' })
@IsOptional()
@IsEnum(LETTER_TYPE)
letterType?: LETTER_TYPE;
}
33 changes: 33 additions & 0 deletions src/statistics/entities/statistic.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { BaseEntity } from 'src/common/entities/base.entity';
import { LETTER_TYPE } from 'src/letters/entities/letter.entity';
import { Column, Entity } from 'typeorm';

@Entity({ name: 'KA_SHARE_ST' })
export class KakaoShareCallbackStatistic extends BaseEntity {
@Column({
name: 'chat_type',
comment: `카카오톡 공유 메시지가 전달된 채팅방의 타입`,
})
chatType: string;

@Column({
name: 'hash_chat_id',
comment: '카카오톡 공유 메세지를 수신한 채팅방의 참고용 ID',
})
hashChatId: string;

@Column({ name: 'template_id', comment: '메세지 템플릿 ID' })
templateId: number;

@Column({ name: 'letter_id', type: 'uuid' })
letterId: string;

@Column({
name: 'letter_type',
comment: '편지 타입',
type: 'enum',
enum: LETTER_TYPE,
nullable: true,
})
letterType: LETTER_TYPE;
}
15 changes: 15 additions & 0 deletions src/statistics/statistics.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Controller, Post, Body } from '@nestjs/common';
import { StatisticsService } from './statistics.service';
import { CreateKakaoShareStatisticRequestDto } from './dto/create-statistic.dto';
import { ApiTags } from '@nestjs/swagger';

@Controller('statistics')
@ApiTags('Statistics API')
export class StatisticsController {
constructor(private readonly statisticsService: StatisticsService) {}

@Post('share/kakao')
create(@Body() createStatisticDto: CreateKakaoShareStatisticRequestDto) {
return this.statisticsService.create(createStatisticDto);
}
}
9 changes: 9 additions & 0 deletions src/statistics/statistics.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { StatisticsService } from './statistics.service';
import { StatisticsController } from './statistics.controller';

@Module({
controllers: [StatisticsController],
providers: [StatisticsService],
})
export class StatisticsModule {}
22 changes: 22 additions & 0 deletions src/statistics/statistics.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Injectable } from '@nestjs/common';
import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource } from 'typeorm';
import { CreateKakaoShareStatisticRequestDto } from './dto/create-statistic.dto';
import { KakaoShareCallbackStatistic } from './entities/statistic.entity';

@Injectable()
export class StatisticsService {
constructor(@InjectDataSource() private readonly dataSource: DataSource) {}
async create(
createKakaoShareStatisticRequestDto: CreateKakaoShareStatisticRequestDto,
) {
const repository = this.dataSource.getRepository(
KakaoShareCallbackStatistic,
);

await repository.save(
repository.create(createKakaoShareStatisticRequestDto),
);
return null;
}
}

0 comments on commit aa4fd85

Please sign in to comment.