public_edb_info.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package data_manage
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. )
  6. // GetEdbInfoByPublicClassifyId
  7. // @Description: 根据公共分类id获取指标列表
  8. // @author: Roc
  9. // @datetime 2024-12-03 14:09:32
  10. // @param classifyId int
  11. // @param edbInfoType int
  12. // @param edbType int
  13. // @return items []*EdbClassifyItems
  14. // @return err error
  15. func GetEdbInfoByPublicClassifyId(classifyId, edbInfoType, edbType int) (items []*EdbClassifyItems, err error) {
  16. o := global.DmSQL["data"]
  17. sql := ` SELECT edb_info_id,classify_id,edb_public_classify_id,edb_name AS classify_name,edb_name_en AS classify_name_en,unique_code,source_name,source,sys_user_id,sys_user_real_name,start_date,edb_code,edb_type, public_sort sort,is_join_permission FROM edb_info WHERE edb_public_classify_id = ? AND edb_info_type = ?`
  18. pars := []interface{}{classifyId, edbInfoType}
  19. // 如果筛选了指标类型,那么就根据条件来
  20. if edbType > 0 {
  21. sql += ` AND edb_type = ? `
  22. pars = append(pars, edbType)
  23. }
  24. sql += ` order by public_sort asc,edb_info_id asc `
  25. err = o.Raw(sql, pars...).Scan(&items).Error
  26. return
  27. }
  28. // UpdatePublicEdbSuccess
  29. // @Description: 更新指标的公开成功状态
  30. // @author: Roc
  31. // @datetime 2024-12-06 13:37:01
  32. // @param edbInfoId int
  33. // @param classifyId int
  34. // @return err error
  35. func UpdatePublicEdbSuccess(edbInfoId, classifyId int) (err error) {
  36. sql := `UPDATE edb_info set public_status = ?,edb_public_classify_id = ? ,modify_time=now(),public_time = now() WHERE edb_info_id = ?`
  37. err = global.DmSQL["data"].Exec(sql, utils.DataPublicSuccess, classifyId, edbInfoId).Error
  38. return
  39. }
  40. // UpdatePublicEdb
  41. // @Description: 更新指标的公开状态
  42. // @author: Roc
  43. // @datetime 2024-12-06 11:10:53
  44. // @param edbInfoIdList []int
  45. // @param status int
  46. // @return err error
  47. func UpdatePublicEdb(edbInfoIdList []int, status int) (err error) {
  48. if len(edbInfoIdList) <= 0 {
  49. return
  50. }
  51. sql := `UPDATE edb_info set public_status = ?,modify_time=now() `
  52. if status == utils.DataPublicSuccess {
  53. sql += `,public_time = now() `
  54. }
  55. sql += ` WHERE edb_info_id in (?) `
  56. err = global.DmSQL["data"].Exec(sql, status, edbInfoIdList).Error
  57. return
  58. }
  59. // UpdatePublicClassifyIdByEdbInfoIdList
  60. // @Description: 根据指标id列表更新所属公共分类id
  61. // @author: Roc
  62. // @datetime 2024-12-10 13:18:52
  63. // @param edbInfoId int
  64. // @param edbClassifyId int
  65. // @return err error
  66. func UpdatePublicClassifyIdByEdbInfoIdList(edbInfoIdList []int, edbClassifyId int) (err error) {
  67. if len(edbInfoIdList) <= 0 {
  68. return
  69. }
  70. sql := ` UPDATE edb_info SET edb_public_classify_id = ? WHERE edb_info_id in (?) AND public_status = 3 `
  71. err = global.DmSQL["data"].Exec(sql, edbClassifyId, edbInfoIdList).Error
  72. return
  73. }