This commit is contained in:
2025-05-14 00:56:29 +09:00
parent 1db3a03ffd
commit 8e9b941a28
6 changed files with 64 additions and 44 deletions
+20 -11
View File
@@ -22,15 +22,17 @@ exports.publicEventEntry = async (req, res) => {
return res.status(403).json({ message: '취소된 이벤트입니다.' });
}
// 클럽의 구독 활성 여부 확인
// 클럽의 구독 활성 여부 확인 - 가장 최근 구독 정보 가져오기
const clubSubscription = await sequelize.models.ClubSubscription.findOne({
where: { clubId: event.clubId, status: 'active' },
include: [{ model: sequelize.models.SubscriptionPlan }]
where: { clubId: event.clubId },
include: [{ model: sequelize.models.SubscriptionPlan }],
order: [['endDate', 'DESC']] // 가장 최근 구독 정보를 가져오기 위해 만료일 기준 내림차순 정렬
});
// 구독이 비활성화된 경우 접근 제한
if (!clubSubscription) {
return res.status(403).json({ message: '클럽의 구독이 비활성화되어 이벤트에 접근할 수 없습니다. 클럽 관리자에게 문의하세요.' });
// 구독이 없거나 만료된 경우 접근 제한
const now = new Date();
if (!clubSubscription || new Date(clubSubscription.endDate) < now) {
return res.status(403).json({ message: '클럽의 구독이 만료되어 이벤트에 접근할 수 없습니다. 클럽 관리자에게 문의하세요.' });
}
let token = null;
@@ -263,14 +265,21 @@ exports.addPublicGuest = async (req, res) => {
// 클럽의 회원 수와 구독 플랜의 최대 회원 수 확인
const memberCount = await Member.count({ where: { clubId: event.clubId } });
// 클럽의 구독 정보 가져오기
// 클럽의 구독 정보 가져오기 - 가장 최근 구독 정보
const clubSubscription = await sequelize.models.ClubSubscription.findOne({
where: { clubId: event.clubId, status: 'active' },
include: [{ model: sequelize.models.SubscriptionPlan }]
where: { clubId: event.clubId },
include: [{ model: sequelize.models.SubscriptionPlan }],
order: [['endDate', 'DESC']] // 가장 최근 구독 정보를 가져오기 위해 만료일 기준 내림차순 정렬
});
// 구독 플랜이 있고 회원 수가 최대치를 초과하는 경우
if (clubSubscription && clubSubscription.SubscriptionPlan) {
// 구독이 없거나 만료된 경우 접근 제한
const now = new Date();
if (!clubSubscription || new Date(clubSubscription.endDate) < now) {
return res.status(403).json({ message: '클럽의 구독이 만료되어 이벤트에 접근할 수 없습니다. 클럽 관리자에게 문의하세요.' });
}
// 회원 수가 최대치를 초과하는 경우
if (clubSubscription.SubscriptionPlan) {
const maxMembers = clubSubscription.SubscriptionPlan.maxMembers;
if (memberCount >= maxMembers) {
return res.status(403).json({
@@ -2,10 +2,11 @@ module.exports = {
up: async (queryInterface, Sequelize) => {
// 각 클럽 5개에 대해 2개의 구독(플랜 1, 2)을 연결
const clubSubscriptions = [];
const now = new Date();
for (let clubId = 1; clubId <= 5; clubId++) {
const planId = Math.floor(Math.random() * 2) + 1; // 랜덤으로 플랜 1, 2 중 하나 선택
const startDate = new Date(2025, 4, 1 + clubId);
const endDate = new Date(startDate.getFullYear(), startDate.getMonth()+1, startDate.getDate());
const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + clubId);
const endDate = new Date(startDate.getFullYear(), startDate.getMonth()+clubId, startDate.getDate());
clubSubscriptions.push({
clubId,
planId,
+5 -4
View File
@@ -2,6 +2,7 @@ module.exports = {
up: async (queryInterface, Sequelize) => {
// 각 클럽마다 3개의 이벤트 생성
const events = [];
const now = new Date();
for (let clubId = 1; clubId <= 5; clubId++) {
for (let i = 1; i <= 3; i++) {
events.push({
@@ -9,15 +10,15 @@ module.exports = {
title: `클럽${clubId} 이벤트${i}`,
description: `클럽${clubId}의 이벤트${i} 설명입니다.`,
eventType: '정기전', // ENUM 값 중 하나
startDate: new Date(2025, 3, 10 + i, 19, 0, 0),
endDate: new Date(2025, 3, 10 + i, 22, 0, 0),
startDate: new Date(now.getFullYear(), now.getMonth(), now.getDate() + i, 20, 0, 0),
endDate: new Date(now.getFullYear(), now.getMonth(), now.getDate() + i, 23, 0, 0),
location: `클럽${clubId} 이벤트장소${i}`,
gameCount: 3,
participantFee: 10000,
maxParticipants: 30,
registrationDeadline: new Date(2025, 3, 9 + i, 23, 59, 59),
registrationDeadline: new Date(now.getFullYear(), now.getMonth(), now.getDate() + i, 18, 0, 0),
participantCount: 0,
status: '활성', // ENUM 값 중 하나
status: '준비', // ENUM 값 중 하나
createdAt: new Date(),
updatedAt: new Date()
});