From 7e4a5c13aa978316bad57d45caedc862821a517b Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 19:44:35 +0900 Subject: [PATCH 1/9] add: where42 api --- .../where42/dto/where42.response.dto.ts | 17 ++------------- src/external/where42/where42.controller.ts | 16 +++++++++++++- src/external/where42/where42.service.ts | 21 +++++++++++++++++-- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/external/where42/dto/where42.response.dto.ts b/src/external/where42/dto/where42.response.dto.ts index 2a40b1d..729e85b 100644 --- a/src/external/where42/dto/where42.response.dto.ts +++ b/src/external/where42/dto/where42.response.dto.ts @@ -10,22 +10,9 @@ export class Where42ResponseDto { login: string; @ApiProperty({ - description: '클러스터 체류 여부', + description: '클러스터 체류 여부, bocal은 null', enum: InOut, example: InOut.OUT, }) - inoutState: InOut; - - @ApiProperty({ - description: '체류중인 클러스터', - enum: Cluster, - example: Cluster.GAEPO, - }) - cluster: Cluster; - - @ApiProperty({ - description: '마지막으로 태깅한 시간', - type: Date, - }) - tag_at: Date; + inoutState: InOut | null; } diff --git a/src/external/where42/where42.controller.ts b/src/external/where42/where42.controller.ts index cf8cdea..537c2cd 100644 --- a/src/external/where42/where42.controller.ts +++ b/src/external/where42/where42.controller.ts @@ -1,4 +1,12 @@ -import { Controller, Get, Logger, Param, UseGuards } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Logger, + Param, + Post, + UseGuards, +} from '@nestjs/common'; import { ApiBearerAuth, ApiOperation, @@ -50,4 +58,10 @@ export class Where42Controller { this.logger.debug(`@islogin) where42: ${login}`); return this.where42Service.where42(login); } + + @Post('where42All') + async where42All(@Body() logins: string[]): Promise { + this.logger.debug(`@where42All) where42All`); + return this.where42Service.where42All(logins); + } } diff --git a/src/external/where42/where42.service.ts b/src/external/where42/where42.service.ts index 4b0de3b..ff14578 100644 --- a/src/external/where42/where42.service.ts +++ b/src/external/where42/where42.service.ts @@ -1,9 +1,11 @@ import { BadRequestException, + Body, ForbiddenException, Inject, Injectable, Logger, + Post, } from '@nestjs/common'; import { ITagLogRepository } from 'src/tag-log/repository/interface/tag-log-repository.interface'; import { UserService } from 'src/user/user.service'; @@ -51,8 +53,23 @@ export class Where42Service { return { login, inoutState: device.inoutState, - cluster: device.cluster, - tag_at: last.tag_at, }; } + + @Post('where42All') + async where42All(@Body() logins: string[]): Promise { + const res = []; + for (const login of logins) { + try { + res.push(await this.where42(login)); + } catch (e) { + this.logger.error('정상적인 조회가 아님'); + res.push({ + login, + inoutState: null, + }); + } + } + return res; + } } From 88c05f50736c677ce813467259ff122e2308d067 Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 20:30:42 +0900 Subject: [PATCH 2/9] =?UTF-8?q?user=20=EC=A0=95=EB=B3=B4=EC=97=90=20admin?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20id?= =?UTF-8?q?=EB=B0=B0=EC=97=B4->=EC=A0=95=EB=B3=B4=EB=B0=B0=EC=97=B4=20?= =?UTF-8?q?=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/dto/id-login.dto.ts | 6 ++++++ .../user-info-repository.interface.ts | 8 ++++++++ .../repository/mysql/user-info.repository.ts | 18 +++++++++++++++--- src/user/user.service.ts | 11 +++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/user/dto/id-login.dto.ts b/src/user/dto/id-login.dto.ts index 4ac23bf..fa3071d 100644 --- a/src/user/dto/id-login.dto.ts +++ b/src/user/dto/id-login.dto.ts @@ -12,4 +12,10 @@ export class IdLoginDto { example: 'joopark', }) login: string; + + @ApiProperty({ + description: '관리자 여부', + example: true, + }) + is_admin: boolean; } diff --git a/src/user/repository/interface/user-info-repository.interface.ts b/src/user/repository/interface/user-info-repository.interface.ts index 09b40ea..433a549 100644 --- a/src/user/repository/interface/user-info-repository.interface.ts +++ b/src/user/repository/interface/user-info-repository.interface.ts @@ -28,4 +28,12 @@ export interface IUserInfoRepository { * @param admin true: 관리자만, false: 카뎃만, undefined: 모두 */ getAllIds(admin?: boolean): Promise; + + /** + * 로그인 ID 배열에 해당하는 사용자 정보를 반환합니다. + * + * @param logins 로그인 ID 배열 + * @returns 사용자 정보 배열 + */ + findUsersByLogins(logins: string[]): Promise; } diff --git a/src/user/repository/mysql/user-info.repository.ts b/src/user/repository/mysql/user-info.repository.ts index af6eab2..211fd2b 100644 --- a/src/user/repository/mysql/user-info.repository.ts +++ b/src/user/repository/mysql/user-info.repository.ts @@ -1,9 +1,9 @@ import { InjectRepository } from '@nestjs/typeorm'; import { UserInfo } from 'src/entities/user-info.entity'; -import { IUserInfoRepository } from '../interface/user-info-repository.interface'; -import { Repository, MoreThanOrEqual, LessThanOrEqual } from 'typeorm'; -import { IdLoginDto } from 'src/user/dto/id-login.dto'; import { CardDto } from 'src/user/dto/card.dto'; +import { IdLoginDto } from 'src/user/dto/id-login.dto'; +import { In, LessThanOrEqual, MoreThanOrEqual, Repository } from 'typeorm'; +import { IUserInfoRepository } from '../interface/user-info-repository.interface'; export class UserInfoRepository implements IUserInfoRepository { constructor( @@ -65,6 +65,18 @@ export class UserInfoRepository implements IUserInfoRepository { return result.map((r) => ({ user_id: r.user_id, login: r.login, + is_admin: r.is_admin, + })); + } + + async findUsersByLogins(logins: string[]): Promise { + const users = await this.userInfoRepository.find({ + where: { login: In(logins) }, + }); + return users.map((user) => ({ + user_id: user.user_id, + login: user.login, + is_admin: user.is_admin, })); } } diff --git a/src/user/user.service.ts b/src/user/user.service.ts index 7def36c..8ce972f 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -51,4 +51,15 @@ export class UserService { this.logger.debug(`@getAllIds) ${admin}`); return await this.userInfoRepository.getAllIds(admin); } + + /** + * 로그인 ID 배열에 해당하는 사용자 정보를 반환합니다. + * + * @param logins 로그인 ID 배열 + * @returns 사용자 정보 배열 + */ + async findUsersByLogins(logins: string[]): Promise { + this.logger.debug(`@findUsersByLogins) ${logins}`); + return await this.userInfoRepository.findUsersByLogins(logins); + } } From 44bc81329541991eee8fce7c52a49e735ce3d4d9 Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 20:31:27 +0900 Subject: [PATCH 3/9] =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EC=9E=85=EC=8B=A4?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=A1=B0=ED=9A=8C=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=A4=91=20db=EC=A1=B0=ED=9A=8C=20=EB=B0=A9=EB=B2=95=EC=97=90?= =?UTF-8?q?=20=EB=94=B0=EB=A5=B8=20=EC=86=8D=EB=8F=84=20=EB=B9=84=EA=B5=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/external/where42/where42.controller.ts | 6 +++ src/external/where42/where42.service.ts | 63 ++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/src/external/where42/where42.controller.ts b/src/external/where42/where42.controller.ts index 537c2cd..d63c7bf 100644 --- a/src/external/where42/where42.controller.ts +++ b/src/external/where42/where42.controller.ts @@ -64,4 +64,10 @@ export class Where42Controller { this.logger.debug(`@where42All) where42All`); return this.where42Service.where42All(logins); } + + @Post('where42All2') + async where42All2(@Body() logins: string[]): Promise { + this.logger.debug(`@where42All) where42All`); + return this.where42Service.where42All2(logins); + } } diff --git a/src/external/where42/where42.service.ts b/src/external/where42/where42.service.ts index ff14578..fa4c594 100644 --- a/src/external/where42/where42.service.ts +++ b/src/external/where42/where42.service.ts @@ -8,6 +8,7 @@ import { Post, } from '@nestjs/common'; import { ITagLogRepository } from 'src/tag-log/repository/interface/tag-log-repository.interface'; +import { IdLoginDto } from 'src/user/dto/id-login.dto'; import { UserService } from 'src/user/user.service'; import { Where42ResponseDto } from './dto/where42.response.dto'; import { IDeviceInfoRepository } from './repository/interface/device-info.repository.interface'; @@ -72,4 +73,66 @@ export class Where42Service { } return res; } + + @Post('where42All2') + async where42All2(@Body() logins: string[]): Promise { + const users = await this.userService.findUsersByLogins(logins); + const userMap = new Map( + users.map((user) => [user.login, user]), + ); + + const res = []; + + for (const login of logins) { + try { + const user = userMap.get(login); + if (!user) { + throw new BadRequestException('존재하지 않는 유저 ID입니다.'); + } + + const isAdmin = user.is_admin; + + if (isAdmin) { + res.push({ + login, + inoutState: null, + }); + continue; + } + + const cards = await this.userService.findCardsByUserId( + user.user_id, + new Date('2019-01-01 00:00:00'), + new Date(), // NOTE: 대략 42 클러스터 오픈일부터 지금까지 조회 + ); + + const last = await this.tagLogRepository.findLatestTagLog(cards); + if (last === null) { + throw new ForbiddenException('태그 기록이 존재하지 않습니다.'); + } + + const device = await this.deviceInfoRepository.getDeviceInfo( + last.device_id, + ); + if (device === null) { + throw new ForbiddenException( + '등록되지 않은 기기에 태그하였습니다. 관리자에게 문의하세요.', + ); + } + + res.push({ + login, + inoutState: device.inoutState, + }); + } catch (e) { + this.logger.error(`정상적인 조회가 아님: ${login}`); + res.push({ + login, + inoutState: null, + }); + } + } + + return res; + } } From e1cf923869f5c765d73043e70b340f4d8e3a0cba Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 20:36:58 +0900 Subject: [PATCH 4/9] =?UTF-8?q?refactor:=20=EB=B9=84=EB=8F=99=EA=B8=B0?= =?UTF-8?q?=EB=A1=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=82=BD=EC=9E=85?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/external/where42/where42.service.ts | 87 +++++++++++++------------ 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/src/external/where42/where42.service.ts b/src/external/where42/where42.service.ts index fa4c594..7e1a27e 100644 --- a/src/external/where42/where42.service.ts +++ b/src/external/where42/where42.service.ts @@ -76,62 +76,63 @@ export class Where42Service { @Post('where42All2') async where42All2(@Body() logins: string[]): Promise { + const res: Where42ResponseDto[] = []; + const users = await this.userService.findUsersByLogins(logins); const userMap = new Map( users.map((user) => [user.login, user]), ); - const res = []; + await Promise.all( + logins.map(async (login) => { + try { + const user = userMap.get(login); + if (!user) { + throw new BadRequestException('존재하지 않는 유저 ID입니다.'); + } + + const isAdmin = user.is_admin; + if (isAdmin) { + res.push({ + login, + inoutState: null, + }); + return; + } + + const cards = await this.userService.findCardsByUserId( + user.user_id, + new Date('2019-01-01 00:00:00'), + new Date(), // NOTE: 대략 42 클러스터 오픈일부터 지금까지 조회 + ); - for (const login of logins) { - try { - const user = userMap.get(login); - if (!user) { - throw new BadRequestException('존재하지 않는 유저 ID입니다.'); - } + const last = await this.tagLogRepository.findLatestTagLog(cards); + if (last === null) { + throw new ForbiddenException('태그 기록이 존재하지 않습니다.'); + } - const isAdmin = user.is_admin; + const device = await this.deviceInfoRepository.getDeviceInfo( + last.device_id, + ); + if (device === null) { + throw new ForbiddenException( + '등록되지 않은 기기에 태그하였습니다. 관리자에게 문의하세요.', + ); + } - if (isAdmin) { + res.push({ + login, + inoutState: device.inoutState, + }); + } catch (e) { + this.logger.error(`정상적인 조회가 아님: ${login}`); res.push({ login, inoutState: null, }); - continue; - } - - const cards = await this.userService.findCardsByUserId( - user.user_id, - new Date('2019-01-01 00:00:00'), - new Date(), // NOTE: 대략 42 클러스터 오픈일부터 지금까지 조회 - ); - - const last = await this.tagLogRepository.findLatestTagLog(cards); - if (last === null) { - throw new ForbiddenException('태그 기록이 존재하지 않습니다.'); - } - - const device = await this.deviceInfoRepository.getDeviceInfo( - last.device_id, - ); - if (device === null) { - throw new ForbiddenException( - '등록되지 않은 기기에 태그하였습니다. 관리자에게 문의하세요.', - ); } - - res.push({ - login, - inoutState: device.inoutState, - }); - } catch (e) { - this.logger.error(`정상적인 조회가 아님: ${login}`); - res.push({ - login, - inoutState: null, - }); - } - } + }), + ); return res; } From cd094659c0bc72128af76513c4ef3610ccb4a78c Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 20:43:09 +0900 Subject: [PATCH 5/9] =?UTF-8?q?delete:=20=EC=86=8D=EB=8F=84=20=EB=B9=84?= =?UTF-8?q?=EA=B5=90=20=ED=9B=84=20=EB=8A=90=EB=A6=B0=20=EB=B2=84=EC=A0=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/external/where42/where42.controller.ts | 6 ------ src/external/where42/where42.service.ts | 17 ----------------- 2 files changed, 23 deletions(-) diff --git a/src/external/where42/where42.controller.ts b/src/external/where42/where42.controller.ts index d63c7bf..537c2cd 100644 --- a/src/external/where42/where42.controller.ts +++ b/src/external/where42/where42.controller.ts @@ -64,10 +64,4 @@ export class Where42Controller { this.logger.debug(`@where42All) where42All`); return this.where42Service.where42All(logins); } - - @Post('where42All2') - async where42All2(@Body() logins: string[]): Promise { - this.logger.debug(`@where42All) where42All`); - return this.where42Service.where42All2(logins); - } } diff --git a/src/external/where42/where42.service.ts b/src/external/where42/where42.service.ts index 7e1a27e..a4f74fc 100644 --- a/src/external/where42/where42.service.ts +++ b/src/external/where42/where42.service.ts @@ -59,23 +59,6 @@ export class Where42Service { @Post('where42All') async where42All(@Body() logins: string[]): Promise { - const res = []; - for (const login of logins) { - try { - res.push(await this.where42(login)); - } catch (e) { - this.logger.error('정상적인 조회가 아님'); - res.push({ - login, - inoutState: null, - }); - } - } - return res; - } - - @Post('where42All2') - async where42All2(@Body() logins: string[]): Promise { const res: Where42ResponseDto[] = []; const users = await this.userService.findUsersByLogins(logins); From f20258d2d0214a41dc60adca34699c0e8a6b9952 Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 20:44:37 +0900 Subject: [PATCH 6/9] chore: minor version update --- package-lock.json | 98 ++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1dab7c..03d5921 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "24hane", - "version": "4.2.1", + "version": "5.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "24hane", - "version": "4.2.1", + "version": "5.1.0", "license": "UNLICENSED", "dependencies": { "@googleapis/sheets": "^5.0.5", @@ -1840,15 +1840,15 @@ } }, "node_modules/@nestjs/platform-express": { - "version": "10.2.10", - "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.2.10.tgz", - "integrity": "sha512-U4KDgtMjH8TqEvt0RzC/POP8ABvL9bYoCScvlGtFSKgVGaMLBKkZ4+jHtbQx6qItYSlBBRUuz/dveMZCObfrkQ==", + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.3.10.tgz", + "integrity": "sha512-wK2ow3CZI2KFqWeEpPmoR300OB6BcBLxARV1EiClJLCj4S1mZsoCmS0YWgpk3j1j6mo0SI8vNLi/cC2iZPEPQA==", "dependencies": { "body-parser": "1.20.2", "cors": "2.8.5", - "express": "4.18.2", + "express": "4.19.2", "multer": "1.4.4-lts.1", - "tslib": "2.6.2" + "tslib": "2.6.3" }, "funding": { "type": "opencollective", @@ -1859,6 +1859,11 @@ "@nestjs/core": "^10.0.0" } }, + "node_modules/@nestjs/platform-express/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, "node_modules/@nestjs/schematics": { "version": "10.0.3", "resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-10.0.3.tgz", @@ -3257,12 +3262,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -4723,16 +4728,16 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -4763,33 +4768,10 @@ "node": ">= 0.10.0" } }, - "node_modules/express/node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, "node_modules/express/node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -4812,20 +4794,6 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, - "node_modules/express/node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -4945,9 +4913,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" @@ -5058,9 +5026,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", @@ -7159,9 +7127,9 @@ "dev": true }, "node_modules/mysql2": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.6.5.tgz", - "integrity": "sha512-pS/KqIb0xlXmtmqEuTvBXTmLoQ5LmAz5NW/r8UyQ1ldvnprNEj3P9GbmuQQ2J0A4LO+ynotGi6TbscPa8OUb+w==", + "version": "3.10.2", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.10.2.tgz", + "integrity": "sha512-KCXPEvAkO0RcHPr362O5N8tFY2fXvbjfkPvRY/wGumh4EOemo9Hm5FjQZqv/pCmrnuxGu5OxnSENG0gTXqKMgQ==", "dependencies": { "denque": "^2.1.0", "generate-function": "^2.3.1", From c913554a94ecb4cff279aba1395172f485a6f97d Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 21:09:14 +0900 Subject: [PATCH 7/9] package version update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df8439b..90054ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "24hane", - "version": "5.0.0", + "version": "5.1.0", "description": "24Hane Backend Server", "author": "joohongpark, niamu01, enaenen", "private": true, From c8a752db7e984b3bd4ea52f55bdb9375d95e9d93 Mon Sep 17 00:00:00 2001 From: niamu01 Date: Wed, 3 Jul 2024 22:08:36 +0900 Subject: [PATCH 8/9] style: importSorting --- src/auth/auth.service.ts | 2 +- src/auth/guard/jwt-sign.guard.ts | 4 ++-- src/auth/srategy/auth.admin.strategy.ts | 4 ++-- src/auth/srategy/auth.external.strategy.ts | 4 ++-- src/auth/srategy/auth.strategy.ts | 4 ++-- src/entities/alive.entity.ts | 2 +- src/entities/card-issuance.entity.ts | 2 +- src/entities/device-info.entity.ts | 2 +- src/entities/inout.entity.ts | 2 +- src/entities/tag-log.entity.ts | 2 +- src/entities/user-info.entity.ts | 2 +- src/external/where42/dto/where42.response.dto.ts | 1 - src/middleware/middleware.d.ts | 2 +- src/reissue/reissue.module.ts | 6 +++--- src/reissue/reissue.service.ts | 12 ++++++------ .../repository/googleApi/card-reissue.repository.ts | 4 ++-- .../repository/mysql/user-card-no.repository.ts | 2 +- .../repository/mysql/statistics.repository.ts | 6 +++--- src/statistics/statistics.controller.ts | 6 +++--- src/statistics/statistics.module.ts | 4 ++-- src/statistics/statistics.service.ts | 2 +- .../repository/mysql/device-info.repository.ts | 6 +++--- src/user/user.module.ts | 2 +- src/user/user.v1.controller.ts | 4 ++-- test/webhook.e2e-spec.ts | 2 +- 25 files changed, 44 insertions(+), 45 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 634110b..bdb376f 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -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 { diff --git a/src/auth/guard/jwt-sign.guard.ts b/src/auth/guard/jwt-sign.guard.ts index d4fd09f..6209b66 100644 --- a/src/auth/guard/jwt-sign.guard.ts +++ b/src/auth/guard/jwt-sign.guard.ts @@ -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'; /** diff --git a/src/auth/srategy/auth.admin.strategy.ts b/src/auth/srategy/auth.admin.strategy.ts index 8ad5773..af08674 100644 --- a/src/auth/srategy/auth.admin.strategy.ts +++ b/src/auth/srategy/auth.admin.strategy.ts @@ -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'; /** diff --git a/src/auth/srategy/auth.external.strategy.ts b/src/auth/srategy/auth.external.strategy.ts index 13f9b1e..3509add 100644 --- a/src/auth/srategy/auth.external.strategy.ts +++ b/src/auth/srategy/auth.external.strategy.ts @@ -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 diff --git a/src/auth/srategy/auth.strategy.ts b/src/auth/srategy/auth.strategy.ts index ada90fc..15637be 100644 --- a/src/auth/srategy/auth.strategy.ts +++ b/src/auth/srategy/auth.strategy.ts @@ -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'; /** diff --git a/src/entities/alive.entity.ts b/src/entities/alive.entity.ts index f69ca20..25c9a9a 100644 --- a/src/entities/alive.entity.ts +++ b/src/entities/alive.entity.ts @@ -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() diff --git a/src/entities/card-issuance.entity.ts b/src/entities/card-issuance.entity.ts index 393ca66..e7f8c0c 100644 --- a/src/entities/card-issuance.entity.ts +++ b/src/entities/card-issuance.entity.ts @@ -1,6 +1,6 @@ import { - Entity, Column, + Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, diff --git a/src/entities/device-info.entity.ts b/src/entities/device-info.entity.ts index 3d7c80b..ae4f1b7 100644 --- a/src/entities/device-info.entity.ts +++ b/src/entities/device-info.entity.ts @@ -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 { diff --git a/src/entities/inout.entity.ts b/src/entities/inout.entity.ts index 6fce5f7..70898a2 100644 --- a/src/entities/inout.entity.ts +++ b/src/entities/inout.entity.ts @@ -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() diff --git a/src/entities/tag-log.entity.ts b/src/entities/tag-log.entity.ts index d853395..06239a4 100644 --- a/src/entities/tag-log.entity.ts +++ b/src/entities/tag-log.entity.ts @@ -1,4 +1,4 @@ -import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'; +import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; @Entity('TAG_LOG') export class TagLog { diff --git a/src/entities/user-info.entity.ts b/src/entities/user-info.entity.ts index 12b3c92..5636885 100644 --- a/src/entities/user-info.entity.ts +++ b/src/entities/user-info.entity.ts @@ -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') diff --git a/src/external/where42/dto/where42.response.dto.ts b/src/external/where42/dto/where42.response.dto.ts index 729e85b..6ebb90f 100644 --- a/src/external/where42/dto/where42.response.dto.ts +++ b/src/external/where42/dto/where42.response.dto.ts @@ -1,5 +1,4 @@ import { ApiProperty } from '@nestjs/swagger'; -import Cluster from 'src/enums/cluster.enum'; import InOut from 'src/enums/inout.enum'; export class Where42ResponseDto { diff --git a/src/middleware/middleware.d.ts b/src/middleware/middleware.d.ts index 7b257a4..28fde5f 100644 --- a/src/middleware/middleware.d.ts +++ b/src/middleware/middleware.d.ts @@ -1,4 +1,4 @@ -import { Request, Response, NextFunction } from 'express'; +import { NextFunction, Request, Response } from 'express'; export type Middleware = ( req: Request, diff --git a/src/reissue/reissue.module.ts b/src/reissue/reissue.module.ts index de4b5a6..289690b 100644 --- a/src/reissue/reissue.module.ts +++ b/src/reissue/reissue.module.ts @@ -1,10 +1,10 @@ import { Module } from '@nestjs/common'; -import { ReissueService } from './reissue.service'; -import { ReissueController } from './reissue.controller'; -import { UserCardRepository } from './repository/mysql/user-card-no.repository'; import { TypeOrmModule } from '@nestjs/typeorm'; import { UserInfo } from 'src/entities/user-info.entity'; +import { ReissueController } from './reissue.controller'; +import { ReissueService } from './reissue.service'; import { CardReissueRepository } from './repository/googleApi/card-reissue.repository'; +import { UserCardRepository } from './repository/mysql/user-card-no.repository'; const userCardRepo = { provide: 'IUserCardRepository', diff --git a/src/reissue/reissue.service.ts b/src/reissue/reissue.service.ts index 5d4e1f8..9c8eea7 100644 --- a/src/reissue/reissue.service.ts +++ b/src/reissue/reissue.service.ts @@ -1,4 +1,3 @@ -import axios from 'axios'; import { HttpException, Inject, @@ -7,14 +6,15 @@ import { NotFoundException, } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; +import axios from 'axios'; +import { CardReissue } from 'src/entities/card-reissue.entity'; +import ReissueState from 'src/enums/reissue-state.enum'; import { UserSessionDto } from '../auth/dto/user.session.dto'; -import { IUserCardRepository } from './repository/interface/user-card-no.repository.interface'; -import { StateDto } from './dto/state.dto'; -import { RequestDto } from './dto/request.dto'; import { FinishedDto } from './dto/finished.dto'; -import ReissueState from 'src/enums/reissue-state.enum'; +import { RequestDto } from './dto/request.dto'; +import { StateDto } from './dto/state.dto'; import { ICardReissueRepository } from './repository/interface/card-reissue.repository.interface'; -import { CardReissue } from 'src/entities/card-reissue.entity'; +import { IUserCardRepository } from './repository/interface/user-card-no.repository.interface'; @Injectable() export class ReissueService { diff --git a/src/reissue/repository/googleApi/card-reissue.repository.ts b/src/reissue/repository/googleApi/card-reissue.repository.ts index 2bcb0c0..e92b33d 100644 --- a/src/reissue/repository/googleApi/card-reissue.repository.ts +++ b/src/reissue/repository/googleApi/card-reissue.repository.ts @@ -1,8 +1,8 @@ +import { auth, sheets } from '@googleapis/sheets'; import { Inject, Logger } from '@nestjs/common'; -import { ICardReissueRepository } from '../interface/card-reissue.repository.interface'; import { ConfigService } from '@nestjs/config'; -import { sheets, auth } from '@googleapis/sheets'; import { CardReissue } from 'src/entities/card-reissue.entity'; +import { ICardReissueRepository } from '../interface/card-reissue.repository.interface'; export class CardReissueRepository implements ICardReissueRepository { private logger = new Logger(CardReissueRepository.name); diff --git a/src/reissue/repository/mysql/user-card-no.repository.ts b/src/reissue/repository/mysql/user-card-no.repository.ts index 8003162..5ccd36f 100644 --- a/src/reissue/repository/mysql/user-card-no.repository.ts +++ b/src/reissue/repository/mysql/user-card-no.repository.ts @@ -1,7 +1,7 @@ -import { IUserCardRepository } from '../interface/user-card-no.repository.interface'; import { InjectRepository } from '@nestjs/typeorm'; import { UserInfo } from 'src/entities/user-info.entity'; import { Repository } from 'typeorm/repository/Repository'; +import { IUserCardRepository } from '../interface/user-card-no.repository.interface'; export class UserCardRepository implements IUserCardRepository { constructor( diff --git a/src/statistics/repository/mysql/statistics.repository.ts b/src/statistics/repository/mysql/statistics.repository.ts index a388317..becb6cc 100644 --- a/src/statistics/repository/mysql/statistics.repository.ts +++ b/src/statistics/repository/mysql/statistics.repository.ts @@ -1,8 +1,8 @@ +import { InjectRepository } from '@nestjs/typeorm'; +import { TagLog } from 'src/entities/tag-log.entity'; import { CadetPerClusterDto } from 'src/statistics/dto/cadet-per-cluster.dto'; -import { IStatisticsRepository } from '../interface/statistics.repository.interface'; import { Repository } from 'typeorm'; -import { TagLog } from 'src/entities/tag-log.entity'; -import { InjectRepository } from '@nestjs/typeorm'; +import { IStatisticsRepository } from '../interface/statistics.repository.interface'; export class StatisticsRepository implements IStatisticsRepository { constructor( diff --git a/src/statistics/statistics.controller.ts b/src/statistics/statistics.controller.ts index b56aa6c..d91b321 100644 --- a/src/statistics/statistics.controller.ts +++ b/src/statistics/statistics.controller.ts @@ -1,9 +1,9 @@ -import { Controller, Get, Inject, Logger } from '@nestjs/common'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; +import { Controller, Get, Inject, Logger } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { StatisticsService } from './statistics.service'; -import { CadetPerClusterDto } from './dto/cadet-per-cluster.dto'; import { Cache } from 'cache-manager'; +import { CadetPerClusterDto } from './dto/cadet-per-cluster.dto'; +import { StatisticsService } from './statistics.service'; @ApiTags('통계 관련 API') @Controller({ diff --git a/src/statistics/statistics.module.ts b/src/statistics/statistics.module.ts index 058550c..173ea3a 100644 --- a/src/statistics/statistics.module.ts +++ b/src/statistics/statistics.module.ts @@ -1,9 +1,9 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; +import { TagLog } from 'src/entities/tag-log.entity'; import { StatisticsRepository } from './repository/mysql/statistics.repository'; -import { StatisticsService } from './statistics.service'; import { StatisticsController } from './statistics.controller'; -import { TagLog } from 'src/entities/tag-log.entity'; +import { StatisticsService } from './statistics.service'; const statisticsRepo = { provide: 'IStatisticsRepository', diff --git a/src/statistics/statistics.service.ts b/src/statistics/statistics.service.ts index 74374ca..7268bb4 100644 --- a/src/statistics/statistics.service.ts +++ b/src/statistics/statistics.service.ts @@ -1,6 +1,6 @@ -import { Cache } from 'cache-manager'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { Inject, Injectable, Logger } from '@nestjs/common'; +import { Cache } from 'cache-manager'; import { CadetPerClusterDto } from './dto/cadet-per-cluster.dto'; import { IStatisticsRepository } from './repository/interface/statistics.repository.interface'; diff --git a/src/tag-log/repository/mysql/device-info.repository.ts b/src/tag-log/repository/mysql/device-info.repository.ts index a8fef23..c4ed391 100644 --- a/src/tag-log/repository/mysql/device-info.repository.ts +++ b/src/tag-log/repository/mysql/device-info.repository.ts @@ -1,8 +1,8 @@ -import { DeviceInfoDto } from 'src/tag-log/dto/device-info.dto'; -import { IDeviceInfoRepository } from '../interface/device-info-repository.interface'; import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; import { DeviceInfo } from 'src/entities/device-info.entity'; +import { DeviceInfoDto } from 'src/tag-log/dto/device-info.dto'; +import { Repository } from 'typeorm'; +import { IDeviceInfoRepository } from '../interface/device-info-repository.interface'; export class DeviceInfoRepository implements IDeviceInfoRepository { constructor( diff --git a/src/user/user.module.ts b/src/user/user.module.ts index cb2fab8..55cb47a 100644 --- a/src/user/user.module.ts +++ b/src/user/user.module.ts @@ -2,8 +2,8 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { UserInfo } from 'src/entities/user-info.entity'; import { UserInfoRepository } from './repository/mysql/user-info.repository'; -import { UserV1Controller } from './user.v1.controller'; import { UserService } from './user.service'; +import { UserV1Controller } from './user.v1.controller'; const userInfoRepo = { provide: 'IUserInfoRepository', diff --git a/src/user/user.v1.controller.ts b/src/user/user.v1.controller.ts index b41528c..205ebf8 100644 --- a/src/user/user.v1.controller.ts +++ b/src/user/user.v1.controller.ts @@ -11,11 +11,11 @@ import { ApiResponse, ApiTags, } from '@nestjs/swagger'; -import { User } from 'src/auth/user.decorator'; import { UserSessionDto } from 'src/auth/dto/user.session.dto'; +import { AdminAuthGuard } from 'src/auth/guard/admin-auth.guard'; +import { User } from 'src/auth/user.decorator'; import { IdLoginDto } from './dto/id-login.dto'; import { UserService } from './user.service'; -import { AdminAuthGuard } from 'src/auth/guard/admin-auth.guard'; @ApiTags('유저 정보 관련') @Controller({ diff --git a/test/webhook.e2e-spec.ts b/test/webhook.e2e-spec.ts index d05ba12..5b4689d 100644 --- a/test/webhook.e2e-spec.ts +++ b/test/webhook.e2e-spec.ts @@ -1,5 +1,5 @@ -import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; import { AppModule } from './../src/app.module.e2e-spec'; describe('WebhookModule (e2e)', () => { From 92fd9fc20b2f1000cb60de66f2d18087d0e0870d Mon Sep 17 00:00:00 2001 From: niamu01 Date: Fri, 5 Jul 2024 16:53:56 +0900 Subject: [PATCH 9/9] =?UTF-8?q?revert:=20Where42ResponseDto=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=A0=84=EC=9C=BC=EB=A1=9C=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../where42/dto/where42.response.dto.ts | 18 ++++++++++-- src/external/where42/where42.service.ts | 28 +++++++++++++------ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/external/where42/dto/where42.response.dto.ts b/src/external/where42/dto/where42.response.dto.ts index 6ebb90f..2a40b1d 100644 --- a/src/external/where42/dto/where42.response.dto.ts +++ b/src/external/where42/dto/where42.response.dto.ts @@ -1,4 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; +import Cluster from 'src/enums/cluster.enum'; import InOut from 'src/enums/inout.enum'; export class Where42ResponseDto { @@ -9,9 +10,22 @@ export class Where42ResponseDto { login: string; @ApiProperty({ - description: '클러스터 체류 여부, bocal은 null', + description: '클러스터 체류 여부', enum: InOut, example: InOut.OUT, }) - inoutState: InOut | null; + inoutState: InOut; + + @ApiProperty({ + description: '체류중인 클러스터', + enum: Cluster, + example: Cluster.GAEPO, + }) + cluster: Cluster; + + @ApiProperty({ + description: '마지막으로 태깅한 시간', + type: Date, + }) + tag_at: Date; } diff --git a/src/external/where42/where42.service.ts b/src/external/where42/where42.service.ts index a4f74fc..7192200 100644 --- a/src/external/where42/where42.service.ts +++ b/src/external/where42/where42.service.ts @@ -12,6 +12,7 @@ import { IdLoginDto } from 'src/user/dto/id-login.dto'; import { UserService } from 'src/user/user.service'; import { Where42ResponseDto } from './dto/where42.response.dto'; import { IDeviceInfoRepository } from './repository/interface/device-info.repository.interface'; +import Cluster from 'src/enums/cluster.enum'; @Injectable() export class Where42Service { @@ -54,11 +55,14 @@ export class Where42Service { return { login, inoutState: device.inoutState, + cluster: device.cluster, + tag_at: last.tag_at, }; } @Post('where42All') async where42All(@Body() logins: string[]): Promise { + // todo: Where42ResponseDto의 inoutState, tag_at은 사라질 예정입니다. const res: Where42ResponseDto[] = []; const users = await this.userService.findUsersByLogins(logins); @@ -74,15 +78,6 @@ export class Where42Service { throw new BadRequestException('존재하지 않는 유저 ID입니다.'); } - const isAdmin = user.is_admin; - if (isAdmin) { - res.push({ - login, - inoutState: null, - }); - return; - } - const cards = await this.userService.findCardsByUserId( user.user_id, new Date('2019-01-01 00:00:00'), @@ -103,15 +98,30 @@ export class Where42Service { ); } + const isAdmin = user.is_admin; + if (isAdmin) { + res.push({ + login, + inoutState: null, + cluster: Cluster.GAEPO, + tag_at: last.tag_at, + }); + return; + } + res.push({ login, inoutState: device.inoutState, + cluster: Cluster.GAEPO, + tag_at: last.tag_at, }); } catch (e) { this.logger.error(`정상적인 조회가 아님: ${login}`); res.push({ login, inoutState: null, + cluster: Cluster.GAEPO, + tag_at: new Date(), }); } }),