123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package knowledge
- import (
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- "time"
- )
- type KnowledgeResourceBiDashboardDetail struct {
- Id int `gorm:"column:id;primary_key"`
- BiDashboardDetailId int `gorm:"column:bi_dashboard_detail_id;comment:关联的BI仪表盘详情ID"`
- KnowledgeResourceId int `gorm:"column:knowledge_resource_id;comment:关联的知识库资源ID"`
- KnowledgeResourceType int `gorm:"column:knowledge_resource_type;comment:知识库资源类型:0事件库,1政策库,2观点库,3知识库"`
- CreateTime time.Time `gorm:"column:create_time;comment:创建时间"`
- }
- func (KnowledgeResourceBiDashboardDetail) TableName() string {
- return "knowledge_resource_bi_dashboard_detail"
- }
- func (k *KnowledgeResourceBiDashboardDetail) BatchAdd(items []*KnowledgeResourceBiDashboardDetail) (err error) {
- if len(items) == 0 {
- return
- }
- tx := global.DmSQL["rddp"].Begin()
- defer func() {
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- sql := `DELETE FROM knowledge_resource_bi_dashboard_detail WHERE bi_dashboard_detail_id =? `
- err = tx.Exec(sql, items[0].BiDashboardDetailId).Error
- if err != nil {
- return
- }
- err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
- return
- }
- func GetKnowledgeResourceIdsByCondition(condition string, pars []interface{}) (resourceIds []int, err error) {
- sql := "SELECT knowledge_resource_id FROM knowledge_resource_bi_dashboard_detail WHERE 1=1 "
- if condition != "" {
- sql += condition
- }
- err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&resourceIds).Error
- return
- }
|