Merge branch 'react-native' into release/1026-merge

# Conflicts:
#	backend/common/enums.py
#	backend/router/v1/auth/account.py
#	frontend/.dockerignore
#	frontend/package-lock.json
#	frontend/package.json
#	frontend/public/terms.html
#	frontend/src/api/client/index.ts
#	frontend/src/b/BLayout.tsx
#	frontend/src/b/Sheets.tsx
#	shared/api/client/@tanstack/react-query.gen.ts
#	shared/api/client/sdk.gen.ts
#	shared/api/client/types.gen.ts
This commit is contained in:
minaChoi committed 2026-10-26 15:36:05 +09:00
commit 5d18fa51fa
148 files changed
+21940 -4532

No files matched your search

+29 -2
View File
@@ -1,11 +1,12 @@
import uuid
from collections import Counter
from datetime import datetime, timezone
from typing import Optional
from sqlalchemy import select
from sqlalchemy import delete, select, update
from sqlalchemy.ext.asyncio import AsyncSession
from common.database.model.models import User
from common.database.model.models import Comment, CommentLike, CommentReport, Post, PostLike, PostSave, User, UserBlock
class UserCRUD:
@@ -46,3 +47,29 @@ class UserCRUD:
user.updated_at = datetime.now(timezone.utc)
await s.flush()
return user
async def agree_terms(self, s: AsyncSession, user_id: uuid.UUID) -> None:
await s.execute(update(User).where(User.user_id == user_id, User.terms_agreed_at.is_(None)).values(terms_agreed_at=datetime.now(timezone.utc)))
async def withdraw(self, s: AsyncSession, user_id: uuid.UUID) -> None:
"""계정과 그 사람이 남긴 좋아요·저장·댓글·신고·차단을 모두 지우고, 게시물·댓글에 쌓인 수를 그만큼 줄인다."""
liked_posts = (await s.scalars(delete(PostLike).where(PostLike.user_id == user_id).returning(PostLike.post_id))).all()
if liked_posts:
await s.execute(update(Post).where(Post.post_id.in_(liked_posts)).values(like_count=Post.like_count - 1))
liked_comments = (await s.scalars(delete(CommentLike).where(CommentLike.user_id == user_id).returning(CommentLike.comment_id))).all()
if liked_comments:
await s.execute(update(Comment).where(Comment.comment_id.in_(liked_comments)).values(like_count=Comment.like_count - 1))
await s.execute(delete(PostSave).where(PostSave.user_id == user_id))
reported = (await s.scalars(delete(CommentReport).where(CommentReport.user_id == user_id).returning(CommentReport.comment_id))).all()
if reported:
await s.execute(update(Comment).where(Comment.comment_id.in_(reported)).values(report_count=Comment.report_count - 1))
await s.execute(delete(UserBlock).where((UserBlock.user_id == user_id) | (UserBlock.blocked_id == user_id)))
mine = (await s.execute(delete(Comment).where(Comment.user_id == user_id).returning(Comment.comment_id, Comment.post_id, Comment.deleted, Comment.is_hidden))).all()
if mine:
ids = [c for c, _, _, _ in mine]
await s.execute(delete(CommentLike).where(CommentLike.comment_id.in_(ids)))
await s.execute(delete(CommentReport).where(CommentReport.comment_id.in_(ids)))
# 이미 지웠거나 숨긴 댓글은 댓글 수에서 빠져 있다
for post_id, n in Counter(p for _, p, deleted, hidden in mine if not deleted and not hidden).items():
await s.execute(update(Post).where(Post.post_id == post_id).values(comment_count=Post.comment_count - n))
await s.execute(delete(User).where(User.user_id == user_id))