개인-게임 시작 완료
This commit is contained in:
parent
2f381769af
commit
b0f220089d
@ -144,6 +144,41 @@ async def participant_user_list(room_type, room_seq, db):
|
||||
return db.execute(query).fetchall()
|
||||
|
||||
|
||||
# 요청자가 방장인지 확인
|
||||
async def check_requester_room_master_auth(room_seq, db):
|
||||
query = text(f"""
|
||||
select
|
||||
user_seq
|
||||
from room_main
|
||||
where room_seq = {room_seq}
|
||||
""")
|
||||
return db.execute(query).fetchall()
|
||||
|
||||
|
||||
# 요청자가 방장인지 확인
|
||||
async def update_room_status(room_seq, room_status, before_status, db):
|
||||
query = text(f"""
|
||||
update room_main
|
||||
set room_status = (select reserve_code from reserve_code where reserve_code_group = 'ROOM_SCORE_STATUS' and reserve_code = '{room_status}')
|
||||
where room_seq = {room_seq}
|
||||
and room_status = (select reserve_code from reserve_code where reserve_code_group = 'ROOM_SCORE_STATUS' and reserve_code = '{before_status}')
|
||||
""")
|
||||
try:
|
||||
db.execute(query)
|
||||
db.commit()
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"sql error: {e}")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -111,6 +111,51 @@ async def participant_user_list(room_type, room_seq, db):
|
||||
}
|
||||
|
||||
|
||||
# 요청자가 방장인지 확인
|
||||
async def check_requester_room_master_auth(user_seq, room_seq, db):
|
||||
db_result_ori = await crud_room_score.check_requester_room_master_auth(room_seq=room_seq, db=db)
|
||||
if len(db_result_ori) != 1:
|
||||
return {
|
||||
"result": "FAIL"
|
||||
}
|
||||
|
||||
room_master_user_seq = db_result_ori[0][0]
|
||||
|
||||
# 조회된 방장 SEQ와 요청자 SEQ 비교
|
||||
if int(room_master_user_seq) == int(user_seq):
|
||||
return {
|
||||
"result": "OK"
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"result": "FAIL"
|
||||
}
|
||||
|
||||
|
||||
# 요청자가 방장인지 확인
|
||||
async def update_room_status(room_seq, room_status, db):
|
||||
room_status_follow_list = ['WAIT', 'RUNNING', 'FINISH']
|
||||
before_status_index = room_status_follow_list.index(room_status)-1
|
||||
if before_status_index < 0:
|
||||
return {
|
||||
"result": "FAIL",
|
||||
}
|
||||
before_status = room_status_follow_list[before_status_index]
|
||||
db_result = await crud_room_score.update_room_status(room_seq=room_seq, room_status=room_status, before_status=before_status, db=db)
|
||||
|
||||
if db_result:
|
||||
return {
|
||||
"result": "OK"
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"result": "FAIL",
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -148,8 +148,17 @@ async def start_private_room(request: Request, body: bytes = Depends(get_body),
|
||||
user_seq_result = cert_process.get_user_seq_by_token(token=auth_token['token'])
|
||||
if user_seq_result["result"] == 'OK':
|
||||
user_seq = user_seq_result['data']['user_seq']
|
||||
body['user_seq'] = user_seq
|
||||
# TODO
|
||||
# 요청자가 방장인지 확인
|
||||
check_requester_room_master_auth_result = await room_score.check_requester_room_master_auth(user_seq=user_seq, room_seq=body['room_seq'], db=db)
|
||||
if check_requester_room_master_auth_result['result'] == 'OK':
|
||||
# 방 상태 RUNNING으로 변경
|
||||
update_room_status_result = await room_score.update_room_status(room_seq=body['room_seq'], room_status='RUNNING', db=db)
|
||||
if update_room_status_result['result'] == 'OK':
|
||||
return await response.ok_res(auth_token=auth_token, data={}, db=db)
|
||||
else:
|
||||
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={})
|
||||
else:
|
||||
return await response.error_res(auth_token=auth_token, auth_type='NOMAL', msg_title='토큰 에러', msg_content='토큰 정보가 정확하지 않습니다.', data={})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user