From 996b64a52890fc4ee1e7cd6ee1ee3be582e4407c Mon Sep 17 00:00:00 2001 From: kimminsu Date: Mon, 25 Nov 2024 17:02:23 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20feat:=20=EB=9E=9C=EB=8D=A4=20?= =?UTF-8?q?=EB=8B=89=EB=84=A4=EC=9E=84=20=EC=83=81=EC=88=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/user/constants/randomNickname.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 packages/backend/src/user/constants/randomNickname.ts diff --git a/packages/backend/src/user/constants/randomNickname.ts b/packages/backend/src/user/constants/randomNickname.ts new file mode 100644 index 00000000..fb55e86e --- /dev/null +++ b/packages/backend/src/user/constants/randomNickname.ts @@ -0,0 +1,16 @@ +export const status = [ + '신중한', + '과감한', + '공부하는', + '성장하는', + '주춤거리는', +]; +export const subject = [ + '병아리', + '햄스터', + '다람쥐', + '거북이', + '판다', + '주린이', + '투자자', +]; From 44bb8eceb6d2423492ad738abcb4542932fb136f Mon Sep 17 00:00:00 2001 From: kimminsu Date: Mon, 25 Nov 2024 19:39:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20feat:=20=EA=B1=B0=EB=9E=98?= =?UTF-8?q?=EC=A4=91=EC=9D=B8=20=EC=A2=85=EB=AA=A9=EB=A7=8C=20=EA=B2=80?= =?UTF-8?q?=EC=83=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/stock/stock.service.ts | 61 ++++++++++----------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/packages/backend/src/stock/stock.service.ts b/packages/backend/src/stock/stock.service.ts index 154eb9d6..c0e50a9c 100644 --- a/packages/backend/src/stock/stock.service.ts +++ b/packages/backend/src/stock/stock.service.ts @@ -69,11 +69,10 @@ export class StockService { } async searchStock(stockName: string) { - const queryBuilder = this.datasource + const result = await this.datasource .getRepository(Stock) - .createQueryBuilder(); - const result = await queryBuilder - .where('stock.stock_name LIKE :name', { + .createQueryBuilder('stock') + .where('stock.is_trading = :isTrading and stock.stock_name LIKE :name', { isTrading: true, name: `%${stockName}%`, }) @@ -94,6 +93,33 @@ export class StockService { } } + async getTopStocksByViews(limit: number) { + const rawData = await this.StocksQuery() + .orderBy('stock.views', 'DESC') + .limit(limit) + .getRawMany(); + + return plainToInstance(StocksResponse, rawData); + } + + async getTopStocksByGainers(limit: number) { + const rawData = await this.StocksQuery() + .orderBy('stockLiveData.changeRate', 'DESC') + .limit(limit) + .getRawMany(); + + return plainToInstance(StocksResponse, rawData); + } + + async getTopStocksByLosers(limit: number) { + const rawData = await this.StocksQuery() + .orderBy('stockLiveData.changeRate', 'ASC') + .limit(limit) + .getRawMany(); + + return plainToInstance(StocksResponse, rawData); + } + private async validateStockExists(stockId: string, manager: EntityManager) { if (!(await this.existsStock(stockId, manager))) { throw new BadRequestException('not exists stock'); @@ -150,31 +176,4 @@ export class StockService { 'stockDetail.marketCap AS marketCap', ]); } - - async getTopStocksByViews(limit: number) { - const rawData = await this.StocksQuery() - .orderBy('stock.views', 'DESC') - .limit(limit) - .getRawMany(); - - return plainToInstance(StocksResponse, rawData); - } - - async getTopStocksByGainers(limit: number) { - const rawData = await this.StocksQuery() - .orderBy('stockLiveData.changeRate', 'DESC') - .limit(limit) - .getRawMany(); - - return plainToInstance(StocksResponse, rawData); - } - - async getTopStocksByLosers(limit: number) { - const rawData = await this.StocksQuery() - .orderBy('stockLiveData.changeRate', 'ASC') - .limit(limit) - .getRawMany(); - - return plainToInstance(StocksResponse, rawData); - } }