disable soft deletion in group api (#10)

* disable soft deletion in group api

* remove DeleteAt

* remove DeleteAt service
This commit is contained in:
UUBulb 2024-11-19 21:41:21 +08:00 committed by GitHub
parent be79b11e58
commit 3efbf9cce1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 20 deletions

View File

@ -146,7 +146,7 @@ func updateNotificationGroup(c *gin.Context) (any, error) {
if err := tx.Save(&ngDB).Error; err != nil { if err := tx.Save(&ngDB).Error; err != nil {
return err return err
} }
if err := tx.Delete(&model.NotificationGroupNotification{}, "notification_group_id = ?", id).Error; err != nil { if err := tx.Unscoped().Delete(&model.NotificationGroupNotification{}, "notification_group_id = ?", id).Error; err != nil {
return err return err
} }

View File

@ -143,7 +143,7 @@ func updateServerGroup(c *gin.Context) (any, error) {
if err := tx.Save(&sgDB).Error; err != nil { if err := tx.Save(&sgDB).Error; err != nil {
return err return err
} }
if err := tx.Delete(&model.ServerGroupServer{}, "server_group_id = ?", id).Error; err != nil { if err := tx.Unscoped().Delete(&model.ServerGroupServer{}, "server_group_id = ?", id).Error; err != nil {
return err return err
} }

View File

@ -2,8 +2,6 @@ package model
import ( import (
"time" "time"
"gorm.io/gorm"
) )
const CtxKeyAuthorizedUser = "ckau" const CtxKeyAuthorizedUser = "ckau"
@ -12,7 +10,8 @@ type Common struct {
ID uint64 `gorm:"primaryKey" json:"id,omitempty"` ID uint64 `gorm:"primaryKey" json:"id,omitempty"`
CreatedAt time.Time `gorm:"index;<-:create" json:"created_at,omitempty"` CreatedAt time.Time `gorm:"index;<-:create" json:"created_at,omitempty"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at,omitempty"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at,omitempty"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"` // Do not use soft deletion
// DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
} }
type Response struct { type Response struct {

View File

@ -2,15 +2,12 @@ package model
import ( import (
"time" "time"
"gorm.io/gorm"
) )
type ServiceHistory struct { type ServiceHistory struct {
ID uint64 `gorm:"primaryKey" json:"id,omitempty"` ID uint64 `gorm:"primaryKey" json:"id,omitempty"`
CreatedAt time.Time `gorm:"index;<-:create;index:idx_server_id_created_at_service_id_avg_delay" json:"created_at,omitempty"` CreatedAt time.Time `gorm:"index;<-:create;index:idx_server_id_created_at_service_id_avg_delay" json:"created_at,omitempty"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at,omitempty"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at,omitempty"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
ServiceID uint64 `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"service_id,omitempty"` ServiceID uint64 `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"service_id,omitempty"`
ServerID uint64 `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"server_id,omitempty"` ServerID uint64 `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"server_id,omitempty"`
AvgDelay float32 `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"avg_delay,omitempty"` // 平均延迟,毫秒 AvgDelay float32 `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"avg_delay,omitempty"` // 平均延迟,毫秒