대기중인 방-개인 참가자 정보 가져오기

This commit is contained in:
eld_master 2024-12-08 01:12:57 +09:00
parent 0a75de924d
commit 2f381769af
3 changed files with 51 additions and 8 deletions

View File

@ -125,6 +125,25 @@ async def check_auth_user(user_seq, room_type, room_seq, db):
return db.execute(query).fetchall()
# 참가자 정보 가져오기
async def participant_user_list(room_type, room_seq, db):
query = text(f"""
select
a.user_seq,
a.participant_type,
a.nickname, {'a.team_name,' if room_type == 'team' else ''}
a.score,
b.profile_img,
b.department,
b.introduce_myself
from room_score_{room_type}_participant a
left join manage_user b
on a.user_seq = b.user_seq
where a.room_seq = {room_seq}
""")
return db.execute(query).fetchall()

View File

@ -57,7 +57,7 @@ async def insert_creater_user(data, db):
# 방 참여자 조회 권한 확인
async def check_auth_user(user_seq, room_type, room_seq, db):
db_result_ori = crud_room_score.check_auth_user(user_seq=user_seq, room_type=room_type, room_seq=room_seq, db=db)
db_result_ori = await crud_room_score.check_auth_user(user_seq=user_seq, room_type=room_type, room_seq=room_seq, db=db)
db_result = []
for db_data in db_result_ori:
db_result.append(db_data)
@ -74,11 +74,31 @@ async def check_auth_user(user_seq, room_type, room_seq, db):
# 참가자 정보 가져오기
async def participant_user_list(user_seq_list, room_type, room_seq, db):
db_result_ori = crud_room_score.participant_user_list(user_seq_list=user_seq_list, room_type=room_type, room_seq=room_seq, db=db)
async def participant_user_list(room_type, room_seq, db):
db_result_ori = await crud_room_score.participant_user_list(room_type=room_type, room_seq=room_seq, db=db)
db_result = []
for db_data in db_result_ori:
db_result.append(db_data)
if room_type == 'private':
db_result.append({
"user_seq": db_data[0],
"participant_type": db_data[1],
"nickname": db_data[2],
"score": db_data[3],
"profile_img": db_data[4],
"department": db_data[5],
"introduce_myself": db_data[6]
})
elif room_type == 'team':
db_result.append({
"user_seq": db_data[0],
"participant_type": db_data[1],
"nickname": db_data[2],
"team_name": db_data[3],
"score": db_data[4],
"profile_img": db_data[5],
"department": db_data[6],
"introduce_myself": db_data[7]
})
if len(db_result) == 0:
return {
@ -86,7 +106,8 @@ async def participant_user_list(user_seq_list, room_type, room_seq, db):
}
else:
return {
"result": "OK"
"result": "OK",
"data": db_result
}

View File

@ -109,11 +109,14 @@ async def get_waiting_private_room_info(request: Request, body: bytes = Depends(
if user_seq_result["result"] == 'OK':
user_seq = user_seq_result['data']['user_seq']
# 방 참여자 조회 권한 확인
check_auth_user_result = room_score.check_auth_user(user_seq=user_seq, room_type='private', room_seq=body['room_seq'], db=db)
if check_auth_user_result != 'OK':
check_auth_user_result = await room_score.check_auth_user(user_seq=user_seq, room_type='private', room_seq=body['room_seq'], db=db)
if check_auth_user_result == 'FAIL':
return await response.fail_res(auth_token=auth_token, auth_type='NOMAL', msg_title='참가자 조회 실패', msg_content='참가자 조회 권한이 없습니다.', data={})
# 참가자 정보 가져오기
participant_user_list_result = room_score.participant_user_list(user_seq_list=body['user_seq_list'], room_type='private', room_seq=body['room_seq'], db=db)
participant_user_list_result = await room_score.participant_user_list(room_type='private', room_seq=body['room_seq'], db=db)
if participant_user_list_result['result'] == 'OK':
return await response.ok_res(auth_token=auth_token, data=participant_user_list_result['data'], db=db)
return await response.error_res(auth_token=auth_token, auth_type='NOMAL', msg_title='참가자 정보 조회 에러', msg_content='참가자 정보 조회중 에러가 발생했습니다. 관리자에게 문의해주세요.', data={})
else:
return await response.error_res(auth_token=auth_token, auth_type='NOMAL', msg_title='토큰 에러', msg_content='토큰 정보가 정확하지 않습니다.', data={})