👽 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 (
"context"
"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/paperclip/pkg/internal/database"
@ -19,19 +20,17 @@ func (v *Server) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*prot
}
switch resType {
case "account":
id, ok := data["id"].(string)
if !ok {
break
var data struct {
ID int `json:"id"`
}
numericId, err := strconv.Atoi(id)
if err != nil {
if err := jsoniter.Unmarshal(in.GetData(), &data); err != nil {
break
}
tx := database.C.Begin()
for _, model := range database.AutoMaintainRange {
switch model.(type) {
default:
tx.Delete(model, "account_id = ?", numericId)
tx.Delete(model, "account_id = ?", data)
}
}
tx.Commit()