forum_chart_edb_mapping.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package data_manage
  2. import (
  3. "time"
  4. "eta/eta_api/global"
  5. "eta/eta_api/utils"
  6. )
  7. type ForumChartEdbMapping struct {
  8. ID int `gorm:"column:id;primaryKey" description:"主键"`
  9. ChartInfoId int
  10. EdbInfoIds string
  11. CreatedTime time.Time
  12. ModifyTime time.Time
  13. }
  14. // 根据chartInfoId获取edbInfoIds
  15. func GetForumEdbInfoIdsByChartInfoId(chartInfoId int) (edbInfoIds string, err error) {
  16. o := global.DbMap[utils.DbNameIndex]
  17. sql := `SELECT edb_info_ids FROM forum_chart_edb_mapping WHERE chart_info_id = ?`
  18. err = o.Raw(sql, chartInfoId).Scan(&edbInfoIds).Error
  19. return
  20. }
  21. // 新增
  22. func AddForumChartEdbMapping(chartInfoId int, edbInfoIds string) (err error) {
  23. o := global.DbMap[utils.DbNameIndex]
  24. sql := `INSERT INTO forum_chart_edb_mapping (chart_info_id, edb_info_ids, created_time, modify_time) VALUES (?, ?, ?, ?)`
  25. err = o.Exec(sql, chartInfoId, edbInfoIds, time.Now(), time.Now()).Error
  26. return
  27. }
  28. // 更新
  29. func UpdateForumChartEdbMapping(chartInfoId int, edbInfoIds string) (err error) {
  30. o := global.DbMap[utils.DbNameIndex]
  31. sql := `UPDATE forum_chart_edb_mapping SET edb_info_ids = ?, modify_time = ? WHERE chart_info_id = ?`
  32. err = o.Exec(sql, edbInfoIds, time.Now(), chartInfoId).Error
  33. return
  34. }
  35. // 删除
  36. func DeleteForumChartEdbMapping(chartInfoId int) (err error) {
  37. o := global.DbMap[utils.DbNameIndex]
  38. sql := `DELETE FROM forum_chart_edb_mapping WHERE chart_info_id = ?`
  39. err = o.Exec(sql, chartInfoId).Error
  40. return
  41. }