package models

import "github.com/beego/beego/v2/client/orm"

type EdbImportFail struct {
	Id           int `orm:"column(id);pk"`
	ClassifyName string
	Frequency    string
	SecName      string
	Unit         string
	Remark       string
	SysUserId    string
}

func AddEdbImportFail(item *EdbImportFail) (err error) {
	o := orm.NewOrmUsingDB("edb")
	_, err = o.Insert(item)
	return err
}

// DelEdbImportFail 删除导入失败记录
func DelEdbImportFail(userId int) (err error) {
	o := orm.NewOrmUsingDB("edb")
	sql := `delete from edb_import_fail where sys_user_id=?`
	_, err = o.Raw(sql, userId).Exec()
	return err
}

// GetEdbImportFailList 获取指标数据导入失败数据
func GetEdbImportFailList(sysUserId int) (items []*EdbImportFail, err error) {
	o := orm.NewOrmUsingDB("edb")
	sql := ` SELECT * FROM edb_import_fail WHERE sys_user_id=? `
	_, err = o.Raw(sql, sysUserId).QueryRows(&items)
	return
}
