add: device login

This commit is contained in:
EUForest
2025-10-11 15:55:45 +08:00
parent a273f8d883
commit 71018eb2f4
12 changed files with 677 additions and 24 deletions
+15
View File
@@ -76,3 +76,18 @@ func (m *customUserModel) DeleteDevice(ctx context.Context, id int64, tx ...*gor
}, data.GetCacheKeys()...)
return err
}
func (m *customUserModel) InsertDevice(ctx context.Context, data *Device, tx ...*gorm.DB) error {
defer func() {
if clearErr := m.ClearDeviceCache(ctx, data); clearErr != nil {
// log cache clear error
}
}()
return m.ExecNoCacheCtx(ctx, func(conn *gorm.DB) error {
if len(tx) > 0 {
conn = tx[0]
}
return conn.Create(data).Error
})
}