feat: 나만의 각 1단계 — 공식 각 두 개를 섞어 내 각 만들기(점수는 낮은 쪽), 로그인 없이 1개·로그인하면 계정 저장, 친구에게 보낸 링크로 내 동네 점수 보기

This commit is contained in:
minaChoi committed 2026-10-20 11:37:40 +09:00
1 parent 96cbd19c61
commit a8a126f6a5
18 files changed
+842 -6

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import uuid
from sqlalchemy import delete, func, select
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.ext.asyncio import AsyncSession
from common.database.model.models import MyGak
class MyGakCRUD:
async def of_user(self, s: AsyncSession, user_id: uuid.UUID) -> list[MyGak]:
return list((await s.scalars(select(MyGak).where(MyGak.user_id == user_id).order_by(MyGak.my_gak_id))).all())
async def count(self, s: AsyncSession, user_id: uuid.UUID) -> int:
return await s.scalar(select(func.count()).select_from(MyGak).where(MyGak.user_id == user_id))
async def add(self, s: AsyncSession, user_id: uuid.UUID, a: int, b: int) -> MyGak:
"""같은 조합이 이미 있으면 그것을 돌려준다."""
await s.execute(insert(MyGak).values(user_id=user_id, index_a=a, index_b=b).on_conflict_do_nothing())
return await s.scalar(select(MyGak).where(MyGak.user_id == user_id, MyGak.index_a == a, MyGak.index_b == b))
async def delete(self, s: AsyncSession, user_id: uuid.UUID, my_gak_id: int) -> bool:
res = await s.execute(delete(MyGak).where(MyGak.my_gak_id == my_gak_id, MyGak.user_id == user_id).returning(MyGak.my_gak_id))
return res.first() is not None