query.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package chart_permission
  2. import (
  3. "errors"
  4. "hongze/hongze_yb/global"
  5. "hongze/hongze_yb/utils"
  6. )
  7. // GetListByProductId 根据产品id获取所有权限列表
  8. func GetListByProductId(productId int64) (list []*ChartPermission, err error) {
  9. err = global.DEFAULT_MYSQL.Where(" product_id = ?", productId).Find(&list).Error
  10. return
  11. }
  12. // GetClassNameListByProductId 根据权限id获取权限分类
  13. func GetClassNameListByProductId(productId int64) (list []*ChartPermission, err error) {
  14. err = global.DEFAULT_MYSQL.Where(" product_id = ?", productId).Group("classify_name").Find(&list).Error
  15. return
  16. }
  17. // GetByWhereMap 根据查询条件map获取信息
  18. func GetByWhereMap(where map[string]interface{}) (list []*ChartPermission, err error) {
  19. cond, whereVal, buildErr := utils.WhereBuild(where)
  20. if buildErr != nil {
  21. err = errors.New("系统异常,生成查询语句失败")
  22. return
  23. }
  24. err = global.DEFAULT_MYSQL.Where(cond, whereVal...).Find(&list).Error
  25. return
  26. }
  27. // GetListByIds 通过IDs获取图表权限集合
  28. func GetListByIds(permissionIds []int) (list []*ChartPermission, err error) {
  29. err = global.DEFAULT_MYSQL.Model(ChartPermission{}).Where("chart_permission_id IN (?)", permissionIds).Scan(&list).Error
  30. return
  31. }