knowledge_import_fail.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package knowledge
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "fmt"
  6. "time"
  7. )
  8. type KnowledgeImportFail struct {
  9. Id int `gorm:"column:id;primaryKey;autoIncrement" description:"主键ID"`
  10. ResourceType int `gorm:"column:resource_type;"`
  11. Title string `gorm:"column:title;"`
  12. Content string `gorm:"column:content"`
  13. SourceFrom string `gorm:"column:source_from"`
  14. Tag string `gorm:"column:tag"`
  15. ClassifyFirst string `gorm:"column:classify_first;"`
  16. ClassifySecond string `gorm:"column:classify_second;"`
  17. ClassifyThird string `gorm:"column:classify_third;"`
  18. StartTime string `gorm:"column:start_time"`
  19. EndTime string `gorm:"column:end_time"`
  20. StartDate string `gorm:"column:start_date"`
  21. EndDate string `gorm:"column:end_date"`
  22. Remark string `gorm:"column:remark" description:"备注"`
  23. SysUserId string `gorm:"column:sys_user_id" description:"系统用户ID"`
  24. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  25. }
  26. func (m *KnowledgeImportFail) TableName() string {
  27. return "knowledge_import_fail"
  28. }
  29. func (m *KnowledgeImportFail) Add(item *KnowledgeImportFail) (err error) {
  30. err = global.DmSQL["rddp"].Create(item).Error
  31. return
  32. }
  33. func (m *KnowledgeImportFail) MultiAdd(items []*KnowledgeImportFail) (err error) {
  34. err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
  35. return err
  36. }
  37. func (m *KnowledgeImportFail) Delete(userId, resourceType int) (err error) {
  38. sql := fmt.Sprintf(`delete from %s where sys_user_id=? and resource_type=?`, m.TableName())
  39. err = global.DmSQL["rddp"].Exec(sql, userId, resourceType).Error
  40. return err
  41. }
  42. func (m *KnowledgeImportFail) GetListBySysUserId(sysUserId, resourceType int) (items []*KnowledgeImportFail, err error) {
  43. sql := fmt.Sprintf(` SELECT * FROM %s WHERE sys_user_id=? and resource_type=? `, m.TableName())
  44. err = global.DmSQL["rddp"].Raw(sql, sysUserId, resourceType).Find(&items).Error
  45. return
  46. }