model

package
v0.0.0-...-82802e3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermReadRelated = iota
	PermReadAll
	PermCreate
	PermChangeRelated
	PermChangeAll
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateGroupRequest

type CreateGroupRequest struct {
	// Name must be unique string. Name will be used
	Name string `json:"name"`
	// Description is additional info about group.
	// For example a Company name or any other meta info.
	Description string `json:"description"`
}

CreateGroupRequest ...

type CreateGroupResponse

type CreateGroupResponse struct {
	// ID is primary key of group.
	ID uuid.UUID `json:"id"`
	// Name is unique name of group.
	Name string `json:"name"`
	// Description is short info about group.
	Description string `json:"description"`
	// CreatedAt is creation time in UNIX format
	CreatedAt int64 `json:"created-at"`
}

CreateGroupResponse represents group object that was stored in service.

type CreateInviteRequest

type CreateInviteRequest struct {
	Group   uuid.UUID `json:"group" example:"00000000-0000-0000-0000-000000000000"`
	Limit   int       `json:"limit" example:"2"`
	Member  int       `json:"members-permission" example:"4"`
	Task    int       `json:"tasks-permission" example:"4"`
	Review  int       `json:"reviews-permission" example:"4"`
	Comment int       `json:"comments-permission" example:"4"`
}

CreateInviteRequest represents data that must be passed by user to create invite.

type CreateInviteResponse

type CreateInviteResponse struct {
	// Link is invite link to group.
	Link string `` /* 151-byte string literal not displayed */
	// Limit is count of available usages of invite link.
	Limit int `json:"limit" example:"2"`
}

CreateInviteResponse is response returned to user.

type CreateInviteViaGroupRequest

type CreateInviteViaGroupRequest struct {
	// Limit is count of available usages of invite link
	Limit int `json:"limit" example:"2"`
	// Member is role of user.
	//
	// There are permissions:
	// 0 - user can affect(read/update) only related objects;
	// 1 - user can read all object.
	// 2 - user can create new objects (invite users);
	// 3 - user can change/delete users who was invited by whose;
	// 4 - user can affect all users.
	Member int `json:"members-permission" example:"4"`
	// Task is role of user.
	//
	// Permissions:
	// 0 - read related;
	// 1 - read all;
	// 2 create;
	// 3 - update/delete related;
	// 4 - delete all;
	Task int `json:"tasks-permission" example:"4"`
	// Review is role of user.
	//
	// Permissions:
	// 0 - read related;
	// 1 - read all;
	// 2 - create;
	// 3 - update/delete related;
	// 4 - update/delete any;
	Review int `json:"reviews-permission" example:"4"`
	// Comment is role of user.
	//
	// Permissions:
	// 0 - read related;
	// 1 - read all;
	// 2 - create;
	// 3 - update/delete related;
	// 4 - update/delete any;
	Comment int `json:"comments-permission" example:"4"`
}

CreateInviteViaGroupRequest is response object to create invite.

type CreateTokenRequest

type CreateTokenRequest struct {
	// Email is user email
	Email string `json:"email" example:"[email protected]"`
	// Password is password of user.
	Password  string `json:"password" example:"strong_password"`
	TokenType string `json:"token-type" example:"bearer"`
}

CreateTokenRequest ...

type CreateTokenResponse

type CreateTokenResponse struct {
	TokenType   string `json:"token_type"`
	AccessToken string `json:"access_token"`
}

CreateTokenResponse is request object which will return to user on token create.

type CreateUserResponse

type CreateUserResponse struct {
	ID    uuid.UUID `json:"id" example:"00000000-0000-0000-0000-000000000000"`
	Email string    `json:"email" example:"[email protected]"`
}

CreateUserResponse ...

type Error

type Error struct {
	Err   string `json:"error" example:"short summary info about error"`
	Field string `json:"field" example:"additional info about error"`
}

Error is abstract error response type.

type GetMeResponse

type GetMeResponse struct {
	ID     uuid.UUID     `json:"id"`
	Email  string        `json:"email"`
	Groups []GroupInUser `json:"groups,omitempty"`
}

GetMeResponse ...

type GetTasksResponse

type GetTasksResponse struct {
	Count int     `json:"count"`
	Tasks []*Task `json:"tasks"`
}

GetTasksResponse ...

type Group

type Group struct {
	ID          uuid.UUID
	Name        string
	Description string
	CreatedAt   time.Time
	Owner       uuid.UUID
}

Group is abstract view of group.

type GroupInUser

type GroupInUser struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Tasks       []*Task   `json:"tasks,omitempty"`
}

GroupInUser is short info about group.

type RegisterUserRequest

type RegisterUserRequest struct {
	// Email is user email
	Email string `json:"email" example:"[email protected]"`
	// Password is password string
	Password string `json:"password" example:"strong_password"`
}

RegisterUserRequest ...

type Role

type Role struct {
	ID       int32
	Members  int
	Tasks    int
	Reviews  int
	Comments int
}

Role is helper struct to store role.

type Task

type Task struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"-"`
	CreatedBy   uuid.UUID `json:"created-by"`
	Status      string    `json:"status"`
}

Task ...

func (*Task) MarshalJSON

func (task *Task) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. Used to pass correct time layout to user.

func (*Task) UnmarshalJSON

func (task *Task) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaler. That gives developer flexibility to not thing about correct time layout passed into.

type TaskCreateRequest

type TaskCreateRequest struct {
	// Name is name of task.
	Name string `json:"name"`
	// Description - is verbose info about task. Could be any string.
	Description string `json:"description"`
	// Users - field which relating users to task.
	// If not defined, will create task only for user, who creates this task or for group.
	Users []uuid.UUID `json:"users"`
	// Group - optional filed that show group to which task will be related.
	Group *uuid.UUID `json:"group"`
}

TaskCreateRequest ...

type Token

type Token struct {
	UserID    uuid.UUID
	Token     string
	ExpiresAt time.Time
	Expires   bool
}

Token is access token struct.

type User

type User struct {
	// ID is user uuid.
	ID uuid.UUID `json:"id" example:"00000000-0000-0000-0000-000000000000"`
	// Email is string field of user's email addr.
	Email string `json:"email" example:"[email protected]"`
	// Pass is encrypted user password.
	Pass string `json:"-"`
}

User ...

type UserInGroup

type UserInGroup struct {
	UserID  uuid.UUID
	Email   string
	IsAdmin bool
	Members int
	Tasks   int
	Reviews int
	Comment int
}

UserInGroup represents user in group object.

Jump to

Keyboard shortcuts

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