query.go 973 B

123456789101112131415161718192021222324252627282930
  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. }