Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop to main #212

Merged
merged 21 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7e4a5c1
add: where42 api
niamu01 Jul 3, 2024
88c05f5
user 정보에 admin여부 추가 및 id배열->정보배열 인터페이스 추가 구현
niamu01 Jul 3, 2024
44bc813
전체 입실여부 조회 함수 중 db조회 방법에 따른 속도 비교
niamu01 Jul 3, 2024
e1cf923
refactor: 비동기로 데이터 삽입하도록 변경
niamu01 Jul 3, 2024
cd09465
delete: 속도 비교 후 느린 버전 삭제
niamu01 Jul 3, 2024
f20258d
chore: minor version update
niamu01 Jul 3, 2024
c913554
package version update
niamu01 Jul 3, 2024
c8a752d
style: importSorting
niamu01 Jul 3, 2024
92fd9fc
revert: Where42ResponseDto 변경 전으로 복구
niamu01 Jul 5, 2024
2aff8e0
Merge pull request #207 from innovationacademy-kr/addWhere42API
niamu01 Jul 9, 2024
ec8858e
refactor: :recycle: where42All api의 반환값 타입 새로운 요청대로 변환
niamu01 Jul 9, 2024
9a72b29
refactor: :recycle: 날짜 연산 함수들의 전반적인 리팩토링
niamu01 Jul 9, 2024
01c0a4b
refactor: :recycle: 클러스터의 오픈일 상수 추가, 현재 시간을 반환하는 함수 추가
niamu01 Jul 9, 2024
18dadbd
refactor: :recycle: null로 조회되는 정보에 대해 클러스터 또한 null로 반환 (nullable)
niamu01 Jul 9, 2024
64dff67
refactor: :recycle: api base url 변경
niamu01 Jul 9, 2024
d5b332c
module import 오류 수정
niamu01 Jul 9, 2024
edad3c0
Merge pull request #209 from innovationacademy-kr/refactor/where42api
niamu01 Jul 9, 2024
39f6dc6
refactor: request body 형식 변경
niamu01 Jul 15, 2024
2a7617f
Merge pull request #210 from innovationacademy-kr/refactor/where42api
niamu01 Jul 15, 2024
562d790
chore: :art: swagger 설명 추가
niamu01 Jul 15, 2024
67cda1a
Merge remote-tracking branch 'origin/refactor/where42api' into develop
niamu01 Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 33 additions & 65 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "24hane",
"version": "5.0.0",
"version": "5.1.0",
"description": "24Hane Backend Server",
"author": "joohongpark, niamu01, enaenen",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Inject, Injectable, Logger } from '@nestjs/common';
import { IAuthRepository } from './repository/auth.repository.interface';
import { UserSessionDto } from 'src/auth/dto/user.session.dto';
import { IAuthRepository } from './repository/auth.repository.interface';

@Injectable()
export class AuthService {
Expand Down
4 changes: 2 additions & 2 deletions src/auth/guard/jwt-sign.guard.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Request, Response } from 'express';
import {
CanActivate,
ExecutionContext,
Injectable,
Logger,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { JwtService } from '@nestjs/jwt';
import { Request, Response } from 'express';
import { Observable } from 'rxjs';
import { UserSessionDto } from 'src/auth/dto/user.session.dto';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/auth/srategy/auth.admin.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExtractJwt, Strategy } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { UserSessionDto } from '../dto/user.session.dto';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/auth/srategy/auth.external.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExtractJwt, Strategy } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';

/**
* 외부 API용 passport-jwt Strategy
Expand Down
4 changes: 2 additions & 2 deletions src/auth/srategy/auth.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExtractJwt, Strategy } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { UserSessionDto } from '../dto/user.session.dto';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/entities/alive.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Cluster from 'src/enums/cluster.enum';
import { Entity, Column, Index, PrimaryGeneratedColumn } from 'typeorm';
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';

// deprecated
@Entity()
Expand Down
2 changes: 1 addition & 1 deletion src/entities/card-issuance.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Entity,
Column,
Entity,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
Expand Down
2 changes: 1 addition & 1 deletion src/entities/device-info.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Cluster from 'src/enums/cluster.enum';
import InOut from 'src/enums/inout.enum';
import { Entity, Column, PrimaryColumn } from 'typeorm';
import { Column, Entity, PrimaryColumn } from 'typeorm';

@Entity('DEVICE_INFO')
export class DeviceInfo {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/inout.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Cluster from 'src/enums/cluster.enum';
import InOut from 'src/enums/inout.enum';
import { Entity, Column, Index, PrimaryGeneratedColumn } from 'typeorm';
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';

// deprecated
@Entity()
Expand Down
2 changes: 1 addition & 1 deletion src/entities/tag-log.entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('TAG_LOG')
export class TagLog {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/user-info.entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Entity, Column, OneToMany, PrimaryColumn } from 'typeorm';
import { Column, Entity, OneToMany, PrimaryColumn } from 'typeorm';
import { CardIssuance } from './card-issuance.entity';

@Entity('USER_INFO')
Expand Down
2 changes: 1 addition & 1 deletion src/enums/cluster.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
*/
enum Cluster {
GAEPO = 'GAEPO',
SEOCHO = 'SEOCHO',
//SEOCHO = 'SEOCHO',
}
export default Cluster;
8 changes: 5 additions & 3 deletions src/external/where42/dto/where42.response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ export class Where42ResponseDto {
example: Cluster.GAEPO,
})
cluster: Cluster;
}

