Skip to content

Commit

Permalink
feat: maininfo - info message add
Browse files Browse the repository at this point in the history
  • Loading branch information
enaenen committed Dec 8, 2023
1 parent 35969f1 commit ec0a831
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/tag-log-v3/dto/UserMonthlyInOutLogs.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { InOutLogType } from './subType/InOutLog.type';
export class UserMonthlyInOutLogsType {
@ApiProperty({
description: '42 로그인 ID',
example: 'joopark',
example: 'wchae',
})
login: string;

@ApiProperty({
description: '인트라 이미지 URI',
example: 'https://cdn.intra.42.fr/users/joopark.jpg',
example: 'https://cdn.intra.42.fr/users/wchae.jpg',
})
profileImage: string;

Expand Down
10 changes: 10 additions & 0 deletions src/tag-log-v3/dto/info-message.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

export class InfoMessageDto {
title: string | null;
content: string | null;

constructor(title: string | null, content: string | null) {
this.title = title;
this.content = content;
}
}
20 changes: 15 additions & 5 deletions src/tag-log-v3/dto/user-Info.type.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import InOut from 'src/enums/inout.enum';
import { InfoMessageDto } from './info-message.dto';

export class UserInfoType {
@ApiProperty({
description: '42 로그인 ID',
example: 'joopark',
example: 'wchae',
})
login: string;

@ApiProperty({
description: '인트라 이미지 URI',
example: 'https://cdn.intra.42.fr/users/joopark.jpg',
example: 'https://cdn.intra.42.fr/users/wchae.jpg',
})
profileImage: string;

Expand All @@ -27,10 +28,19 @@ export class UserInfoType {
gaepo?: number;

@ApiPropertyOptional({
description: '서초 체류인원 (Optional)',
example: 42,
description: '안내 메세지(Optional)',
example: [
{
title: "제목",
content: "메세지"
},
{
title: "제목",
content: "메세지"
},
],
})
seocho?: number;
infoMessages? : InfoMessageDto[];

@ApiProperty({
description: '본인의 클러스터 체류 여부',
Expand Down
12 changes: 10 additions & 2 deletions src/tag-log-v3/tag-log-v3.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { CadetPerClusterDto } from 'src/statistics/dto/cadet-per-cluster.dto';
import { InOutLogPerDay, groupLogsByDay } from './dto/subType/InOutLogPerDay.type';
import { UserMonthlyInOutLogsType } from './dto/UserMonthlyInOutLogs.type';
import { TWELVE_HOURS_IN_SECONDS } from 'src/utils/common.constants';
import { InfoMessageDto } from './dto/info-message.dto';
import { MessageGenerator } from 'src/utils/message-generator.component';

@ApiTags('체류 시간 산출 v3')
@Controller({
Expand All @@ -42,6 +44,7 @@ export class TagLogController {
constructor(
private tagLogService: TagLogService,
private statisticsService: StatisticsService,
private messageGenerator: MessageGenerator,
@Inject(CACHE_MANAGER) private cacheManager: Cache,
) {}

Expand Down Expand Up @@ -140,15 +143,20 @@ export class TagLogController {
await this.cacheManager.set('getCadetPerCluster', cadetPerCluster, 60);
}
const gaepo = +cadetPerCluster.find((v) => v.cluster === 'GAEPO')?.cadet;
const seocho = +cadetPerCluster.find((v) => v.cluster === 'SEOCHO')?.cadet;
// const seocho = +cadetPerCluster.find((v) => v.cluster === 'SEOCHO')?.cadet;

const infoMessages: InfoMessageDto[] = [];
infoMessages.push(this.messageGenerator.generateInfoMessage());

const result: UserInfoType = {
login: user.login,
profileImage: user.image_url,
isAdmin: user.is_staff,
inoutState: inoutState.inout,
tagAt: inoutState.log,
gaepo: gaepo ? gaepo : 0,
seocho: seocho ? seocho : 0,
// seocho: seocho ? seocho : 0,
infoMessages: infoMessages,
};
return result;
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/common.constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export const TWELVE_HOURS_IN_SECONDS = 12 * 60 * 60;
export const ONE_DAY_IN_SECONDS = 24 * 60 * 60;
export const ONE_DAY_IN_SECONDS = 24 * 60 * 60;

export const INFO_MESSAGE_TITLE = "인정 시간은 지원금 정책에 반영되는 시간입니다.";
export const INFO_MESSAGE_CONTENT = "1일 최대 12시간";
15 changes: 15 additions & 0 deletions src/utils/message-generator.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Injectable, Logger } from "@nestjs/common";

Check warning on line 1 in src/utils/message-generator.component.ts

View workflow job for this annotation

GitHub Actions / CI

'Logger' is defined but never used
import { InfoMessageDto } from "src/tag-log-v3/dto/info-message.dto";

@Injectable()
export class MessageGenerator {
// private logger = new Logger(MessageGenerator.name);

generateInfoMessage(): InfoMessageDto {
const INFO_MESSAGE_TITLE: string = "인정 시간은 지원금 정책에 반영되는 시간입니다.";
const INFO_MESSAGE_CONTENT: string = "1일 최대 12시간";
const infoMessage = new InfoMessageDto(INFO_MESSAGE_TITLE, INFO_MESSAGE_CONTENT);
return infoMessage;
}

}
5 changes: 3 additions & 2 deletions src/utils/utils.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Module } from '@nestjs/common';
import { DateCalculator } from './date-calculator.component';
import { GoogleApi } from './google-api.component';
import { MessageGenerator } from './message-generator.component';

@Module({
providers: [DateCalculator, GoogleApi],
exports: [DateCalculator, GoogleApi],
providers: [DateCalculator, GoogleApi, MessageGenerator],
exports: [DateCalculator, GoogleApi, MessageGenerator],
})
export class UtilsModule {}

0 comments on commit ec0a831

Please sign in to comment.