model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EMAIL_DELIVER_BASEURL                = "https://email.illasoft.com/v1/"
	EMAIL_DELIVER_USAGE_SUBSCRIBE        = "subscribe"
	EMAIL_DELIVER_USAGE_VERIFICATIONCODE = "code"
	EMAIL_DELIVER_INVITE_EMAIL           = "invite"
	EMAIL_DELIVER_SHARE_APP_EMAIL        = "shareApp"
)
View Source
const (
	ILLA_UNIT_APPS                      = 1
	ILLA_UNIT_RESOURCES                 = 2
	ILLA_UNIT_ACTIONS                   = 3
	ILLA_UNIT_TREE_STATES               = 4
	ILLA_UNIT_KV_STATES                 = 5
	ILLA_UNIT_SET_STATES                = 6
	ILLA_UNIT_USERS                     = 7
	ILLA_UNIT_TEAMS                     = 8
	ILLA_UNIT_TEAM_MEMBERS              = 9
	ILLA_UNIT_INVITES                   = 10
	ILLA_UNIT_PROMOTE_CODES             = 11
	ILLA_UNIT_PROMOTE_CODE_USAGES       = 12
	ILLA_UNIT_ROLES                     = 13
	ILLA_UNIT_USER_ROLE_RELATIONS       = 14
	ILLA_UNIT_UNIT_ROLE_RELATIONS       = 15
	ILLA_UNIT_COMPENSATING_TRANSACTIONS = 16
	ILLA_UNIT_TRANSACTION_SERIALS       = 17
	ILLA_UNIT_CAPACITIES                = 18
	ILLA_UNIT_DRIVE                     = 19
	ILLA_UNIT_APP_SNAPSHOT              = 20
)
View Source
const (
	USER_JWT_TOKEN_KEY_TEMPLATE         = "%d_jwt_expired_at"
	EMAIL_JWT_TOKEN_KEY_PREFIX          = "email_%s"
	DEFAULT_EMAIL_REGISTER_TOKEN_EXPIRE = 15 * time.Minute
)
View Source
const (
	USER_ROLE_ANONYMOUS = -1
	USER_ROLE_OWNER     = 1
	USER_ROLE_ADMIN     = 2
	USER_ROLE_EDITOR    = 3
	USER_ROLE_VIEWER    = 4
)

User Role ID in Team @note: this will extend as role system later.

View Source
const CUSTOMIZATION_LANGUAGE_CS_CZ = "cs-CZ"
View Source
const CUSTOMIZATION_LANGUAGE_DA_DK = "da-DK"
View Source
const CUSTOMIZATION_LANGUAGE_DE_DE = "de-DE"
View Source
const CUSTOMIZATION_LANGUAGE_EL_GR = "el-GR"
View Source
const CUSTOMIZATION_LANGUAGE_EN_US = "en-US"
View Source
const CUSTOMIZATION_LANGUAGE_ES_ES = "es-ES"
View Source
const CUSTOMIZATION_LANGUAGE_FI_FI = "fi-FI"
View Source
const CUSTOMIZATION_LANGUAGE_FR_FR = "fr-FR"
View Source
const CUSTOMIZATION_LANGUAGE_IT_IT = "it-IT"
View Source
const CUSTOMIZATION_LANGUAGE_JA_JP = "ja-JP"
View Source
const CUSTOMIZATION_LANGUAGE_KO_KR = "ko-KR"
View Source
const CUSTOMIZATION_LANGUAGE_NL_NL = "nl-NL"
View Source
const CUSTOMIZATION_LANGUAGE_NO_NO = "no-NO"
View Source
const CUSTOMIZATION_LANGUAGE_PL_PL = "pl-PL"
View Source
const CUSTOMIZATION_LANGUAGE_PT_PT = "pt-PT"
View Source
const CUSTOMIZATION_LANGUAGE_RO_RO = "ro-RO"
View Source
const CUSTOMIZATION_LANGUAGE_RU_RU = "ru-RU"
View Source
const CUSTOMIZATION_LANGUAGE_SV_SE = "sv-SE"
View Source
const CUSTOMIZATION_LANGUAGE_UK_UA = "uk-UA"
View Source
const CUSTOMIZATION_LANGUAGE_ZH_CN = "zh-CN"
View Source
const PENDING_USER_AVATAR = ""
View Source
const PENDING_USER_ID = 0
View Source
const PENDING_USER_NICKNAME = "pending"
View Source
const PENDING_USER_PASSWORDDIGEST = "pending"
View Source
const TEAM_DEFAULT_ID = 0
View Source
const TEAM_FIELD_ICON = "icon"
View Source
const TEAM_FIELD_IDENTIFIER = "identifier"
View Source
const TEAM_FIELD_NAME = "name"
View Source
const TEAM_FOLDER_PREFIX = "team-"
View Source
const TEAM_ICON_FOLDER = "/icon"
View Source
const TEAM_MEMBER_STATUS_OK = 1
View Source
const TEAM_MEMBER_STATUS_PENDING = 2
View Source
const TEAM_P_FIELD_ALLOW_EDITOR_INVITE = "allowEditorInvite"
View Source
const TEAM_P_FIELD_ALLOW_EDITOR_MANAGE_TEAM_MEMBER = "allowEditorManageTeamMember"
View Source
const TEAM_P_FIELD_ALLOW_VIEWER_INVITE = "allowViewerInvite"
View Source
const TEAM_P_FIELD_ALLOW_VIEWER_MANAGE_TEAM_MEMBER = "allowViewerManageTeamMember"
View Source
const TEAM_P_FIELD_BLOCK_REGISTER = "blockRegister"
View Source
const TEAM_P_FIELD_INVITE_LINK_ENABLED = "inviteLinkEnabled"
View Source
const TEAM_SPACE_FOLDER = "/team"
View Source
const TEAM_SYSTEM_FOLDER = "/system"
View Source
const USER_AVATAR_FOLVER = "/avatar"
View Source
const USER_FOLDER_PREFIX = "user-"

