👽 Update the account deletion

This commit is contained in:
LittleSheep 2025-03-01 14:07:19 +08:00
parent 10f75ab37a
commit 070fd7bb6a

View File

@ -2,8 +2,9 @@ package grpc
import ( import (
"context" "context"
"git.solsynth.dev/hypernet/nexus/pkg/nex" "git.solsynth.dev/hypernet/nexus/pkg/nex"
"strconv" jsoniter "github.com/json-iterator/go"
"git.solsynth.dev/hypernet/nexus/pkg/proto" "git.solsynth.dev/hypernet/nexus/pkg/proto"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database" "git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
@ -19,19 +20,17 @@ func (v *Server) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*prot
} }
switch resType { switch resType {
case "account": case "account":
id, ok := data["id"].(string) var data struct {
if !ok { ID int `json:"id"`
break
} }
numericId, err := strconv.Atoi(id) if err := jsoniter.Unmarshal(in.GetData(), &data); err != nil {
if err != nil {
break break
} }
tx := database.C.Begin() tx := database.C.Begin()
for _, model := range database.AutoMaintainRange { for _, model := range database.AutoMaintainRange {
switch model.(type) { switch model.(type) {
default: default:
tx.Delete(model, "account_id = ?", numericId) tx.Delete(model, "account_id = ?", data)
} }
} }
tx.Commit() tx.Commit()