org.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. type AuthorizeType int
  6. const (
  7. ORG_READABLE AuthorizeType = iota + 1
  8. ORG_WRITABLE
  9. ORG_ADMIN
  10. )
  11. // Team represents a organization team.
  12. type Team struct {
  13. Id int64
  14. OrgId int64 `xorm:"INDEX"`
  15. Name string
  16. Description string
  17. Authorize AuthorizeType
  18. NumMembers int
  19. NumRepos int
  20. }
  21. // NewTeam creates a record of new team.
  22. func NewTeam(t *Team) error {
  23. _, err := x.Insert(t)
  24. return err
  25. }
  26. // ________ ____ ___
  27. // \_____ \_______ ____ | | \______ ___________
  28. // / | \_ __ \/ ___\| | / ___// __ \_ __ \
  29. // / | \ | \/ /_/ > | /\___ \\ ___/| | \/
  30. // \_______ /__| \___ /|______//____ >\___ >__|
  31. // \/ /_____/ \/ \/
  32. // OrgUser represents an organization-user relation.
  33. type OrgUser struct {
  34. Id int64
  35. Uid int64 `xorm:"INDEX"`
  36. OrgId int64 `xorm:"INDEX"`
  37. IsPublic bool
  38. IsOwner bool
  39. NumTeam int
  40. }
  41. // GetOrgUsersByUserId returns all organization-user relations by user ID.
  42. func GetOrgUsersByUserId(uid int64) ([]*OrgUser, error) {
  43. ous := make([]*OrgUser, 0, 10)
  44. err := x.Where("uid=?", uid).Find(&ous)
  45. return ous, err
  46. }
  47. // ___________ ____ ___
  48. // \__ ___/___ _____ _____ | | \______ ___________
  49. // | |_/ __ \\__ \ / \| | / ___// __ \_ __ \
  50. // | |\ ___/ / __ \| Y Y \ | /\___ \\ ___/| | \/
  51. // |____| \___ >____ /__|_| /______//____ >\___ >__|
  52. // \/ \/ \/ \/ \/
  53. // TeamUser represents an team-user relation.
  54. type TeamUser struct {
  55. Id int64
  56. Uid int64
  57. OrgId int64 `xorm:"INDEX"`
  58. TeamId int64
  59. }