클럽 설정 기능
This commit is contained in:
@@ -198,8 +198,7 @@ exports.createClub = async (req, res) => {
|
||||
// 클럽 정보 업데이트
|
||||
exports.updateClub = async (req, res) => {
|
||||
try {
|
||||
const { id, name, location, description, contact, ownerEmail, status } = req.body;
|
||||
const clubId = id || req.params.id;
|
||||
const { clubId, name, location, description, contact, ownerEmail, status, femaleHandicap } = req.body;
|
||||
const club = await Club.findByPk(clubId);
|
||||
|
||||
if (!club) {
|
||||
@@ -226,6 +225,7 @@ exports.updateClub = async (req, res) => {
|
||||
description: description !== undefined ? description : club.description,
|
||||
contact: contact !== undefined ? contact : club.contact,
|
||||
status: status || club.status,
|
||||
femaleHandicap: femaleHandicap || club.femaleHandicap,
|
||||
ownerId: newOwnerId
|
||||
});
|
||||
|
||||
@@ -421,7 +421,7 @@ exports.addClubMember = async (req, res) => {
|
||||
// 클럽 회원 정보 수정
|
||||
exports.updateClubMember = async (req, res) => {
|
||||
try {
|
||||
const { clubId, memberId, name, gender, memberType, email, phone, status } = req.body;
|
||||
const { clubId, memberId, name, gender, memberType, email, phone, handicap, status } = req.body;
|
||||
|
||||
if (!clubId || !memberId) {
|
||||
return res.status(400).json({ message: '잘못된 클럽 또는 회원 ID입니다.' });
|
||||
@@ -461,6 +461,7 @@ exports.updateClubMember = async (req, res) => {
|
||||
memberType: memberType || member.memberType,
|
||||
email: email || member.email,
|
||||
phone: phone || member.phone,
|
||||
handicap: handicap || member.handicap,
|
||||
status: status || member.status
|
||||
});
|
||||
|
||||
|
||||
@@ -265,6 +265,10 @@ exports.addPublicGuest = async (req, res) => {
|
||||
// 클럽의 회원 수와 구독 플랜의 최대 회원 수 확인
|
||||
const memberCount = await Member.count({ where: { clubId: event.clubId } });
|
||||
|
||||
// 클럽 정보 가져오기 (여성 기본 핸디캡 확인을 위해)
|
||||
const club = await Club.findByPk(event.clubId);
|
||||
if (!club) return res.status(404).json({ message: '클럽 정보를 찾을 수 없습니다.' });
|
||||
|
||||
// 클럽의 구독 정보 가져오기 - 가장 최근 구독 정보
|
||||
const clubSubscription = await sequelize.models.ClubSubscription.findOne({
|
||||
where: { clubId: event.clubId },
|
||||
@@ -288,6 +292,12 @@ exports.addPublicGuest = async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 여성 핸디캡 적용
|
||||
let handicap = null;
|
||||
if (gender === '여성' && club.femaleHandicap) {
|
||||
handicap = club.femaleHandicap;
|
||||
}
|
||||
|
||||
// publicAuth 미들웨어로 인증됨
|
||||
const member = await Member.create({
|
||||
name,
|
||||
@@ -295,7 +305,8 @@ exports.addPublicGuest = async (req, res) => {
|
||||
gender,
|
||||
clubId: event.clubId,
|
||||
memberType: '게스트',
|
||||
average: average || 0
|
||||
average: average || 0,
|
||||
handicap: handicap // 여성 핸디캡 적용
|
||||
});
|
||||
const participant = await EventParticipant.create({ eventId: event.id, memberId: member.id });
|
||||
res.json({
|
||||
|
||||
Reference in New Issue
Block a user