model

package
v0.0.0-...-da014be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ASOK ..
	ASOK
	// ASFail ..
	ASFail
)
View Source
const (

	// UCPManager 企业管理员
	UCPManager
	// UCPSuperManager 企业超级管理员
	UCPSuperManager
)
View Source
const (

	// UTPMember 小组成员
	UTPMember
	// UTPManager 小组管理员
	UTPManager
)
View Source
const CtxKeyAuthorizedUser = "cau"

CtxKeyAuthorizedUser ..

Variables

This section is empty.

Functions

func GetIndividualFromTeams

func GetIndividualFromTeams(db *gorm.DB, teams []uint64) ([]uint64, error)

GetIndividualFromTeams ..

Types

type Account

type Account struct {
	Common    `json:"common,omitempty"`
	Login     string `gorm:"UNIQUE_INDEX" json:"login,omitempty"`
	Name      string `json:"name,omitempty"` // 昵称
	AvatarURL string `json:"avatar_url,omitempty"`

	Status  uint   `json:"status,omitempty"`
	Message string `json:"message,omitempty"`
	Token   string `json:"token,omitempty"`

	SyncedAt  time.Time
	CompanyID uint64 `json:"company_id,omitempty"`
}

Account ..

func NewAccountFromGitHub

func NewAccountFromGitHub(gu *github.User) Account

NewAccountFromGitHub ..

type Common

type Common struct {
	ID        uint64 `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

Common ..

type Company

type Company struct {
	Common
	Brand     string
	AvatarURL string

	Managers      []User
	SuperManagers []User
}

Company ...

func (*Company) CheckUserPermission

func (c *Company) CheckUserPermission(db *gorm.DB, userID, minPermission uint64) (uint64, error)

CheckUserPermission ..

type Config

type Config struct {
	Debug bool
	Site  struct {
		Brand      string // 站点名称
		CookieName string
	}
	GitHub struct {
		ClientID     string
		ClientSecret string
	}
}

Config ..

func ReadInConfig

func ReadInConfig(path string) (*Config, error)

ReadInConfig ..

type Repository

type Repository struct {
	ID          uint64 `gorm:"primary_key"`
	Name        string
	HTMLURL     string
	Description string
	Private     bool

	SyncedAt  time.Time // 最后一次同步
	AccountID uint64

	OutsideCollaborators []User
	Account              Account
}

Repository ..

func NewRepositoryFromGitHub

func NewRepositoryFromGitHub(gr *github.Repository) Repository

NewRepositoryFromGitHub ..

func (*Repository) GetTeams

func (r *Repository) GetTeams(db *gorm.DB) ([]uint64, error)

GetTeams ..

func (*Repository) HasUser

func (r *Repository) HasUser(db *gorm.DB, userID uint64) (bool, error)

HasUser ..

func (*Repository) IsIndividualCollaborator

func (r *Repository) IsIndividualCollaborator(db *gorm.DB, teamIDs []uint64) (bool, error)

IsIndividualCollaborator 是不是只在一个 Team 的开发者

func (*Repository) IsOutsideCollaborator

func (r *Repository) IsOutsideCollaborator(db *gorm.DB, userID uint64) (bool, error)

IsOutsideCollaborator 是不是只在一个 Team 的开发者

func (*Repository) RelatedOutsideCollaborators

func (r *Repository) RelatedOutsideCollaborators(db *gorm.DB) error

RelatedOutsideCollaborators ..

func (*Repository) ReleatedAccount

func (r *Repository) ReleatedAccount(db *gorm.DB) error

ReleatedAccount ..

func (*Repository) SAccountID

func (r *Repository) SAccountID() string

SAccountID ..

func (*Repository) SID

func (r *Repository) SID() string

SID ..

type Response

type Response struct {
	Code    uint64      `json:"code,omitempty"`
	Message string      `json:"message,omitempty"`
	Result  interface{} `json:"result,omitempty"`
}

Response ..

type Team

type Team struct {
	Common
	Name string `json:"name,omitempty"`

	CompanyID uint64 `json:"company_id,omitempty"`

	RepositoriesID []uint64 `gorm:"-"`
	Repositories   []Repository
	EmployeesID    []uint64 `gorm:"-"`
	Employees      []User
	Managers       []User
}

Team ..

func (*Team) CheckUserPermission

func (t *Team) CheckUserPermission(db *gorm.DB, userID uint64, minPermission uint64) (uint64, error)

CheckUserPermission ..

func (*Team) FetchEmployees

func (t *Team) FetchEmployees(db *gorm.DB)

FetchEmployees ..

func (*Team) FetchEmployeesID

func (t *Team) FetchEmployeesID(db *gorm.DB)

FetchEmployeesID ..

func (*Team) FetchRepositories

func (t *Team) FetchRepositories(db *gorm.DB)

FetchRepositories ..

func (*Team) FetchRepositoriesID

func (t *Team) FetchRepositoriesID(db *gorm.DB)

FetchRepositoriesID ..

type TeamRepository

type TeamRepository struct {
	TeamID       uint64 `gorm:"primary_key;auto_increment:false"`
	RepositoryID uint64 `gorm:"primary_key;auto_increment:false"`
}

TeamRepository ..

type User

type User struct {
	Common    `json:"common,omitempty"`
	Login     string `gorm:"UNIQUE_INDEX" json:"login,omitempty"` // 登录名
	AvatarURL string `json:"avatar_url,omitempty"`                // 头像地址
	Name      string `json:"name,omitempty"`                      // 昵称
	Blog      string `json:"blog,omitempty"`                      // 网站链接
	Email     string `json:"email,omitempty"`                     // 邮箱
	Hireable  bool   `json:"hireable,omitempty"`
	Bio       string `json:"bio,omitempty"` // 个人简介

	Token        string    `gorm:"UNIQUE_INDEX" json:"-"`   // 认证 Token
	TokenExpired time.Time `json:"token_expired,omitempty"` // Token 过期时间
	SuperAdmin   bool      `json:"super_admin,omitempty"`   // 超级管理员

	TeamsID []uint64 `gorm:"-"`
}

User ...

func NewUserFromGitHub

func NewUserFromGitHub(gu *github.User) User

NewUserFromGitHub ..

func (*User) FetchTeams

func (u *User) FetchTeams(db *gorm.DB)

FetchTeams ..

func (*User) InTeams

func (u *User) InTeams(db *gorm.DB, teamIDs []uint64, perm uint64) (bool, error)

InTeams ...

func (*User) IssueNewToken

func (u *User) IssueNewToken()

IssueNewToken ...

type UserCompany

type UserCompany struct {
	UserID     uint64 `gorm:"primary_key;auto_increment:false"`
	CompanyID  uint64 `gorm:"primary_key;auto_increment:false"`
	Permission uint64
}

UserCompany ..

type UserRepository

type UserRepository struct {
	UserID       uint64 `gorm:"primary_key;auto_increment:false"`
	RepositoryID uint64 `gorm:"primary_key;auto_increment:false"`
	InvitationID int64
}

UserRepository ..

type UserTeam

type UserTeam struct {
	UserID     uint64 `gorm:"primary_key;auto_increment:false"`
	TeamID     uint64 `gorm:"primary_key;auto_increment:false"`
	Permission uint64
	UpdatedAt  time.Time
}

UserTeam ..

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL