sharetoken

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	Create(c *gin.Context)
	List(c *gin.Context)
	Delete(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
) API

type AggregationResult

type AggregationResult struct {
	Data       []Response `bson:"data" json:"data"`
	TotalCount int64      `bson:"total_count" json:"total_count"`
}

func (*AggregationResult) GetData

func (r *AggregationResult) GetData() interface{}

func (*AggregationResult) GetTotal

func (r *AggregationResult) GetTotal() int64

type EditRequest

type EditRequest struct {
	Duration    *datetime.DurationWithUnit `json:"duration"`
	Description string                     `json:"description" binding:"max=500"`
}

type ListRequest

type ListRequest struct {
	pagination.Query
	Search string `form:"search"`
	Sort   string `form:"sort" binding:"oneoforempty=asc desc"`
	SortBy string `json:"sort_by" form:"sort_by" binding:"oneoforempty=user.name description created accessed expired"`
}

type Model

type Model struct {
	ID          string            `bson:"_id"`
	Value       string            `bson:"value"`
	User        string            `bson:"user"`
	Description string            `bson:"description"`
	Created     datetime.CpsTime  `bson:"created"`
	Accessed    datetime.CpsTime  `bson:"accessed"`
	Expired     *datetime.CpsTime `bson:"expired,omitempty"`
}

type Response

type Response struct {
	ID          string            `bson:"_id" json:"_id"`
	Value       string            `bson:"value" json:"value"`
	User        *author.Author    `bson:"user" json:"user"`
	Roles       []author.Role     `bson:"roles" json:"roles"`
	Description string            `bson:"description" json:"description"`
	Created     datetime.CpsTime  `bson:"created" json:"created" swaggertype:"integer"`
	Accessed    datetime.CpsTime  `bson:"accessed" json:"accessed" swaggertype:"integer"`
	Expired     *datetime.CpsTime `bson:"expired" json:"expired" swaggertype:"integer"`
}

type Store

type Store interface {
	Insert(ctx context.Context, userId string, r EditRequest) (*Response, error)
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	Delete(ctx context.Context, id string) (bool, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	tokenGenerator token.Generator,
	authorProvider author.Provider,
) Store

Jump to

Keyboard shortcuts

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