package bi_dashboard import ( "eta_gn/eta_api/global" "time" ) type BiDashboardDetail struct { BiDashboardDetailId int `gorm:"primaryKey;autoIncrement;column:bi_dashboard_detail_id" ` // bi看板id BiDashboardId int `gorm:"column:bi_dashboard_id" ` // 看板id Type int `gorm:"column:type" ` // 1图表 2表格 3知识资源库 Conf string `gorm:"column:conf" ` // 配置信息 UniqueCode string `gorm:"column:unique_code;size:32;not null" ` // 报告唯一编码 Sort int `gorm:"column:sort" ` // 排序字段 CreateTime time.Time `gorm:"column:create_time" ` // 创建时间 ModifyTime time.Time `gorm:"column:modify_time" ` // 更新时间 } // tableName func (m *BiDashboardDetail) TableName() string { return "bi_dashboard_detail" } func (m *BiDashboardDetail) Insert() (err error) { return global.DEFAULT_DmSQL.Create(m).Error } func GetBiDashboardDetailById(id int) (list []*BiDashboardDetail, err error) { err = global.DEFAULT_DmSQL.Table("bi_dashboard_detail").Where("bi_dashboard_id IN ?", id).Find(&list).Error return } // GetBiDashboardDetailIdByBidashboardIdAndType 获取看板详情id func GetBiDashboardDetailIdByBidashboardIdAndType(bid int, t int) (ids []int, err error) { sql := "SELECT bi_dashboard_detail_id FROM bi_dashboard_detail WHERE bi_dashboard_id = ? AND type = ?" err = global.DEFAULT_DmSQL.Raw(sql, bid, t).Scan(&ids).Error return } // multiAdd func AddBiDashboardDetailMulti(items []*BiDashboardDetail) (err error) { return global.DEFAULT_DmSQL.CreateInBatches(items, 100).Error } // del func DeleteBiDashboardDetail(id int) (err error) { return global.DEFAULT_DmSQL.Where("bi_dashboard_id = ?", id).Delete(&BiDashboardDetail{}).Error } type MoveDashboardDetailReq struct { BiDashboardId int `description:"看板id"` BiDashboardDetailId int `description:"看板详情id"` Sort int `description:"排序"` OtherDetailId int `description:"交换的详情id"` OtherSort int `description:"交换的排序"` } // update func EditBiDashboardDetail(item *BiDashboardDetail) (err error) { return global.DEFAULT_DmSQL.Model(item).Where("bi_dashboard_detail_id = ?", item.BiDashboardDetailId).Updates(item).Error } type DelDashboardDetailReq struct { BiDashboardDetailId int `description:"看板详情id"` } // del func DeleteBiDashboardDetailByDetailId(id int) (err error) { return global.DEFAULT_DmSQL.Where("bi_dashboard_detail_id = ?", id).Delete(&BiDashboardDetail{}).Error }