chart_description.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package data_manage
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "time"
  6. )
  7. type ChartDescription struct {
  8. Id int `gorm:"column:id;primaryKey"`
  9. Description string `gorm:"column:description"`
  10. ChartInfoId int `gorm:"column:chart_info_id"` // 图表id
  11. SysUserId int `gorm:"column:sys_user_id"` // 创建人id
  12. SysUserRealName string `gorm:"column:sys_user_real_name"` // 创建人姓名
  13. ModifyTime time.Time `gorm:"column:modify_time"` // 变更时间
  14. CreateTime time.Time `gorm:"column:create_time"` // 关系建立时间
  15. }
  16. // AddChartDescription 添加图表简介
  17. func AddChartDescription(item *ChartDescription) (err error) {
  18. err = global.DbMap[utils.DbNameIndex].Create(item).Error
  19. return
  20. }
  21. // GetChartDescriptionByChartInfoId 根据图表ID获取图表简介
  22. func GetChartDescriptionByChartInfoId(chartInfoId int) (item []*ChartDescription, err error) {
  23. sql := `SELECT * FROM chart_description WHERE chart_info_id = ? order by create_time desc, id desc`
  24. err = global.DbMap[utils.DbNameIndex].Raw(sql, chartInfoId).Find(&item).Error
  25. return
  26. }
  27. // GetChartDescriptionById 根据ID获取图表简介
  28. func GetChartDescriptionById(id int) (item *ChartDescription, err error) {
  29. sql := `SELECT * FROM chart_description WHERE id = ?`
  30. err = global.DbMap[utils.DbNameIndex].Raw(sql, id).First(&item).Error
  31. return
  32. }
  33. // DeleteChartDescription 删除图表简介
  34. func DeleteChartDescription(id int) (err error) {
  35. sql := `DELETE FROM chart_description WHERE id = ?`
  36. err = global.DbMap[utils.DbNameIndex].Exec(sql, id).Error
  37. return
  38. }
  39. // DeleteChartDescriptionByChartInfoId 根据图表ID删除图表简介
  40. func DeleteChartDescriptionByChartInfoId(chartInfoId int) (err error) {
  41. sql := `DELETE FROM chart_description WHERE chart_info_id = ?`
  42. err = global.DbMap[utils.DbNameIndex].Exec(sql, chartInfoId).Error
  43. return
  44. }
  45. type ChartDescriptionList struct {
  46. Id int `gorm:"column:id;primaryKey"`
  47. Description string `gorm:"column:description"`
  48. ChartInfoId int `gorm:"column:chart_info_id"` // 图表id
  49. SysUserId int `gorm:"column:sys_user_id"` // 创建人id
  50. SysUserRealName string `gorm:"column:sys_user_real_name"` // 创建人姓名
  51. CreateTime string `gorm:"column:create_time"` // 创建时间
  52. }
  53. type ChartDescriptionListResponse struct {
  54. List []*ChartDescriptionList
  55. }
  56. type ChartDescriptionAddReq struct {
  57. ChartInfoId int `description:"图表id"`
  58. Description string `description:"简介"`
  59. }
  60. type ChartDescriptionReq struct {
  61. Id int
  62. Description string // 图表id
  63. ChartInfoId int
  64. SysUserId int // 创建人id
  65. SysUserRealName string // 创建人姓名
  66. AdminName string // 创建人姓名
  67. ModifyTime time.Time // 变更时间
  68. CreateTime time.Time // 关系建立时间
  69. }