dao

package
v0.0.0-...-ff5c026 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccTableName           = "accounts"
	RolesTableName         = "roles"
	OrgTableName           = "orgs"
	ProjectTableName       = "projects"
	DefaultLimit           = 50
	DefaultCursor          = `created_at`
	LoginAttemptsTableName = `login_attempts`
)

const.go contains all the table columns / fields basically.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID                string `json:"id,omitempty" genji:"id" coredb:"primary"`
	Email             string `json:"email,omitempty" genji:"email"`
	Password          string `json:"password,omitempty" genji:"password"`
	CreatedAt         int64  `json:"created_at" genji:"created_at"`
	UpdatedAt         int64  `json:"updated_at" genji:"updated_at"`
	LastLogin         int64  `json:"last_login" genji:"last_login"`
	Disabled          bool   `json:"disabled" genji:"disabled"`
	Verified          bool   `json:"verified" genji:"verified"`
	VerificationToken string `json:"verification_token,omitempty" genji:"verification_token"`
	AvatarResourceId  string `json:"avatar_resource_id,omitempty" genji:"avatar_resource_id"`
}

func (Account) CreateSQL

func (a Account) CreateSQL() []string

CreateSQL will only be called once by sys-core see sys-core API.

func (*Account) ToRpcAccount

func (a *Account) ToRpcAccount(roles []*accountRpc.UserRoles, avatar []byte) (*accountRpc.Account, error)

type AccountDB

type AccountDB struct {
	// contains filtered or unexported fields
}

func NewAccountDB

func NewAccountDB(db *coresvc.CoreDB, l logging.Logger) (*AccountDB, error)

func (*AccountDB) BuildSearchQuery

func (a *AccountDB) BuildSearchQuery(qs string) string

func (*AccountDB) DeleteAccount

func (a *AccountDB) DeleteAccount(id string) error

func (*AccountDB) DeleteOrg

func (a *AccountDB) DeleteOrg(id string) error

func (*AccountDB) DeleteProject

func (a *AccountDB) DeleteProject(id string) error

func (*AccountDB) DeleteRole

func (a *AccountDB) DeleteRole(id string) error

func (*AccountDB) FetchRoles

func (a *AccountDB) FetchRoles(accountId string) ([]*Role, error)

func (*AccountDB) FromPkgNewRoleRequest

func (a *AccountDB) FromPkgNewRoleRequest(role *rpc.NewUserRoles, accountId string) *Role

func (*AccountDB) FromPkgRoleRequest

func (a *AccountDB) FromPkgRoleRequest(role *rpc.UserRoles, accountId string) *Role

func (*AccountDB) FromRpcAccount

func (a *AccountDB) FromRpcAccount(account *accountRpc.Account) (*Account, error)

func (*AccountDB) FromRpcOrgRequestToQueryFilter

func (a *AccountDB) FromRpcOrgRequestToQueryFilter(org *rpc.OrgRequest) (*coresvc.QueryParams, error)

func (*AccountDB) FromRpcProject

func (a *AccountDB) FromRpcProject(p *rpc.ProjectRequest) (*Project, error)

func (*AccountDB) FromrpcOrgRequest

func (a *AccountDB) FromrpcOrgRequest(org *rpc.OrgRequest, id string) (*Org, error)

func (*AccountDB) GetAccount

func (a *AccountDB) GetAccount(filterParams *coresvc.QueryParams) (*Account, error)

func (*AccountDB) GetLoginAttempt

func (a *AccountDB) GetLoginAttempt(originIp string) (*LoginAttempt, error)

func (*AccountDB) GetOrg

func (a *AccountDB) GetOrg(filterParam *coresvc.QueryParams) (*Org, error)

func (*AccountDB) GetProject

func (a *AccountDB) GetProject(filterParam *coresvc.QueryParams) (*Project, error)

func (*AccountDB) GetRole

func (a *AccountDB) GetRole(filterParam *coresvc.QueryParams) (*Role, error)

func (*AccountDB) InsertAccount

func (a *AccountDB) InsertAccount(acc *Account) error

func (*AccountDB) InsertFromRpcAccountRequest

func (a *AccountDB) InsertFromRpcAccountRequest(account *accountRpc.AccountNewRequest, verified bool) (*Account, error)

func (*AccountDB) InsertOrg

func (a *AccountDB) InsertOrg(o *Org) error

func (*AccountDB) InsertProject

func (a *AccountDB) InsertProject(p *Project) error

