diff --git a/back/src/wos/wos.controller.ts b/back/src/wos/wos.controller.ts index 29fd751..71b9dcb 100644 --- a/back/src/wos/wos.controller.ts +++ b/back/src/wos/wos.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Post, Get, Delete, Patch, Body, Param, HttpCode } from '@nestjs/common'; +import { Controller, Post, Get, Delete, Patch, Body, Param, Query, HttpCode } from '@nestjs/common'; import { WosService } from './wos.service'; @Controller('api') @@ -28,6 +28,12 @@ export class WosController { return this.wosService.listUsers(); } + @Get('users/search') + async searchUsers(@Query('q') q: string) { + if (!q || q.trim().length === 0) return []; + return this.wosService.searchUsersByNickname(q.trim()); + } + @Get('history/:fid') async getHistory(@Param('fid') fid: string) { return this.wosService.getHistory(fid); diff --git a/back/src/wos/wos.service.ts b/back/src/wos/wos.service.ts index eaef255..e41543d 100644 --- a/back/src/wos/wos.service.ts +++ b/back/src/wos/wos.service.ts @@ -228,6 +228,15 @@ export class WosService { return this.wosUserRepo.find({ order: { created_at: 'DESC' } }); } + async searchUsersByNickname(nickname: string) { + return this.wosUserRepo + .createQueryBuilder('u') + .where('u.nickname LIKE :q', { q: `%${nickname}%` }) + .orderBy('u.nickname', 'ASC') + .limit(20) + .getMany(); + } + async listCoupons() { return this.wosCouponRepo.find({ order: { created_at: 'DESC' } }); } diff --git a/front/src/views/HomeView.vue b/front/src/views/HomeView.vue index a1743da..d919a53 100644 --- a/front/src/views/HomeView.vue +++ b/front/src/views/HomeView.vue @@ -27,7 +27,12 @@
-
+
+ + +
+ +
🎁 쿠폰 λ°›κΈ°
+ +
+
+ +
+ +
+
+
+

{{ store.errorMsg }}

@@ -61,13 +93,18 @@