// Code generated by go.ipao.vip/gen. DO NOT EDIT. // Code generated by go.ipao.vip/gen. DO NOT EDIT. // Code generated by go.ipao.vip/gen. DO NOT EDIT. package models import ( "context" "time" "go.ipao.vip/gen" ) const TableNameAuditLog = "audit_logs" // AuditLog mapped from table type AuditLog struct { ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;comment:主键ID。" json:"id"` // 主键ID。 TenantID int64 `gorm:"column:tenant_id;type:bigint;not null;comment:租户ID;用途:关联租户审计(0表示平台级)。" json:"tenant_id"` // 租户ID;用途:关联租户审计(0表示平台级)。 OperatorID int64 `gorm:"column:operator_id;type:bigint;not null;comment:操作者用户ID;用途:审计追溯;约束:必须存在。" json:"operator_id"` // 操作者用户ID;用途:审计追溯;约束:必须存在。 Action string `gorm:"column:action;type:character varying(64);not null;comment:动作标识;用途:检索分类;约束:例如 review_content/freeze_coupon。" json:"action"` // 动作标识;用途:检索分类;约束:例如 review_content/freeze_coupon。 TargetID string `gorm:"column:target_id;type:character varying(64);not null;comment:目标ID;用途:定位被操作对象;可为空字符串。" json:"target_id"` // 目标ID;用途:定位被操作对象;可为空字符串。 Detail string `gorm:"column:detail;type:text;not null;comment:动作详情;用途:记录操作原因与补充说明。" json:"detail"` // 动作详情;用途:记录操作原因与补充说明。 CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now();comment:创建时间;用途:时间序列查询与审计留存。" json:"created_at"` // 创建时间;用途:时间序列查询与审计留存。 } // Quick operations without importing query package // Update applies changed fields to the database using the default DB. func (m *AuditLog) Update(ctx context.Context) (gen.ResultInfo, error) { return Q.AuditLog.WithContext(ctx).Updates(m) } // Save upserts the model using the default DB. func (m *AuditLog) Save(ctx context.Context) error { return Q.AuditLog.WithContext(ctx).Save(m) } // Create inserts the model using the default DB. func (m *AuditLog) Create(ctx context.Context) error { return Q.AuditLog.WithContext(ctx).Create(m) } // Delete removes the row represented by the model using the default DB. func (m *AuditLog) Delete(ctx context.Context) (gen.ResultInfo, error) { return Q.AuditLog.WithContext(ctx).Delete(m) } // ForceDelete permanently deletes the row (ignores soft delete) using the default DB. func (m *AuditLog) ForceDelete(ctx context.Context) (gen.ResultInfo, error) { return Q.AuditLog.WithContext(ctx).Unscoped().Delete(m) } // Reload reloads the model from database by its primary key and overwrites current fields. func (m *AuditLog) Reload(ctx context.Context) error { fresh, err := Q.AuditLog.WithContext(ctx).GetByID(m.ID) if err != nil { return err } *m = *fresh return nil }