func (*AccountDB) InsertRole

func (a *AccountDB) InsertRole(p *Role) error

func (*AccountDB) ListAccount

func (a *AccountDB) ListAccount(filterParams *coresvc.QueryParams, orderBy string, limit, cursor int64, sqlMatcher string) ([]*Account, int64, error)

func (*AccountDB) ListNonSubbed

func (a *AccountDB) ListNonSubbed(accountId string, filterParams *coresvc.QueryParams, orderBy string, limit, cursor int64) ([]*Org, int64, error)

func (*AccountDB) ListOrg

func (a *AccountDB) ListOrg(filterParam *coresvc.QueryParams, orderBy string, limit, cursor int64, sqlMatcher string) ([]*Org, int64, error)

func (*AccountDB) ListProject

func (a *AccountDB) ListProject(filterParam *coresvc.QueryParams, orderBy string, limit, cursor int64, sqlMatcher string) ([]*Project, int64, error)

func (*AccountDB) ListRole

func (a *AccountDB) ListRole(filterParam *coresvc.QueryParams) ([]*Role, error)

func (*AccountDB) ResetAll

func (a *AccountDB) ResetAll() error

func (*AccountDB) UpdateAccount

func (a *AccountDB) UpdateAccount(acc *Account) error

func (*AccountDB) UpdateOrg

func (a *AccountDB) UpdateOrg(o *Org) error

func (*AccountDB) UpdateProject

func (a *AccountDB) UpdateProject(p *Project) error

func (*AccountDB) UpdateRole

func (a *AccountDB) UpdateRole(p *Role) error

func (*AccountDB) UpsertLoginAttempt

func (a *AccountDB) UpsertLoginAttempt(originIp string, accountEmail string, attempt uint, banPeriod int64) (*LoginAttempt, error)

type LoginAttempt

type LoginAttempt struct {
	OriginIP      string `json:"origin_ip" genji:"origin_ip" coredb:"primary"`
	AccountEmail  string `json:"account_email,omitempty" genji:"account_email"`
	TotalAttempts uint   `json:"total_attempts" genji:"total_attempts"`
	BanPeriod     int64  `json:"ban_period" genji:"ban_period"`
}

func (LoginAttempt) CreateSQL

func (l LoginAttempt) CreateSQL() []string

CreateSQL will only be called once by sys-core see sys-core API.

type Org

type Org struct {
	Id             string `genji:"id" json:"id,omitempty" coredb:"primary"`
	Name           string `genji:"name" json:"name,omitempty"`
	LogoResourceId string `genji:"logo_resource_id" json:"logo_resource_id,omitempty"`
	Contact        string `genji:"contact" json:"contact,omitempty"`
	CreatedAt      int64  `genji:"created_at" json:"created_at"`
	AccountId      string `genji:"account_id" json:"account_id"`
}

func (Org) CreateSQL

func (o Org) CreateSQL() []string

func (*Org) ToRpcOrg

func (o *Org) ToRpcOrg(projects []*rpc.Project, logo []byte) (*rpc.Org, error)

type Project

type Project struct {
	Id             string `json:"id" genji:"id" coredb:"primary"`
	Name           string `json:"name,omitempty" genji:"name"`
	LogoResourceId string `json:"logo_resource_id" genji:"logo_resource_id"`
	CreatedAt      int64  `json:"created_at" genji:"created_at"`
	AccountId      string `json:"account_id" genji:"account_id"`
	OrgId          string `json:"org_id" genji:"org_id"`
	OrgName        string `json:"org_name" genji:"org_name"`
}

func (Project) CreateSQL

func (p Project) CreateSQL() []string

func (*Project) ToRpcProject

func (p *Project) ToRpcProject(org *rpc.Org, logo []byte) (*rpc.Project, error)

type Role

type Role struct {
	ID        string `genji:"id" coredb:"primary"`
	AccountId string `genji:"account_id"`
	Role      int    `genji:"role"`
	ProjectId string `genji:"project_id"`
	OrgId     string `genji:"org_id"`
	CreatedAt int64  `genji:"created_at"`
	UpdatedAt int64  `genji:"updated_at"`
}

func (Role) CreateSQL

func (p Role) CreateSQL() []string

CreateSQL will only be called once by sys-core see sys-core API.

func (*Role) ToPkgRole

func (p *Role) ToPkgRole() (*rpc.UserRoles, error)

Jump to

Keyboard shortcuts

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