service

package
v0.0.0-...-e371da1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShareStatusVoting   int8 = 1
	ShareStatusPlaned   int8 = 2
	ShareStatusFinished int8 = 3

	RelTypeLike int8 = 1
	RelTypeJoin int8 = 2
)
View Source
const (
	UserStatusEnabled  int8 = 1
	UserStatusDisabled int8 = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Id        int64     `json:"id"`
	Name      string    `json:"name"`
	AttaType  string    `json:"atta_type"`
	AttaPath  string    `json:"atta_path"`
	CreatedAt time.Time `json:"created_at"`
}

type AttachmentService

type AttachmentService interface {
	GetByID(ctx context.Context, id int64) (*Attachment, error)
	GetByShareID(ctx context.Context, shareID int64) ([]Attachment, error)
	CreateAttachment(ctx context.Context, atta Attachment) (int64, error)
}

func NewAttachmentService

func NewAttachmentService(cc infra.Resolver, db *sql.DB) AttachmentService

type CreditRank

type CreditRank struct {
	UserID  int64             `json:"user_id"`
	Name    string            `json:"name"`
	Account string            `json:"account"`
	Status  int8              `json:"status"`
	Credit  int64             `json:"credit"`
	Rank    int64             `json:"rank"`
	Shares  []CreditRankShare `json:"shares"`
}

type CreditRankShare

type CreditRankShare struct {
	ShareID int64  `json:"share_id"`
	Subject string `json:"subject"`
}

type CreditRanks

type CreditRanks []CreditRank

func (CreditRanks) Len

func (t CreditRanks) Len() int

func (CreditRanks) Less

func (t CreditRanks) Less(i, j int) bool

func (CreditRanks) Swap

func (t CreditRanks) Swap(i, j int)

type CreditService

type CreditService interface {
	CreditRanks(ctx context.Context, startAt time.Time) (CreditRanks, error)
}

func NewCreditService

func NewCreditService(cc infra.Resolver, db *sql.DB) CreditService

type Plan

type Plan struct {
	PlanUpdateFields
	Id           int64     `json:"id"`
	RealDuration int64     `json:"real_duration" validate:"gte=0"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type PlanUpdateFields

type PlanUpdateFields struct {
	ShareAt      time.Time `json:"share_at,omitempty" validate:"required"`
	ShareRoom    string    `json:"share_room"`
	PlanDuration int64     `json:"plan_duration" validate:"required,gt=0"`
	Note         string    `json:"note"`
}

type Provider

type Provider struct{}

func (Provider) Boot

func (p Provider) Boot(cc infra.Resolver)

func (Provider) Register

func (p Provider) Register(cc infra.Binder)

type Share

type Share struct {
	ShareUpdateFields
	Id           int64     `json:"id"`
	Status       int8      `json:"status" validate:"oneof=1 2 3"`
	Note         string    `json:"note"`
	LikeCount    int64     `json:"like_count" validate:"gte=0"`
	JoinCount    int64     `json:"join_count" validate:"gte=0"`
	Attachments  string    `json:"attachments"`
	CreateUserId int64     `json:"create_user_id"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type ShareDetail

type ShareDetail struct {
	Share       Share        `json:"share"`
	Plan        *Plan        `json:"plan"`
	Attachments []Attachment `json:"attachments"`
	LikeUsers   []User       `json:"like_users"`
	JoinUsers   []User       `json:"join_users"`
}

type ShareExt

type ShareExt struct {
	Share
	ShareAt      time.Time `json:"share_at,omitempty"`
	ShareRoom    string    `json:"share_room"`
	PlanDuration int64     `json:"plan_duration"`
}

type ShareFilter

type ShareFilter struct {
	Statuses []int8 `json:"statuses"`
	Creator  int64  `json:"creator"`
	Type     string `json:"type"`
}

type ShareFinishFields

type ShareFinishFields struct {
	RealDuration int64   `json:"real_duration" validate:"required,gte=0"`
	Attachments  []int64 `json:"attachments"`
	Note         string  `json:"note"`
}

type ShareService

type ShareService interface {
	// GetShareByID get a share by id
	GetShareByID(ctx context.Context, id int64) (*ShareDetail, error)
	// CreateShare create a share
	CreateShare(ctx context.Context, share Share) (int64, error)
	// CreateOrUpdatePlan create or update a share plan
	CreateOrUpdatePlan(ctx context.Context, shareID int64, plan PlanUpdateFields) (int64, error)
	// RemovePlan delete a plan for a share
	RemovePlan(ctx context.Context, shareID int64) (bool, error)
	// GetShares return all shares
	GetShares(ctx context.Context, filter ShareFilter, sortDesc bool, page int64, perPage int64) ([]ShareExt, query.PaginateMeta, error)
	// FinishShare set a share as finished status
	FinishShare(ctx context.Context, shareID int64, sf ShareFinishFields) (bool, error)

	// UpdateShare update a share
	UpdateShare(ctx context.Context, id int64, share ShareUpdateFields) error
	// RemoveShare delete a share
	RemoveShare(ctx context.Context, id int64) (bool, error)
	// LikeShare user like a share or cancel
	LikeShare(ctx context.Context, id int64, userID int64, positive bool) (bool, error)
	// JoinShare user join a share or cancel
	JoinShare(ctx context.Context, id int64, userID int64, positive bool) (bool, error)

	// IsUserLikeOrJoinShares return whether the user join or like the shares
	IsUserLikeOrJoinShares(ctx context.Context, userID int64, shareIDs []int64) (map[int64]UserLikeOrJoinShare, error)
}

func NewShareService

func NewShareService(cc infra.Resolver, db *sql.DB) ShareService

type ShareUpdateFields

type ShareUpdateFields struct {
	Subject     string `json:"subject" validate:"required,gte=2"`
	SubjectType string `json:"subject_type" validate:"required"`
	Description string `json:"description"`
	ShareUser   string `json:"share_user"`
	ShareUserId int64  `json:"share_user_id"`
}

type User

type User struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	// contains filtered or unexported fields
}

type UserBasic

type UserBasic struct {
	Id      int64  `json:"id"`
	Name    string `json:"name"`
	Account string `json:"account"`
}

type UserBasics

type UserBasics []UserBasic

func (UserBasics) Len

func (t UserBasics) Len() int

func (UserBasics) Less

func (t UserBasics) Less(i, j int) bool

func (UserBasics) Swap

func (t UserBasics) Swap(i, j int)

type UserInfo

type UserInfo struct {
	Id       int64  `json:"id"`
	Uuid     string `json:"uuid"`
	Name     string `json:"name"`
	Account  string `json:"account"`
	Status   int8   `json:"status"`
	Password string `json:"-"`
}

type UserLikeOrJoinShare

type UserLikeOrJoinShare struct {
	ShareID int64 `json:"share_id"`
	Like    bool  `json:"like"`
	Join    bool  `json:"join"`
}

type UserService

type UserService interface {
	Users(ctx context.Context) (UserBasics, error)
	LoadUser(ctx context.Context, username string, userInfo UserInfo) (*UserInfo, error)
	LoadUserByAccount(ctx context.Context, account string) (*UserInfo, error)
	Register(ctx context.Context, username, password string) (*UserInfo, error)
}

func NewUserService

func NewUserService(cc infra.Resolver, db *sql.DB) UserService

type ValidateError

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

func NewValidateError

func NewValidateError(err error) *ValidateError

func (*ValidateError) Error

func (v *ValidateError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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