public_chart_info.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package data_manage
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. )
  6. // GetChartInfoByPublicClassifyId
  7. // @Description: 根据公共分类id获取指标列表
  8. // @author: Roc
  9. // @datetime 2024-12-03 14:09:32
  10. // @param classifyId int
  11. // @param chartInfoType int
  12. // @param source int
  13. // @return items []*ChartClassifyItems
  14. // @return err error
  15. func GetChartInfoByPublicClassifyId(classifyId, source int) (items []*ChartClassifyItems, err error) {
  16. o := global.DmSQL["data"]
  17. sql := ` SELECT chart_info_id,chart_classify_id,chart_public_classify_id,chart_name AS chart_classify_name,chart_name_en AS chart_classify_name_en,unique_code,source,sys_user_id,sys_user_real_name,start_date,chart_type, public_sort as sort,is_join_permission FROM chart_info WHERE chart_public_classify_id = ? AND source = ?`
  18. sql += ` order by public_sort asc,chart_info_id asc `
  19. err = o.Raw(sql, classifyId, source).Scan(&items).Error
  20. return
  21. }
  22. // UpdatePublicChartSuccess
  23. // @Description: 更新指标的公开成功状态
  24. // @author: Roc
  25. // @datetime 2024-12-06 13:37:01
  26. // @param chartInfoId int
  27. // @param classifyId int
  28. // @return err error
  29. func UpdatePublicChartSuccess(chartInfoId, classifyId int) (err error) {
  30. sql := `UPDATE chart_info set public_status = ?,chart_public_classify_id = ? ,modify_time=now(),public_time = now() WHERE chart_info_id = ?`
  31. err = global.DmSQL["data"].Exec(sql, utils.DataPublicSuccess, classifyId, chartInfoId).Error
  32. return
  33. }
  34. // UpdatePublicChart
  35. // @Description: 更新指标的公开状态
  36. // @author: Roc
  37. // @datetime 2024-12-06 11:10:53
  38. // @param chartInfoIdList []int
  39. // @param status int
  40. // @return err error
  41. func UpdatePublicChart(chartInfoIdList []int, status int) (err error) {
  42. if len(chartInfoIdList) <= 0 {
  43. return
  44. }
  45. sql := `UPDATE chart_info set public_status = ?,modify_time=now() `
  46. if status == utils.DataPublicSuccess {
  47. sql += `,public_time = now() `
  48. }
  49. sql += ` WHERE chart_info_id in (?) `
  50. err = global.DmSQL["data"].Exec(sql, status, chartInfoIdList).Error
  51. return
  52. }
  53. // UpdatePublicClassifyIdByChartInfoIdList
  54. // @Description: 根据指标id列表更新所属公共分类id
  55. // @author: Roc
  56. // @datetime 2024-12-10 13:18:52
  57. // @param chartInfoId int
  58. // @param chartClassifyId int
  59. // @return err error
  60. func UpdatePublicClassifyIdByChartInfoIdList(chartInfoIdList []int, chartClassifyId int) (err error) {
  61. if len(chartInfoIdList) <= 0 {
  62. return
  63. }
  64. sql := ` UPDATE chart_info SET chart_public_classify_id = ? WHERE chart_info_id in (?) AND public_status = 3 `
  65. err = global.DmSQL["data"].Exec(sql, chartClassifyId, chartInfoIdList).Error
  66. return
  67. }