my_chart.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package chart
  2. import (
  3. "errors"
  4. "hongze/hongze_yb/models/tables/my_chart_classify"
  5. "hongze/hongze_yb/services/user"
  6. )
  7. // GetUserChartClassifyListByCondition 获取用户图表分类列表
  8. func GetUserChartClassifyListByCondition(userInfo user.UserInfo, publicCondition, privateCondition map[string]interface{}) (publicClassify, privateClassify []*my_chart_classify.MyChartClassify, err error) {
  9. // 判断是否为内部人员
  10. isInner, adminInfo, err := user.GetAdminByUserInfo(userInfo)
  11. if err != nil {
  12. err = errors.New("用户信息有误, Err:" + err.Error())
  13. return
  14. }
  15. if isInner {
  16. // 内部人员
  17. publicCondition["is_public"] = 1
  18. publicCondition["admin_id !="] = adminInfo.AdminID
  19. privateCondition["admin_id"] = adminInfo.AdminID
  20. privateClassify, err = my_chart_classify.GetClassifyListByCondition(privateCondition, "sort ASC, my_chart_classify_id ASC")
  21. if err != nil {
  22. err = errors.New("获取我的图表分类失败, Err:" + err.Error())
  23. return
  24. }
  25. } else {
  26. // 用户
  27. publicCondition["is_public"] = 1
  28. publicCondition["is_company_public"] = 1
  29. }
  30. publicClassify, err = my_chart_classify.GetClassifyListByCondition(publicCondition, "public_time ASC")
  31. if err != nil {
  32. err = errors.New("获取公共图表分类失败, Err:" + err.Error())
  33. return
  34. }
  35. return
  36. }