feat: community RPC 从内存存储迁移到 ent 数据库

This commit is contained in:
zetaloop
2026-04-24 08:16:31 +08:00
parent 5ad579f03c
commit 6cc14479c5
69 changed files with 14396 additions and 501 deletions
@@ -3,7 +3,9 @@ package logic
import (
"context"
"errors"
"time"
"juwan-backend/app/community/rpc/internal/models/posts"
"juwan-backend/app/community/rpc/internal/svc"
"juwan-backend/app/community/rpc/pb"
@@ -29,17 +31,15 @@ func (l *DelPostsLogic) DelPosts(in *pb.DelPostsReq) (*pb.DelPostsResp, error) {
return nil, errors.New("id is required")
}
store := l.svcCtx.Store
store.Mu.Lock()
defer store.Mu.Unlock()
post, ok := store.Posts[in.GetId()]
if !ok {
return &pb.DelPostsResp{}, nil
now := time.Now()
_, err := l.svcCtx.CommunityModelRW.Posts.Update().
Where(posts.IDEQ(in.GetId()), posts.DeletedAtIsNil()).
SetDeletedAt(now).
SetUpdatedAt(now).
Save(l.ctx)
if err != nil {
logx.Errorf("delPosts err: %v", err)
}
now := nowUnix(0)
post.DeletedAt = now
post.UpdatedAt = now
return &pb.DelPostsResp{}, nil
}