버그 수정
This commit is contained in:
@@ -4,7 +4,7 @@ const { clubHasFeature } = require('../utils/featureAccess');
|
|||||||
function requireFeature(featureCode) {
|
function requireFeature(featureCode) {
|
||||||
return async function(req, res, next) {
|
return async function(req, res, next) {
|
||||||
try {
|
try {
|
||||||
const clubId = req.clubId || (req.user && req.user.clubId);
|
const clubId = req.clubId || req.body.clubId || req.params.clubId;
|
||||||
if (!clubId) {
|
if (!clubId) {
|
||||||
return res.status(400).json({ error: '클럽 정보가 필요합니다.' });
|
return res.status(400).json({ error: '클럽 정보가 필요합니다.' });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,16 +97,4 @@ Event.associate = (models) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Event.associate = (models) => {
|
|
||||||
Event.belongsTo(models.Club, {
|
|
||||||
foreignKey: 'clubId'
|
|
||||||
});
|
|
||||||
Event.hasMany(models.EventParticipant, {
|
|
||||||
foreignKey: 'eventId'
|
|
||||||
});
|
|
||||||
Event.hasMany(models.EventScore, {
|
|
||||||
foreignKey: 'eventId'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Event;
|
module.exports = Event;
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ EventParticipant.associate = (models) => {
|
|||||||
EventParticipant.hasMany(models.EventScore, {
|
EventParticipant.hasMany(models.EventScore, {
|
||||||
foreignKey: 'participantId'
|
foreignKey: 'participantId'
|
||||||
});
|
});
|
||||||
|
EventParticipant.belongsTo(models.Member, { foreignKey: 'memberId' });
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = EventParticipant;
|
module.exports = EventParticipant;
|
||||||
|
|||||||
@@ -75,11 +75,14 @@ const Member = sequelize.define('Member', {
|
|||||||
tableName: 'Members',
|
tableName: 'Members',
|
||||||
timestamps: true
|
timestamps: true
|
||||||
});
|
});
|
||||||
|
Member.associate = (models) => {
|
||||||
|
// User와의 관계 설정
|
||||||
|
Member.belongsTo(User, {foreignKey: 'userId'});
|
||||||
|
|
||||||
// User와의 관계 설정
|
// Club과의 관계 설정
|
||||||
Member.belongsTo(User, {foreignKey: 'userId'});
|
Member.belongsTo(Club, {foreignKey: 'clubId'});
|
||||||
|
|
||||||
// Club과의 관계 설정
|
|
||||||
Member.belongsTo(Club, {foreignKey: 'clubId'});
|
|
||||||
|
|
||||||
|
// EventParticipant와의 관계 설정
|
||||||
|
Member.hasMany(models.EventParticipant, { foreignKey: 'memberId' });
|
||||||
|
};
|
||||||
module.exports = Member;
|
module.exports = Member;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ router.delete('/', authenticateJWT, clubController.deleteClub);
|
|||||||
router.post('/user', authenticateJWT, clubController.getUserClubs);
|
router.post('/user', authenticateJWT, clubController.getUserClubs);
|
||||||
|
|
||||||
// 클럽 회원 통계 조회
|
// 클럽 회원 통계 조회
|
||||||
router.post('/members/stats', authenticateJWT, requireFeature('statistics'), clubController.getMemberStats);
|
router.post('/members/stats', authenticateJWT, clubController.getMemberStats);
|
||||||
|
|
||||||
// 클럽 회원 목록 조회
|
// 클럽 회원 목록 조회
|
||||||
router.post('/members', authenticateJWT, clubController.getClubMembers);
|
router.post('/members', authenticateJWT, clubController.getClubMembers);
|
||||||
@@ -46,10 +46,10 @@ router.post('/meetings/last', authenticateJWT, clubController.getLastMeeting);
|
|||||||
router.post('/meetings/recent', authenticateJWT, clubController.getRecentMeetings);
|
router.post('/meetings/recent', authenticateJWT, clubController.getRecentMeetings);
|
||||||
|
|
||||||
// 점수 통계 조회
|
// 점수 통계 조회
|
||||||
router.post('/scores/stats', authenticateJWT, requireFeature('statistics'), clubController.getScoreStats);
|
router.post('/scores/stats', authenticateJWT, clubController.getScoreStats);
|
||||||
|
|
||||||
// 상위 회원 목록 조회
|
// 상위 회원 목록 조회
|
||||||
router.post('/members/top', authenticateJWT, requireFeature('statistics'), clubController.getTopMembers);
|
router.post('/members/top', authenticateJWT, clubController.getTopMembers);
|
||||||
|
|
||||||
// 새 클럽 생성
|
// 새 클럽 생성
|
||||||
router.post('/create', authenticateJWT, clubController.createClub);
|
router.post('/create', authenticateJWT, clubController.createClub);
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ const fetchClubs = async () => {
|
|||||||
// 첫 번째 클럽의 memberType을 localStorage에 저장
|
// 첫 번째 클럽의 memberType을 localStorage에 저장
|
||||||
if (clubs.value.length > 0) {
|
if (clubs.value.length > 0) {
|
||||||
localStorage.setItem('userClubRole', clubs.value[0].memberType || '');
|
localStorage.setItem('userClubRole', clubs.value[0].memberType || '');
|
||||||
|
localStorage.setItem('clubId', clubs.value[0].id);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('클럽 목록 로드 실패:', error);
|
console.error('클럽 목록 로드 실패:', error);
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ const userAvatar = computed(() => user.value?.avatar || '');
|
|||||||
|
|
||||||
// 로그아웃
|
// 로그아웃
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
|
user.value = null;
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
localStorage.removeItem('clubId');
|
localStorage.removeItem('clubId');
|
||||||
localStorage.removeItem('userRole');
|
localStorage.removeItem('userRole');
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ const fetchEvents = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const eventData = await eventService.getEvents(clubId.value);
|
const eventData = await eventService.getEvents(clubId.value);
|
||||||
|
console.log('eventData', eventData);
|
||||||
events.value = eventData.map(event => ({
|
events.value = eventData.map(event => ({
|
||||||
id: event.id,
|
id: event.id,
|
||||||
title: event.title,
|
title: event.title,
|
||||||
|
|||||||
@@ -105,6 +105,7 @@
|
|||||||
<Button label="예" icon="pi pi-check" class="p-button-danger" @click="deleteEvent" />
|
<Button label="예" icon="pi pi-check" class="p-button-danger" @click="deleteEvent" />
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
<Toast />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -163,6 +164,7 @@ const fetchEvents = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const response = await eventService.getEvents(clubId.value);
|
const response = await eventService.getEvents(clubId.value);
|
||||||
|
console.log('eventData', response);
|
||||||
events.value = response;
|
events.value = response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.add({
|
toast.add({
|
||||||
|
|||||||
Reference in New Issue
Block a user