🚧 Refactor backup service
This commit is contained in:
@@ -16,17 +16,19 @@ type Document struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// 创建时间
|
||||
// UUID for cross-device sync (UUIDv7)
|
||||
UUID string `json:"uuid"`
|
||||
// creation time
|
||||
CreatedAt string `json:"created_at"`
|
||||
// 最后更新时间
|
||||
// update time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
// 删除时间,NULL表示未删除
|
||||
// deleted at
|
||||
DeletedAt *string `json:"deleted_at,omitempty"`
|
||||
// 文档标题
|
||||
// document title
|
||||
Title string `json:"title"`
|
||||
// 文档内容
|
||||
// document content
|
||||
Content string `json:"content"`
|
||||
// 是否锁定
|
||||
// document locked status
|
||||
Locked bool `json:"locked"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
@@ -40,7 +42,7 @@ func (*Document) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullBool)
|
||||
case document.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case document.FieldCreatedAt, document.FieldUpdatedAt, document.FieldDeletedAt, document.FieldTitle, document.FieldContent:
|
||||
case document.FieldUUID, document.FieldCreatedAt, document.FieldUpdatedAt, document.FieldDeletedAt, document.FieldTitle, document.FieldContent:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -63,6 +65,12 @@ func (_m *Document) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int(value.Int64)
|
||||
case document.FieldUUID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field uuid", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UUID = value.String
|
||||
}
|
||||
case document.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -136,6 +144,9 @@ func (_m *Document) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Document(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("uuid=")
|
||||
builder.WriteString(_m.UUID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt)
|
||||
builder.WriteString(", ")
|
||||
|
||||
Reference in New Issue
Block a user