export class Where42RequestDto {
@ApiProperty({
description: '마지막으로 태깅한 시간',
type: Date,
description: '42 로그인 ID',
example: 'yeju',
})
tag_at: Date;
login: string;
}
49 changes: 47 additions & 2 deletions src/external/where42/where42.controller.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import { Controller, Get, Logger, Param, UseGuards } from '@nestjs/common';
import {
Body,
Controller,
Get,
Logger,
Param,
Post,
UseGuards,
} from '@nestjs/common';
import {
ApiBearerAuth,
ApiBody,
ApiOperation,
ApiParam,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { ExtAuthGuard } from 'src/auth/guard/ext-auth.guard';
import { Where42ResponseDto } from './dto/where42.response.dto';
import {
Where42RequestDto,
Where42ResponseDto,
} from './dto/where42.response.dto';
import { Where42Service } from './where42.service';

@ApiTags('Where42 전용 API')
Expand Down Expand Up @@ -50,4 +62,37 @@ export class Where42Controller {
this.logger.debug(`@islogin) where42: ${login}`);
return this.where42Service.where42(login);
}

/**
* 여러 사용자가 클러스터에 체류중인지 확인합니다.
*
* @param logins 유저 로그인 ID (Where42RequestDto) 리스트
* @returns Where42ResponseDto[]
*/
@ApiOperation({
summary: '여러 카뎃들의 클러스터 체류여부 확인',
description:
'여러명의 카뎃이 클러스터에 체류중인지 한번에 확인합니다. 마지막으로 체류했던 체류중인 클러스터의 장소 정보도 함께 가져옵니다.',
})
@ApiResponse({
status: 200,
type: Where42ResponseDto,
isArray: true,
description: '조회 성공',
})
@ApiResponse({ status: 401, description: '접근 권한 없음 (토큰 만료 등)' })
@ApiResponse({ status: 403, description: '태그 기록이 존재하지 않는 카뎃' })
@ApiResponse({ status: 500, description: '서버 내부 에러' })
@ApiBody({
type: [Where42RequestDto],
description: '유저 로그인 ID 객체의 배열',
})
@Post('where42/where42All')
async where42All(
@Body() logins: Where42RequestDto[],
): Promise<Where42ResponseDto[]> {
this.logger.debug(`@where42All) where42All`);
const loginList = logins.map((loginDto) => loginDto.login);
return this.where42Service.where42All(loginList);
}
}
7 changes: 6 additions & 1 deletion src/external/where42/where42.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DeviceInfo } from 'src/entities/device-info.entity';
import { TagLog } from 'src/entities/tag-log.entity';
import { TagLogRepository } from 'src/tag-log/repository/mysql/tag-log.repository';
import { UserModule } from 'src/user/user.module';
import { DateCalculatorModule } from 'src/utils/data-calculator/data-calculator.module';
import { DeviceInfoRepository } from './repository/mysql/device-info.repository';
import { Where42Controller } from './where42.controller';
import { Where42Service } from './where42.service';
Expand All @@ -22,7 +23,11 @@ const deviceInfoRepo = {
* 24Hane 기능 외 다른 서비스에서 사용하는 외부 API 모듈
*/
@Module({
imports: [UserModule, TypeOrmModule.forFeature([DeviceInfo, TagLog])],
imports: [
UserModule,
TypeOrmModule.forFeature([DeviceInfo, TagLog]),
DateCalculatorModule,
],
controllers: [Where42Controller],
providers: [tagLogRepo, deviceInfoRepo, Where42Service],
})
Expand Down
Loading
Loading