- 新增 dao.Now() 函数获取数据库毫秒精度时间,避免多实例时钟偏差 - 增量同步查询增加上界(updated_at <= upperBound)防止竞态条件 - 配置创建、更新、删除、回滚统一使用数据库时间替代 time.Now() - 配置历史新增 operate 字段记录操作类型(update/delete/rollback) - 删除配置和回滚操作前增加历史快照记录 - 新增 DeleteHistory 接口支持手动删除单条历史记录 - 移除 GetHistory 的 Limit(5) 限制,返回完整历史列表 - 删除应用时同步更新关联配置的 updated_at 以便增量同步识别 - version 字段改为必填,前后端同步增加校验规则 - 前端历史列表增加操作类型列、删除按钮及表格最大高度限制 - 数据库表结构 datetime 升级为 datetime(3) 支持毫秒精度
49 lines
2.1 KiB
Go
49 lines
2.1 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
type AppConfig struct {
|
|
Id int `xorm:"int autoincr pk" json:"id"`
|
|
GroupId *int `xorm:"int" json:"groupId"`
|
|
AppId *int `xorm:"int" json:"appId"`
|
|
AppCode string `xorm:"varchar(32)" json:"appCode"`
|
|
Env string `xorm:"varchar(16)" json:"env"`
|
|
Version string `xorm:"varchar(32)" json:"version"`
|
|
Name string `xorm:"varchar(32)" json:"name"`
|
|
Type int `xorm:"smallint(1)" json:"type"` // 1:file, 2:kv, 3:json
|
|
Contents string `xorm:"text" json:"contents"`
|
|
Enabled bool `xorm:"tinyint(1) default 1" json:"enabled"`
|
|
CreatedAt *time.Time `xorm:"datetime(3)" json:"createdAt"`
|
|
CreatedBy string `xorm:"varchar(32)" json:"createdBy"`
|
|
UpdatedAt *time.Time `xorm:"datetime(3)" json:"updatedAt"`
|
|
UpdatedBy string `xorm:"varchar(32)" json:"updatedBy"`
|
|
Global bool `xorm:"-" json:"global"`
|
|
AppNames string `xorm:"-" json:"appNames,omitempty"`
|
|
ClientCount int `xorm:"-" json:"clientCount,omitempty"`
|
|
}
|
|
|
|
func (AppConfig) TableName() string {
|
|
return "app_config"
|
|
}
|
|
|
|
type AppConfigHistory struct {
|
|
Id int `xorm:"int autoincr pk" json:"id"`
|
|
OriginId int `xorm:"int" json:"originId"`
|
|
AppId *int `xorm:"int" json:"appId"`
|
|
AppName string `xorm:"varchar(32)" json:"appName"`
|
|
AppNames string `xorm:"varchar(64)" json:"appNames"`
|
|
Env string `xorm:"varchar(16)" json:"env"`
|
|
Version string `xorm:"varchar(32)" json:"version"`
|
|
Name string `xorm:"varchar(32)" json:"name"`
|
|
Type int `xorm:"smallint(1)" json:"type"`
|
|
Operate string `xorm:"varchar(16)" json:"operate"` // update, delete, rollback
|
|
Contents string `xorm:"text" json:"contents"`
|
|
ActiveContents string `xorm:"-" json:"activeContents,omitempty"`
|
|
CreatedAt *time.Time `xorm:"datetime" json:"createdAt"`
|
|
CreatedBy string `xorm:"varchar(32)" json:"createdBy"`
|
|
}
|
|
|
|
func (AppConfigHistory) TableName() string {
|
|
return "app_config_history"
|
|
}
|