table.go
1.0 KB
package dao
import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"time"
)
func TableDelete(ptr *pgTransaction.TransactionContext, tableId int, tableType domain.TableType) error {
sql := "delete from metadata.tables where table_id = ? and table_type = ?"
_, err := ptr.PgTx.Exec(sql, tableId, tableType.ToString())
return err
}
func TableSoftDelete(ptr *pgTransaction.TransactionContext, tableId int, tableType domain.TableType) error {
sql := "update metadata.tables set deleted_at=? where table_id = ? and table_type = ?"
_, err := ptr.PgTx.Exec(sql, time.Now(), tableId, tableType.ToString())
return err
}
func TableDeleteByTime(ptr *pgTransaction.TransactionContext, tableType domain.TableType, begin time.Time, end time.Time) error {
sql := "delete from metadata.tables where table_type = ? and created_at >=? and created_at< ?"
_, err := ptr.PgTx.Exec(sql, tableType.ToString(), begin, end)
return err
}