Variables

This section is empty.

Functions

func BuildLookUpTableForUserExport

func BuildLookUpTableForUserExport(users []*User) map[int]*UserForExport

func BuildTeamIDLookUpTableForTeamMemberExport

func BuildTeamIDLookUpTableForTeamMemberExport(teamMembers []*TeamMember) map[int]*TeamMemberForExport

func CreateAccessToken

func CreateAccessToken(id int, uid uuid.UUID) (string, error)

func ExtractUserIDFromToken

func ExtractUserIDFromToken(accessToken string) (int, uuid.UUID, error)

func GenerateAndSendVerificationCode

func GenerateAndSendVerificationCode(email, usage string) (string, error)

func PickUpTeamIDsInTeamMembers

func PickUpTeamIDsInTeamMembers(teamMembers []*TeamMember) []int

func PickUpTeamMemberIDsInTeamMembers

func PickUpTeamMemberIDsInTeamMembers(teamMembers []*TeamMember) []int

func PickUpUserIDsInUserMembers

func PickUpUserIDsInUserMembers(teamMembers []*TeamMember) []int

func SendSubscriptionEmail

func SendSubscriptionEmail(email string) error

func SendVerificationEmail

func SendVerificationEmail(email, code, usage string) error

func ValidateAccessToken

func ValidateAccessToken(accessToken string) (bool, error)

func ValidateVerificationCode

func ValidateVerificationCode(vCode, codeToken, email, usage string) (bool, error)

Types

type AuthClaims

type AuthClaims struct {
	User   int       `json:"user"`
	UID    uuid.UUID `json:"uuid"`
	Random string    `json:"rnd"`
	jwt.RegisteredClaims
}

type Cache added in v0.0.8

type Cache struct {
	JWTCache *JWTCache
}

func NewCache added in v0.0.8

func NewCache(redisDriver *redis.Client, logger *zap.SugaredLogger) *Cache

type ChangePasswordRequest

type ChangePasswordRequest struct {
	CurrentPassword string `json:"currentPassword" validate:"required"`
	NewPassword     string `json:"newPassword" validate:"required"`
}

func NewChangePasswordRequest

func NewChangePasswordRequest() *ChangePasswordRequest

type Drive

type Drive struct {
	SystemDriveS3Instance S3Instance
	TeamDriveS3Instance   S3Instance
	// contains filtered or unexported fields
}

func NewDrive

func NewDrive(systemDriveS3Instance S3Instance, teamDriveS3Instance S3Instance, logger *zap.SugaredLogger) *Drive

type ForgetPasswordRequest

type ForgetPasswordRequest struct {
	Email             string `json:"email" validate:"required"`
	NewPassword       string `json:"newPassword" validate:"required"`
	VerificationCode  string `json:"verificationCode" validate:"required"`
	VerificationToken string `json:"verificationToken"`
}

func NewForgetPasswordRequest

func NewForgetPasswordRequest() *ForgetPasswordRequest

type GetAllTeamMembersResponse

type GetAllTeamMembersResponse struct {
	AllTeamMembers []*TeamMemberWithUserInfoForExportConverted
}

func (*GetAllTeamMembersResponse) ExportForFeedback

func (resp *GetAllTeamMembersResponse) ExportForFeedback() interface{}

type GetMyTeamsResponse

type GetMyTeamsResponse struct {
	MyTeams []*MyTeamResponse
}

func NewGetMyTeamsResponse

func NewGetMyTeamsResponse(teams []*Team, teamMembersLT map[int]*TeamMemberForExport) *GetMyTeamsResponse

func (*GetMyTeamsResponse) ExportForFeedback

func (resp *GetMyTeamsResponse) ExportForFeedback() interface{}

type GetTargetTeamByInternalRequestResponse

