autoCoupon: alliance 연맹원 목록 연동 추가
- /api/alliances: alliance 백엔드 프록시 - /api/alliance-members: R5 PIN 인증 후 연맹원 목록 반환 (쿠폰 등록 여부 포함) - AlliancePanel.vue: 연맹 선택 + R5 PIN 인증 + 역할별 필터 + 쿠폰 등록 현황 - HomeView.vue에 AlliancePanel 추가
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { Controller, Post, Get, Delete, Patch, Body, Param, Query, HttpCode } from '@nestjs/common';
|
||||
import { Controller, Post, Get, Delete, Patch, Body, Param, Query, HttpCode, BadRequestException, ForbiddenException } from '@nestjs/common';
|
||||
import { WosService } from './wos.service';
|
||||
import axios from 'axios';
|
||||
|
||||
const ALLIANCE_API = 'http://localhost:3005/api';
|
||||
|
||||
@Controller('api')
|
||||
export class WosController {
|
||||
@@ -59,4 +62,25 @@ export class WosController {
|
||||
async deleteCoupon(@Param('id') id: string) {
|
||||
return this.wosService.deleteCoupon(Number(id));
|
||||
}
|
||||
|
||||
@Get('alliances')
|
||||
async getAlliances() {
|
||||
const { data } = await axios.get(`${ALLIANCE_API}/alliances`);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Post('alliance-members')
|
||||
@HttpCode(200)
|
||||
async getAllianceMembers(@Body() body: { alliance_id: number; pin: string }) {
|
||||
if (!body.alliance_id || !body.pin) throw new BadRequestException('alliance_id와 pin이 필요합니다');
|
||||
try {
|
||||
await axios.get(`${ALLIANCE_API}/alliances/${body.alliance_id}/pending`, { params: { pin: body.pin } });
|
||||
} catch {
|
||||
throw new ForbiddenException('PIN이 틀렸습니다');
|
||||
}
|
||||
const { data: members } = await axios.get(`${ALLIANCE_API}/members`, { params: { alliance_id: body.alliance_id } });
|
||||
const wosUsers = await this.wosService.listUsers();
|
||||
const nicknameSet = new Set(wosUsers.map((u: any) => u.nickname?.toLowerCase()));
|
||||
return members.map((m: any) => ({ ...m, in_coupon_system: nicknameSet.has(m.nickname?.toLowerCase()) }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user