github.com/octohelm/storage@v0.0.0-20240516030302-1ac2cc1ea347/testdata/model/common.go (about)

     1  package model
     2  
     3  import (
     4  	"database/sql/driver"
     5  	"time"
     6  
     7  	"github.com/octohelm/storage/pkg/datatypes"
     8  )
     9  
    10  type OperateTime struct {
    11  	CreatedAt datatypes.Datetime `db:"f_created_at,default=CURRENT_TIMESTAMP,onupdate=CURRENT_TIMESTAMP"`
    12  	UpdatedAt int64              `db:"f_updated_at,default='0'"`
    13  }
    14  
    15  type OperateTimeWithDeleted struct {
    16  	OperateTime
    17  	DeletedAt int64 `db:"f_deleted_at,default='0'"`
    18  }
    19  
    20  //var _ dal.ModelWithSoftDelete = &OperateTimeWithDeleted{}
    21  
    22  func (v *OperateTimeWithDeleted) SoftDeleteFieldAndZeroValue() (string, driver.Value) {
    23  	return "DeletedAt", int64(v.DeletedAt)
    24  }
    25  
    26  func (v *OperateTimeWithDeleted) MarkDeletedAt() {
    27  	v.DeletedAt = time.Now().Unix()
    28  }