tag

package
v0.0.0-...-36d29c1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

Tag管理

定义接口与数据结构

数据结构和接口的定义(产品)

为接口添加测试用例(TDD)

实现接口

编写接口对外的HTTP暴露Handler

Documentation

Index

Constants

View Source
const (
	AppName = "tag"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddTagRequest

type AddTagRequest struct {
	// 一次可以添加多个Tag
	Tags []*CreateTagRequest
}

func NewAddTagRequest

func NewAddTagRequest() *AddTagRequest

初始化添加tag请求的结构体

func (*AddTagRequest) AddTag

func (req *AddTagRequest) AddTag(tag *CreateTagRequest)

func (*AddTagRequest) BlogIds

func (req *AddTagRequest) BlogIds() (ids []int)

做blog id去重,生成并返回一个blog id切片

func (*AddTagRequest) Validate

func (req *AddTagRequest) Validate() error

type CreateTagRequest

type CreateTagRequest struct {
	// 关联的博客, 同一标签,允许打在不同博客上的
	BlogId int `json:"blog_id" validate:"required"`
	// 标签名称
	Key string `json:"key" validate:"required"`
	// 标签的value
	Value string `json:"value" validate:"required"`
	// 标签的颜色
	Color string `json:"color"`
}

type QueryTagRequest

type QueryTagRequest struct {
	TagIds []int `json:"tag_ids"`
	BlogId int   `json:"blog_id"`
}

func NewQueryTagRequest

func NewQueryTagRequest() *QueryTagRequest

func (*QueryTagRequest) AddTagId

func (req *QueryTagRequest) AddTagId(ids ...int)

type RemoveTagRequest

type RemoveTagRequest struct {
	TagIds []int `json:"tag_ids"`
}

func NewRemoveTagRequest

func NewRemoveTagRequest() *RemoveTagRequest

func (*RemoveTagRequest) AddTagId

func (req *RemoveTagRequest) AddTagId(id int)

type Service

type Service interface {
	// 查询标签
	QueryTagRequest(context.Context, *QueryTagRequest) (*TagSet, error)
	// 文章添加Tag
	AddTag(context.Context, *AddTagRequest) (*TagSet, error)
	// 文章移除Tag
	RemoveTag(context.Context, *RemoveTagRequest) (*TagSet, error)
}

type Tag

type Tag struct {
	// 标签Id
	Id int `json:"id"`
	// 创建时间: 用于排序
	CreateAt int64 `json:"create_at"`
	// Tag的具体数据
	*CreateTagRequest
}

用于存储文章标签, 整个key, value组成一个tag

func NewTagFromAddTagRequest

func NewTagFromAddTagRequest(req *CreateTagRequest) *Tag

TagSet中Tag的值写入

type TagSet

type TagSet struct {
	Items []*Tag `json:"items"`
}

func NewTagSet

func NewTagSet() *TagSet

func NewTagSetFromAddRequest

func NewTagSetFromAddRequest(req *AddTagRequest) *TagSet

添加tag请求的结构体 写入 TagSet

func (*TagSet) Add

func (s *TagSet) Add(item *Tag)

func (*TagSet) String

func (s *TagSet) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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