1234567891011121314151617181920212223242526272829303132333435 |
- package index
- import (
- "eta/eta_bridge/global"
- "fmt"
- "time"
- )
- type EdbUpdateLog struct {
- Id int64 `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
- OpDbName string `gorm:"column:op_db_name;type:varchar(255);comment:库名;default:NULL;" json:"op_db_name"` // 库名
- OpTableName string `gorm:"column:op_table_name;type:varchar(255);comment:表名;" json:"op_table_name"` // 表名
- OpType string `gorm:"column:op_type;type:varchar(16);comment:变更类型;default:NULL;" json:"op_type"` // 变更类型
- OldData string `gorm:"column:old_data;type:text;comment:历史数据;" json:"old_data"` // 历史数据
- NewData string `gorm:"column:new_data;type:text;comment:新数据;" json:"new_data"` // 新数据
- CreateTime time.Time `gorm:"column:create_time;type:timestamp;default:CURRENT_TIMESTAMP;" json:"create_time"`
- }
- func (m *EdbUpdateLog) TableName() string {
- return "edb_update_log"
- }
- // Create 添加数据
- func (m *EdbUpdateLog) Create() (err error) {
- err = global.MYSQL["index"].Create(m).Error
- return
- }
- // DeleteBeforeTenDayLog 清除n前的日志数据
- func (m *EdbUpdateLog) DeleteBeforeTenDayLog(beforeDate string) (err error) {
- sql := fmt.Sprintf(`DELETE FROM %s WHERE create_time < ?`, m.TableName())
- err = global.MYSQL["index"].Exec(sql, beforeDate).Error
- return
- }
|