file.go
784 字节
package dao
import (
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)
func FileDelete(ptr *pgTransaction.TransactionContext, fileId int, fileType domain.FileType) error {
sql := "delete from metadata.files where file_id = ? and file_type = ?"
_, err := ptr.PgTx.Exec(sql, fileId, fileType.ToString())
return err
}
func FileDeleteBySourceFileId(ptr *pgTransaction.TransactionContext, fileId int, fileType domain.FileType, excludeFileIs ...int) error {
sql := "delete from metadata.files where source_file_id = ? and file_type =? and file_id not in (?)"
_, err := ptr.PgTx.Exec(sql, fileId, fileType.ToString(), pg.In(excludeFileIs))
return err
}