쿠폰 자동 입력 사이트 작성
배포 완료. 이제: - **FID 탭**: FID 직접 입력 → WOS API 호출 → DB 저장 → 쿠폰 자동 지급 - **닉네임 탭**: 닉네임 입력 시 DB에서 실시간 검색 → 선택하면 자동으로 FID 조회 및 쿠폰 지급
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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' } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user