type GetTargetTeamByInternalRequestResponse struct {
	ID         string    `json:"id"`
	UID        uuid.UUID `json:"uid"`
	Name       string    `json:"name"`
	Identifier string    `json:"identifier"`
	Icon       string    `json:"icon"`
	Permission string    `json:"permission"` // for team permission config
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

func NewGetTargetTeamByInternalRequestResponse

func NewGetTargetTeamByInternalRequestResponse(team *Team) *GetTargetTeamByInternalRequestResponse

func (*GetTargetTeamByInternalRequestResponse) ExportForFeedback

func (resp *GetTargetTeamByInternalRequestResponse) ExportForFeedback() interface{}

type GetTargetUserByInternalRequestResponse

type GetTargetUserByInternalRequestResponse struct {
	ID           string    `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID string    `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func NewGetTargetUserByInternalRequestResponse

func NewGetTargetUserByInternalRequestResponse(user *User) *GetTargetUserByInternalRequestResponse

func (*GetTargetUserByInternalRequestResponse) ExportForFeedback

func (resp *GetTargetUserByInternalRequestResponse) ExportForFeedback() interface{}

func (*GetTargetUserByInternalRequestResponse) SetTeamMemberID

func (resp *GetTargetUserByInternalRequestResponse) SetTeamMemberID(id int)

type GetTargetUsersByInternalRequestResponse added in v0.0.12

type GetTargetUsersByInternalRequestResponse struct {
	Users map[string]*GetTargetUserByInternalRequestResponse `json:"users"`
}

func NewGetTargetUsersByInternalRequestResponse added in v0.0.12

func NewGetTargetUsersByInternalRequestResponse(users []*User) *GetTargetUsersByInternalRequestResponse

func (*GetTargetUsersByInternalRequestResponse) ExportForFeedback added in v0.0.12

func (resp *GetTargetUsersByInternalRequestResponse) ExportForFeedback() interface{}

type GetTeamByTeamIDResponse

type GetTeamByTeamIDResponse struct {
	ID         string          `json:"id"`
	UID        uuid.UUID       `json:"uid"`
	Name       string          `json:"name"`
	Identifier string          `json:"identifier"`
	Icon       string          `json:"icon"`
	Permission *TeamPermission `json:"permission"`
	CreatedAt  time.Time       `json:"createdAt"`
	UpdatedAt  time.Time       `json:"updatedAt"`
}

func NewGetTeamByTeamIDResponse

func NewGetTeamByTeamIDResponse(t *Team) *GetTeamByTeamIDResponse

func (*GetTeamByTeamIDResponse) ExportForFeedback

func (resp *GetTeamByTeamIDResponse) ExportForFeedback() interface{}

type GetTeamMemberResponse

type GetTeamMemberResponse struct {
	ID           string                `json:"userID"`
	UID          uuid.UUID             `json:"uid"`
	TeamMemberID string                `json:"teamMemberID"`
	Nickname     string                `json:"nickname"`
	Email        string                `json:"email"`
	Avatar       string                `json:"avatar"`
	Language     string                `json:"language"`
	IsSubscribed bool                  `json:"isSubscribed"`
	UserRole     int                   `json:"userRole"`
	Permission   *TeamMemberPermission `json:"permission"` // for user permission config
	UserStatus   int                   `json:"userStatus"`
	CreatedAt    time.Time             `json:"createdAt"`
	UpdatedAt    time.Time             `json:"updatedAt"`
}

func (*GetTeamMemberResponse) ExportForFeedback

func (resp *GetTeamMemberResponse) ExportForFeedback() interface{}

type GetTeamPermissionResponse

type GetTeamPermissionResponse struct {
	AllowEditorInvite           bool `json:"allowEditorInvite"`
	AllowViewerInvite           bool `json:"allowViewerInvite"`
	AllowEditorManageTeamMember bool `json:"allowEditorManageTeamMember"`
	AllowViewerManageTeamMember bool `json:"allowViewerManageTeamMember"`
	InviteLinkEnabled           bool `json:"inviteLinkEnabled"`
}

func NewGetTeamPermissionResponse

func NewGetTeamPermissionResponse(team *Team) *GetTeamPermissionResponse

func (*GetTeamPermissionResponse) ExportForFeedback

func (resp *GetTeamPermissionResponse) ExportForFeedback() interface{}

type GetUserByIDResponse

type GetUserByIDResponse struct {
	ID               string    `json:"userID"`
	UID              uuid.UUID `json:"uid"`
	Nickname         string    `json:"nickname"`
	Email            string    `json:"email"`
	Avatar           string    `json:"avatar"`
	Language         string    `json:"language"`
	IsTutorialViewed bool      `json:"isTutorialViewed"`
	CreatedAt        time.Time `json:"createdAt"`
	UpdatedAt        time.Time `json:"updatedAt"`
}

func NewGetUserByIDResponse

func NewGetUserByIDResponse(user *User) *GetUserByIDResponse

func (*GetUserByIDResponse) ExportForFeedback

func (resp *GetUserByIDResponse) ExportForFeedback() interface{}

type GetVerificationCodeResponse

type GetVerificationCodeResponse struct {
	VerificationToken string `json:"verificationToken"`
}

func NewGetVerificationCodeResponse

func NewGetVerificationCodeResponse(token string) *GetVerificationCodeResponse

func (*GetVerificationCodeResponse) ExportForFeedback

func (resp *GetVerificationCodeResponse) ExportForFeedback() interface{}

type JWTCache added in v0.0.8

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

func NewJWTCache added in v0.0.8

func NewJWTCache(cache *redis.Client, logger *zap.SugaredLogger) *JWTCache

func (*JWTCache) CleanUserJWTTokenExpiredAt added in v0.0.8

func (c *JWTCache) CleanUserJWTTokenExpiredAt(user *User) error

func (*JWTCache) DoesUserJWTTokenAvaliable added in v0.0.8

func (c *JWTCache) DoesUserJWTTokenAvaliable(user *User, jwtTokenExpireAt string) (bool, error)

func (*JWTCache) GetTokenByEmail added in v1.0.0

func (c *JWTCache) GetTokenByEmail(email string) (string, error)

func (*JWTCache) InitUserJWTTokenExpiredAt added in v0.0.8

func (c *JWTCache) InitUserJWTTokenExpiredAt(user *User, jwtTokenExpireAt string) error

func (*JWTCache) SetTokenForEmail added in v1.0.0

func (c *JWTCache) SetTokenForEmail(email string, jwtToken string) error

type MyTeamResponse added in v0.0.5

type MyTeamResponse struct {
	ID                   string                `json:"id"`
	UID                  uuid.UUID             `json:"uid"`
	Name                 string                `json:"name"`
	Identifier           string                `json:"identifier"`
	Icon                 string                `json:"icon"`
	MyRole               int                   `json:"myRole"`
	TeamMemberID         string                `json:"teamMemberID"`
	TeamMemberPermission *TeamMemberPermission `json:"teamMemberPermission"`
	TeamPermission       *TeamPermission       `json:"permission"`
	JoinedAt             time.Time             `json:"-"`
}

func NewMyTeamResponse added in v0.0.5

func NewMyTeamResponse(team *Team, targetTeamMember *TeamMember) *MyTeamResponse

func (*MyTeamResponse) ExportForFeedback added in v0.0.5

func (resp *MyTeamResponse) ExportForFeedback() interface{}

type Response

type Response interface {
	ExportForFeedback() interface{}
}

type S3Instance

type S3Instance interface {
	GetPreSignedPutURL(fileName string) (string, error)
}

type SignInRequest

type SignInRequest struct {
	Email    string `json:"email" validate:"required"`
	Password string `json:"password" validate:"required"`
}

func NewSignInRequest

func NewSignInRequest() *SignInRequest

type SignInResponse added in v1.0.0

type SignInResponse struct {
	ID           string    `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID string    `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func NewSignInResponse added in v1.0.0

func NewSignInResponse(u *User) *SignInResponse

func (*SignInResponse) ExportForFeedback added in v1.0.0

func (resp *SignInResponse) ExportForFeedback() interface{}

type Storage

type Storage struct {
	UserStorage       *UserStorage
	TeamStorage       *TeamStorage
	TeamMemberStorage *TeamMemberStorage
}

func NewStorage

func NewStorage(postgresDriver *gorm.DB, logger *zap.SugaredLogger) *Storage

type SystemDrive

type SystemDrive struct {
	Drive      S3Instance `json:"-"`
	UserFolder string     `json:"userFolder"`
}

func NewSystemDrive

func NewSystemDrive(drive *Drive) *SystemDrive

func (*SystemDrive) GetUserAvatarUploadPreSignedURL

func (d *SystemDrive) GetUserAvatarUploadPreSignedURL(fileName string) (string, error)

func (*SystemDrive) SetUser

func (d *SystemDrive) SetUser(user *User)

type Team

type Team struct {
	ID         int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:teams_ukey"`
	UID        uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:teams_ukey"`
	Name       string    `json:"name" gorm:"column:name;type:varchar;size:255;not null"`
	Identifier string    `json:"identifier" gorm:"column:identifier;type:varchar;size:255;not null"`
	Icon       string    `json:"icon" gorm:"column:icon;type:varchar;size:255;not null"`
	Permission string    `json:"permission" gorm:"column:permission;type:jsonb"` // for team permission config
	CreatedAt  time.Time `gorm:"column:created_at;type:timestamp"`
	UpdatedAt  time.Time `gorm:"column:updated_at;type:timestamp"`
}

func NewTeam

func NewTeam() *Team

func (*Team) ConstructByJSON

func (u *Team) ConstructByJSON(TeamJSON []byte) error

func (*Team) DoesEditorOrViewerCanInviteMember

func (u *Team) DoesEditorOrViewerCanInviteMember() bool

func (*Team) Export

func (t *Team) Export() *TeamForExport

func (*Team) ExportID

func (u *Team) ExportID() int

func (*Team) ExportTeamPermission

func (u *Team) ExportTeamPermission() *TeamPermission

func (*Team) GetIdentifier

func (u *Team) GetIdentifier() string

func (*Team) GetUID

func (u *Team) GetUID() uuid.UUID

func (*Team) GetUIDInString

func (u *Team) GetUIDInString() string

func (*Team) InitCreatedAt

func (u *Team) InitCreatedAt()

func (*Team) InitUID

func (u *Team) InitUID()

func (*Team) InitUpdatedAt

func (u *Team) InitUpdatedAt()

func (*Team) SetTeamPermission

func (u *Team) SetTeamPermission(tp *TeamPermission)

func (*Team) UpdateByUpdateTeamConfigRawRequest

func (u *Team) UpdateByUpdateTeamConfigRawRequest(rawReq map[string]interface{}) error

func (*Team) UpdateByUpdateTeamPermissionRawRequest

func (u *Team) UpdateByUpdateTeamPermissionRawRequest(rawReq map[string]interface{}) error

type TeamDrive

type TeamDrive struct {
	UID              uuid.UUID  `json:"uid"`
	Drive            S3Instance `json:"-"`
	TeamSystemFolder string     `json:"teamsystemfolder"`
	TeamSpaceFolder  string     `json:"teamspacefolder"`
}

func NewTeamDrive

func NewTeamDrive(drive *Drive) *TeamDrive

func (*TeamDrive) GetIconUploadPreSignedURL

func (d *TeamDrive) GetIconUploadPreSignedURL(fileName string) (string, error)

func (*TeamDrive) SetTeam

func (d *TeamDrive) SetTeam(team *Team)

type TeamForExport

type TeamForExport struct {
	ID         int             `json:"id"`
	UID        uuid.UUID       `json:"uid"`
	Name       string          `json:"name"`
	Identifier string          `json:"identifier"`
	Icon       string          `json:"icon"`
	Permission *TeamPermission `json:"permission"`
	CreatedAt  time.Time       `json:"createdAt"`
	UpdatedAt  time.Time       `json:"updatedAt"`
}

type TeamIconUploadAddressResponse

type TeamIconUploadAddressResponse struct {
	UploadAddress string `json:"uploadAddress"`
}

func NewTeamIconUploadAddressResponse

func NewTeamIconUploadAddressResponse(presignedURL string) *TeamIconUploadAddressResponse

func (*TeamIconUploadAddressResponse) ExportForFeedback

func (resp *TeamIconUploadAddressResponse) ExportForFeedback() interface{}

type TeamMember

type TeamMember struct {
	ID         int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:team_members_ukey"`
	TeamID     int       `json:"team_id" gorm:"column:team_id;type:bigserial;index:team_members_team_and_user_id"`
	UserID     int       `json:"user_id" gorm:"column:user_id;type:bigserial;index:team_members_team_and_user_id"`
	UserRole   int       `json:"user_role" gorm:"column:user_role;type:smallint"`
	Permission string    `json:"permission" gorm:"column:permission;type:jsonb"` // for user permission config
	Status     int       `json:"status" gorm:"column:status;type:smallint"`
	CreatedAt  time.Time `gorm:"column:created_at;type:timestamp"`
	UpdatedAt  time.Time `gorm:"column:updated_at;type:timestamp"`
}

func NewTeamMember

func NewTeamMember() *TeamMember

func (*TeamMember) ActiveUser

func (u *TeamMember) ActiveUser()

func (*TeamMember) ConstructByJSON

func (u *TeamMember) ConstructByJSON(TeamMemberJSON []byte) error

func (*TeamMember) Export

func (u *TeamMember) Export() *TeamMemberForExport

func (*TeamMember) ExportID

func (u *TeamMember) ExportID() int

func (*TeamMember) ExportPermission

func (u *TeamMember) ExportPermission() *TeamMemberPermission

func (*TeamMember) ExportUserID

func (u *TeamMember) ExportUserID() int

func (*TeamMember) ExportUserRole

func (u *TeamMember) ExportUserRole() int

func (*TeamMember) ExportWithPendingUserInfo

func (u *TeamMember) ExportWithPendingUserInfo(userForExport *UserForExport) *TeamMemberWithUserInfoForExport

func (*TeamMember) ExportWithUserInfo

func (u *TeamMember) ExportWithUserInfo(userForExport *UserForExport) *TeamMemberWithUserInfoForExport

func (*TeamMember) InitCreatedAt

func (u *TeamMember) InitCreatedAt()

func (*TeamMember) InitUpdatedAt

func (u *TeamMember) InitUpdatedAt()

func (*TeamMember) IsAdmin

func (u *TeamMember) IsAdmin() bool

func (*TeamMember) IsEditor

func (u *TeamMember) IsEditor() bool

func (*TeamMember) IsOwner

func (u *TeamMember) IsOwner() bool

func (*TeamMember) IsStatusOK

func (u *TeamMember) IsStatusOK() bool

func (*TeamMember) IsStatusPending

func (u *TeamMember) IsStatusPending() bool

func (*TeamMember) IsViewer

func (u *TeamMember) IsViewer() bool

func (*TeamMember) SetID

func (u *TeamMember) SetID(id int)

func (*TeamMember) SetUserID

func (u *TeamMember) SetUserID(userID int)

func (*TeamMember) SetUserRole

func (u *TeamMember) SetUserRole(userRole int)

func (*TeamMember) UpdateByUpdateTeamMemberRoleRequest

func (u *TeamMember) UpdateByUpdateTeamMemberRoleRequest(req *UpdateTeamMemberRoleRequest)

func (*TeamMember) UpdateTeamMemberRole

func (u *TeamMember) UpdateTeamMemberRole(userRole int)

type TeamMemberForExport

type TeamMemberForExport struct {
	ID         int                   `json:"id"`
	TeamID     int                   `json:"teamID"`
	UserID     int                   `json:"userID"`
	UserRole   int                   `json:"userRole"`
	Permission *TeamMemberPermission `json:"permission"` // for user permission config
	Status     int                   `json:"status"`
	CreatedAt  time.Time             `json:"createdAt"`
	UpdatedAt  time.Time             `json:"updatedAt"`
}

type TeamMemberPermission

type TeamMemberPermission struct {
	Config int `json:"config"`
}

func NewTeamMemberPermission

func NewTeamMemberPermission() *TeamMemberPermission

func (*TeamMemberPermission) ExportForTeam

func (tmp *TeamMemberPermission) ExportForTeam() string

type TeamMemberStorage

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

func NewTeamMemberStorage

func NewTeamMemberStorage(db *gorm.DB, logger *zap.SugaredLogger) *TeamMemberStorage

func (*TeamMemberStorage) Create

func (d *TeamMemberStorage) Create(u *TeamMember) (int, error)

func (*TeamMemberStorage) DeleteByID

func (d *TeamMemberStorage) DeleteByID(id int) error

func (*TeamMemberStorage) DeleteByIDAndTeamID

func (d *TeamMemberStorage) DeleteByIDAndTeamID(id int, teamID int) error

func (*TeamMemberStorage) DeleteByTeamID

func (d *TeamMemberStorage) DeleteByTeamID(teamID int) error

func (*TeamMemberStorage) DeleteByTeamIDAndUserID

func (d *TeamMemberStorage) DeleteByTeamIDAndUserID(teamID int, userID int) error

func (*TeamMemberStorage) DeleteByUID

func (d *TeamMemberStorage) DeleteByUID(uid string) error

func (*TeamMemberStorage) DeleteByUserID

func (d *TeamMemberStorage) DeleteByUserID(userID int) error

func (*TeamMemberStorage) DoesTeamIncludedTargetUser

func (d *TeamMemberStorage) DoesTeamIncludedTargetUser(teamID int, userID int) (bool, error)

func (*TeamMemberStorage) IsNowUserIsTeamOwner

func (d *TeamMemberStorage) IsNowUserIsTeamOwner(userID int) (bool, error)

func (*TeamMemberStorage) RetrieveByID

func (d *TeamMemberStorage) RetrieveByID(id int) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByTeamID

func (d *TeamMemberStorage) RetrieveByTeamID(team_id int) ([]*TeamMember, error)

func (*TeamMemberStorage) RetrieveByTeamIDAndID

func (d *TeamMemberStorage) RetrieveByTeamIDAndID(team_id int, id int) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByTeamIDAndUserID

func (d *TeamMemberStorage) RetrieveByTeamIDAndUserID(teamID int, userID int) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByUID

func (d *TeamMemberStorage) RetrieveByUID(uid string) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByUserID

func (d *TeamMemberStorage) RetrieveByUserID(user_id int) ([]*TeamMember, error)

func (*TeamMemberStorage) RetrieveTeamMemberByTeamIDAndID

func (d *TeamMemberStorage) RetrieveTeamMemberByTeamIDAndID(teamID int, id int) (*TeamMember, error)

func (*TeamMemberStorage) Update

func (d *TeamMemberStorage) Update(u *TeamMember) error

type TeamMemberWithUserInfoForExport

type TeamMemberWithUserInfoForExport struct {
	ID           int                   `json:"userID"`
	UID          uuid.UUID             `json:"uid"`
	TeamMemberID int                   `json:"teamMemberID"`
	Nickname     string                `json:"nickname"`
	Email        string                `json:"email"`
	Avatar       string                `json:"avatar"`
	Language     string                `json:"language"`
	IsSubscribed bool                  `json:"isSubscribed"`
	UserRole     int                   `json:"userRole"`
	Permission   *TeamMemberPermission `json:"permission"` // for user permission config
	UserStatus   int                   `json:"userStatus"`
	CreatedAt    time.Time             `json:"createdAt"`
	UpdatedAt    time.Time             `json:"updatedAt"`
}

type TeamMemberWithUserInfoForExportConverted

type TeamMemberWithUserInfoForExportConverted struct {
	ID           string                `json:"userID"`
	UID          uuid.UUID             `json:"uid"`
	TeamMemberID string                `json:"teamMemberID"`
	Nickname     string                `json:"nickname"`
	Email        string                `json:"email"`
	Avatar       string                `json:"avatar"`
	Language     string                `json:"language"`
	IsSubscribed bool                  `json:"isSubscribed"`
	UserRole     int                   `json:"userRole"`
	Permission   *TeamMemberPermission `json:"permission"` // for user permission config
	UserStatus   int                   `json:"userStatus"`
	CreatedAt    time.Time             `json:"createdAt"`
	UpdatedAt    time.Time             `json:"updatedAt"`
}

type TeamPermission

type TeamPermission struct {
	AllowEditorInvite           bool `json:"allowEditorInvite"`
	AllowViewerInvite           bool `json:"allowViewerInvite"`
	AllowEditorManageTeamMember bool `json:"allowEditorManageTeamMember"`
	AllowViewerManageTeamMember bool `json:"allowViewerManageTeamMember"`
	InviteLinkEnabled           bool `json:"inviteLinkEnabled"`
	BlockRegister               bool `json:"blockRegister"`
}

func NewTeamPermission

func NewTeamPermission() *TeamPermission
func (tp *TeamPermission) DisableInviteLink()

func (*TeamPermission) DoesBlockRegister added in v0.0.15

func (tp *TeamPermission) DoesBlockRegister() bool

func (*TeamPermission) DoesEditorCanManageTeamMember

func (tp *TeamPermission) DoesEditorCanManageTeamMember() bool

func (*TeamPermission) DoesInviteLinkEnabled

func (tp *TeamPermission) DoesInviteLinkEnabled() bool

func (*TeamPermission) DoesViewerCanManageTeamMember

func (tp *TeamPermission) DoesViewerCanManageTeamMember() bool
func (tp *TeamPermission) EnableInviteLink()

func (*TeamPermission) ExportForTeam

func (tp *TeamPermission) ExportForTeam() string

func (*TeamPermission) ImportFromTeam

func (tp *TeamPermission) ImportFromTeam(team *Team)

type TeamStorage

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

func NewTeamStorage

func NewTeamStorage(db *gorm.DB, logger *zap.SugaredLogger) *TeamStorage

func (*TeamStorage) Create

func (d *TeamStorage) Create(u *Team) (int, error)

func (*TeamStorage) DeleteByID

func (d *TeamStorage) DeleteByID(id int) error

func (*TeamStorage) DeleteByUID

func (d *TeamStorage) DeleteByUID(uid string) error

func (*TeamStorage) IsIdentifierExists

func (d *TeamStorage) IsIdentifierExists(identifier string) bool

func (*TeamStorage) RetrieveByID

func (d *TeamStorage) RetrieveByID(id int) (*Team, error)

func (*TeamStorage) RetrieveByIDs

func (d *TeamStorage) RetrieveByIDs(ids []int) ([]*Team, error)

func (*TeamStorage) RetrieveByIdentifier

func (d *TeamStorage) RetrieveByIdentifier(identifier string) (*Team, error)

func (*TeamStorage) RetrieveByUID

func (d *TeamStorage) RetrieveByUID(uid string) (*Team, error)

func (*TeamStorage) UpdateByID

func (d *TeamStorage) UpdateByID(u *Team) error

type TeamsForExport

type TeamsForExport []*TeamForExport

func NewTeamsForExport

func NewTeamsForExport(teams []*Team) (r TeamsForExport)

type UpdateAvatarRequest

type UpdateAvatarRequest struct {
	Avatar string `json:"avatar" validate:"required"`
}

func NewUpdateAvatarRequest

func NewUpdateAvatarRequest() *UpdateAvatarRequest

type UpdateDomainRequest

type UpdateDomainRequest struct {
	ID                 int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:domains_ukey"`
	UID                uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:domains_ukey"`
	TeamID             int       `json:"teamID" gorm:"column:team_id;type:bigserial;index:domains_team_id"`
	UserDomain         string    `json:"userDomain" gorm:"column:user_domain;type:varchar;size:255;not null"`
	SystemDomainPrefix string    `json:"systemDomain_prefix" gorm:"column:system_domain_prefix;type:varchar;size:255;not null"`
	ResolveStatus      int       `json:"resolveStatus" gorm:"column:resolve_status;type:smallint;"`
	Category           int       `json:"category" gorm:"column:category;type:smallint;"`
}

func NewUpdateDomainRequest

func NewUpdateDomainRequest() *UpdateDomainRequest

type UpdateIsTutorialViewedRequest added in v0.0.7

type UpdateIsTutorialViewedRequest struct {
	IsTutorialViewed bool `json:"isTutorialViewed" validate:"boolean"`
}

func NewUpdateIsTutorialViewedRequest added in v0.0.7

func NewUpdateIsTutorialViewedRequest() *UpdateIsTutorialViewedRequest

type UpdateLanguageRequest

type UpdateLanguageRequest struct {
	Language string `` /* 152-byte string literal not displayed */
}

func NewUpdateLanguageRequest

func NewUpdateLanguageRequest() *UpdateLanguageRequest

type UpdateNicknameRequest

type UpdateNicknameRequest struct {
	Nickname string `json:"nickname" validate:"required"`
}

func NewUpdateNicknameRequest

func NewUpdateNicknameRequest() *UpdateNicknameRequest

type UpdateTeamConfigRequest

type UpdateTeamConfigRequest struct {
	Name       string `json:"name" validate:"required"`
	Identifier string `json:"identifier" validate:"required"`
	Icon       string `json:"icon"`
}

func NewUpdateTeamConfigRequest

func NewUpdateTeamConfigRequest(rawReq map[string]interface{}) *UpdateTeamConfigRequest

type UpdateTeamMemberRequest

type UpdateTeamMemberRequest struct {
	ID         int    `json:"id" gorm:"column:id;type:bigserial;primary_key;index:team_members_ukey"`
	TeamID     int    `json:"teamID" gorm:"column:team_id;type:bigserial;index:team_members_team_and_user_id"`
	UserID     int    `json:"userID" gorm:"column:user_id;type:bigserial;index:team_members_team_and_user_id"`
	UserRole   int    `json:"userRole" gorm:"column:user_role;type:smallint"`
	Permission string `json:"permission" gorm:"column:authority;type:jsonb"` // for user permission config
}

func NewUpdateTeamMemberRequest

func NewUpdateTeamMemberRequest() *UpdateTeamMemberRequest

type UpdateTeamMemberRoleRequest

type UpdateTeamMemberRoleRequest struct {
	UserRole int `json:"userRole" validate:"required"`
}

func NewUpdateTeamMemberRoleRequest

func NewUpdateTeamMemberRoleRequest() *UpdateTeamMemberRoleRequest

func (*UpdateTeamMemberRoleRequest) ExportUserRole

func (u *UpdateTeamMemberRoleRequest) ExportUserRole() int

func (*UpdateTeamMemberRoleRequest) IsTransferOwner

func (u *UpdateTeamMemberRoleRequest) IsTransferOwner() bool

type UpdateTeamPermissionRequest

type UpdateTeamPermissionRequest struct {
	AllowEditorInvite           bool `json:"allowEditorInvite"`
	AllowViewerInvite           bool `json:"allowViewerInvite"`
	AllowEditorManageTeamMember bool `json:"allowEditorManageTeamMember"`
	AllowViewerManageTeamMember bool `json:"allowViewerManageTeamMember"`
}

func NewUpdateTeamPermissionRequest

func NewUpdateTeamPermissionRequest(rawReq map[string]interface{}) *UpdateTeamPermissionRequest

type UpdateUserRequest

type UpdateUserRequest struct {
	ID             string    `json:"id" gorm:"column:id;type:bigserial;primary_key;index:users_ukey"`
	UID            uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:users_ukey"`
	Nickname       string    `json:"nickname" gorm:"column:nickname;type:varchar;size:15;not null"`
	PasswordDigest string    `json:"passworddigest" gorm:"column:password_digest;type:varchar;size:60;not null"`
	Email          string    `json:"email" gorm:"column:email;type:varchar;size:255;not null"`
	Avatar         string    `json:"avatar" gorm:"column:avatar;type:varchar;size:255;not null"`
	SSOConfig      string    `json:"SSOConfig" gorm:"column:sso_config;type:jsonb"`        // for single sign-on data
	Customization  string    `json:"customization" gorm:"column:customization;type:jsonb"` // for user itself customization config, including: Language, IsSubscribed

}

func NewUpdateUserRequest

func NewUpdateUserRequest() *UpdateUserRequest

type UpdateUserResponse

type UpdateUserResponse struct {
	ID           string    `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID string    `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func NewUpdateUserResponse

func NewUpdateUserResponse(user *User) *UpdateUserResponse

func (*UpdateUserResponse) ExportForFeedback

func (resp *UpdateUserResponse) ExportForFeedback() interface{}

type User

type User struct {
	ID             int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:users_ukey"`
	UID            uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:users_ukey"`
	Nickname       string    `json:"nickname" gorm:"column:nickname;type:varchar;size:15"`
	PasswordDigest string    `json:"passworddigest" gorm:"column:password_digest;type:varchar;size:60;not null"`
	Email          string    `json:"email" gorm:"column:email;type:varchar;size:255;not null"`
	Avatar         string    `json:"avatar" gorm:"column:avatar;type:varchar;size:255;not null"`
	SSOConfig      string    `json:"SSOConfig" gorm:"column:sso_config;type:jsonb"`        // for single sign-on data
	Customization  string    `json:"customization" gorm:"column:customization;type:jsonb"` // for user itself customization config, including: Language, IsSubscribed
	CreatedAt      time.Time `gorm:"column:created_at;type:timestamp"`
	UpdatedAt      time.Time `gorm:"column:updated_at;type:timestamp"`
}

func NewUser

func NewUser() *User

func (*User) ConstructByJSON

func (u *User) ConstructByJSON(userJSON []byte) error

func (*User) Export

func (u *User) Export() *UserForExport

func (*User) ExportEmail

func (u *User) ExportEmail() string

func (*User) ExportID

func (u *User) ExportID() int

func (*User) ExportLanguage

func (u *User) ExportLanguage() string

func (*User) ExportUserCustomization

func (u *User) ExportUserCustomization() *UserCustomization

func (*User) GetUIDInString

func (u *User) GetUIDInString() string

func (*User) InitCreatedAt

func (u *User) InitCreatedAt()

func (*User) InitUID

func (u *User) InitUID()

func (*User) InitUpdatedAt

func (u *User) InitUpdatedAt()

func (*User) SetAvatar

func (u *User) SetAvatar(avatar string)

func (*User) SetID

func (u *User) SetID(id int)

func (*User) SetIsTutorialViewed added in v0.0.7

func (u *User) SetIsTutorialViewed(isTutorialViewed bool)

func (*User) SetLanguage

func (u *User) SetLanguage(language string)

func (*User) SetNickname

func (u *User) SetNickname(nickname string)

func (*User) SetPasswordByByte

func (u *User) SetPasswordByByte(password []byte)

func (*User) SetUserCustomization

func (u *User) SetUserCustomization(userCustomization *UserCustomization)

func (*User) UpdateByUpdateUserAvatarRequest

func (u *User) UpdateByUpdateUserAvatarRequest(req *UpdateAvatarRequest)

type UserAvatarUploadAddressResponse

type UserAvatarUploadAddressResponse struct {
	UploadAddress string `json:"uploadAddress"`
}

func NewUserAvatarUploadAddressResponse

func NewUserAvatarUploadAddressResponse(presignedURL string) *UserAvatarUploadAddressResponse

func (*UserAvatarUploadAddressResponse) ExportForFeedback

func (resp *UserAvatarUploadAddressResponse) ExportForFeedback() interface{}

type UserCustomization

type UserCustomization struct {
	Language         string
	IsSubscribed     bool
	IsTutorialViewed bool
}

func NewUserCustomization

func NewUserCustomization() *UserCustomization

func (*UserCustomization) Export

func (c *UserCustomization) Export() (string, error)

func (*UserCustomization) SetIsSubscribed

func (c *UserCustomization) SetIsSubscribed(isSubscribed bool)

func (*UserCustomization) SetIsTutorialViewed added in v0.0.7

func (c *UserCustomization) SetIsTutorialViewed(isTutorialViewed bool)

func (*UserCustomization) SetLanguage

func (c *UserCustomization) SetLanguage(language string)

type UserForExport

type UserForExport struct {
	ID           int       `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID int       `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func (*UserForExport) SetTeamMemberID

func (ufe *UserForExport) SetTeamMemberID(teamMemberID int)

type UserSSOConfig

type UserSSOConfig struct {
	Github string
}

func NewUserSSOConfig

func NewUserSSOConfig() *UserSSOConfig

func (*UserSSOConfig) Export

func (u *UserSSOConfig) Export() string

type UserStorage

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

func NewUserStorage

func NewUserStorage(db *gorm.DB, logger *zap.SugaredLogger) *UserStorage

func (*UserStorage) Create

func (d *UserStorage) Create(u *User) (int, error)

func (*UserStorage) DeleteByID

func (d *UserStorage) DeleteByID(id int) error

func (*UserStorage) DeleteByUID

func (d *UserStorage) DeleteByUID(uid string) error

func (*UserStorage) RetrieveByEmail

func (d *UserStorage) RetrieveByEmail(email string) (*User, error)

func (*UserStorage) RetrieveByID

func (d *UserStorage) RetrieveByID(id int) (*User, error)

func (*UserStorage) RetrieveByIDAndUID

func (d *UserStorage) RetrieveByIDAndUID(id int, uid uuid.UUID) (*User, error)

func (*UserStorage) RetrieveByIDs

func (d *UserStorage) RetrieveByIDs(ids []int) ([]*User, error)

func (*UserStorage) RetrieveByUID

func (d *UserStorage) RetrieveByUID(uid uuid.UUID) (*User, error)

func (*UserStorage) UpdateByID

func (d *UserStorage) UpdateByID(u *User) error

func (*UserStorage) ValidateUser

func (d *UserStorage) ValidateUser(id int, uid uuid.UUID) (bool, error)

type VCodeClaims

type VCodeClaims struct {
	Email string `json:"email"`
	Code  string `json:"code"`
	Usage string `json:"usage"`
	jwt.RegisteredClaims
}

type VerificationRequest

type VerificationRequest struct {
	Email string `json:"email" validate:"required"`
	Usage string `json:"usage" validate:"oneof=signup forgetpwd"`
}

func NewVerificationRequest

func NewVerificationRequest() *VerificationRequest

Jump to

Keyboard shortcuts

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