智慧食堂
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
828 B

  1. package db
  2. import (
  3. "applet/app/admin/enum"
  4. "applet/app/db/model"
  5. "applet/app/utils/logx"
  6. "xorm.io/xorm"
  7. )
  8. type PermissionGroupDb struct {
  9. Db *xorm.Engine `json:"db"`
  10. }
  11. func (permissionGroupDb *PermissionGroupDb) Set() { // set方法
  12. permissionGroupDb.Db = Db
  13. }
  14. func (permissionGroupDb *PermissionGroupDb) FindPermissionGroup() (*[]model.PermissionGroup, error) {
  15. var m []model.PermissionGroup
  16. if err := permissionGroupDb.Db.Where("state = ?", enum.PermissionGroupStateForNormal).Asc("id").Find(&m); err != nil {
  17. return nil, logx.Error(err)
  18. }
  19. return &m, nil
  20. }
  21. func (permissionGroupDb *PermissionGroupDb) FindPermissionGroupV2() (*[]model.PermissionGroup, error) {
  22. var m []model.PermissionGroup
  23. if err := permissionGroupDb.Db.Asc("id").Find(&m); err != nil {
  24. return nil, logx.Error(err)
  25. }
  26. return &m, nil
  27. }