biz

package
v0.0.0-...-f792d7b Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	ID          uint
	Name        string
	Slug        string
	Description string
	Count       uint
}

type CategoryRepo

type CategoryRepo interface {
	SaveCategory(*Category) error
	GetCategoryByID(uint) (*Category, error)
	GetCategoryByName(string) (*Category, error)
	GetAllCategories() ([]*Category, error)
	DeleteCategory(uint) error
	DeleteCategoryByName(string) error
}

CategoryRepo defines the storage interface for category.

type CategoryUseCase

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

CategoryUseCase defines the use case for category.

func NewCategoryUseCase

func NewCategoryUseCase(repo CategoryRepo, logger log.Logger) *CategoryUseCase

NewCategoryUseCase creates a new CategoryUseCase.

func (*CategoryUseCase) CreateCategory

func (uc *CategoryUseCase) CreateCategory(c *Category) error

CreateCategory creates a new category.

func (*CategoryUseCase) DeleteCategory

func (uc *CategoryUseCase) DeleteCategory(id uint) error

DeleteCategory deletes a category by its ID.

func (*CategoryUseCase) DeleteCategoryByName

func (uc *CategoryUseCase) DeleteCategoryByName(name string) error

DeleteCategoryByName deletes a category by its name.

func (*CategoryUseCase) GetAllCategories

func (uc *CategoryUseCase) GetAllCategories() ([]*Category, error)

GetAllCategories gets all categories.

func (*CategoryUseCase) GetCategoryByID

func (uc *CategoryUseCase) GetCategoryByID(id uint) (*Category, error)

GetCategoryByID gets a category by its ID.

func (*CategoryUseCase) GetCategoryByName

func (uc *CategoryUseCase) GetCategoryByName(name string) (*Category, error)

GetCategoryByName gets a category by its name.

type Comment

type Comment struct {
	ID       uint
	PostID   uint
	Content  string
	ParentID uint
	Rating   int
	NickName string
	Email    string
	Website  string
}

type CommentRepo

type CommentRepo interface {
	SaveComment(*Comment) error
	GetCommentsByID(uint) ([]*Comment, error) // if the comment has children, its children will be returned as well
	GetPostCommentsByPostID(uint) ([]*Comment, error)
	DeleteComment(uint) error // if the comment has children, its children will be deleted as well
}

CommentRepo defines the storage interface for comment.

type CommentUseCase

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

CommentUseCase defines the use case for comment.

func NewCommentUseCase

func NewCommentUseCase(repo CommentRepo, logger log.Logger) *CommentUseCase

func (*CommentUseCase) CreateComment

func (uc *CommentUseCase) CreateComment(c *Comment) error

func (*CommentUseCase) DeleteComment

func (uc *CommentUseCase) DeleteComment(id uint) error

func (*CommentUseCase) GetCommentsByID

func (uc *CommentUseCase) GetCommentsByID(id uint) ([]*Comment, error)

func (*CommentUseCase) GetPostCommentsByPostID

func (uc *CommentUseCase) GetPostCommentsByPostID(id uint) ([]*Comment, error)

type ListOptions

type ListOptions struct {
	Page     uint32
	PageSize uint32
	Author   string
	Category string
	Status   string
	Slug     string
}

ListOptions 定义列表查询选项

type Post

type Post struct {
	ID        uint32
	Title     string
	Content   string
	Slug      string
	Status    string
	Author    string
	Category  string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type PostRepo

type PostRepo interface {
	// 创建文章
	CreatePost(ctx context.Context, post *Post) (*Post, error)

	// 更新文章
	UpdatePost(ctx context.Context, post *Post) (*Post, error)

	// 根据 ID 获取文章
	GetPostByID(ctx context.Context, id uint32) (*Post, error)

	// 根据 Slug 获取文章
	GetPostBySlug(ctx context.Context, slug string) (*Post, error)

	// 列出文章
	ListPosts(ctx context.Context, opts *ListOptions) ([]*Post, uint32, error)

	// 删除文章
	DeletePost(ctx context.Context, id uint32) error

	// 根据 Slug 删除文章
	DeletePostBySlug(ctx context.Context, slug string) error
}

PostRepo defines the storage interface for post.

type PostUseCase

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

PostUseCase defines the use case for post.

func NewPostUseCase

func NewPostUseCase(repo PostRepo, logger log.Logger) *PostUseCase

func (*PostUseCase) Create

func (uc *PostUseCase) Create(ctx context.Context, p *Post) (*Post, error)

Create 创建文章

func (*PostUseCase) Delete

func (uc *PostUseCase) Delete(ctx context.Context, id uint32) error

Delete 删除文章

func (*PostUseCase) DeleteBySlug

func (uc *PostUseCase) DeleteBySlug(ctx context.Context, slug string) error

DeleteBySlug 根据 Slug 删除文章

func (*PostUseCase) GetByID

func (uc *PostUseCase) GetByID(ctx context.Context, id uint32) (*Post, error)

GetByID 根据 ID 获取文章

func (*PostUseCase) GetBySlug

func (uc *PostUseCase) GetBySlug(ctx context.Context, slug string) (*Post, error)

GetBySlug 根据 Slug 获取文章

func (*PostUseCase) List

func (uc *PostUseCase) List(ctx context.Context, opts *ListOptions) ([]*Post, uint32, error)

List 列出文章

func (*PostUseCase) Update

func (uc *PostUseCase) Update(ctx context.Context, p *Post) (*Post, error)

Update 更新文章

type Tag

type Tag struct {
	ID          uint
	Name        string
	Slug        string
	Count       uint
	Description string
}

type TagRepo

type TagRepo interface {
	SaveTag(*Tag) error
	GetTagByID(uint) (*Tag, error)
	GetTagByName(string) (*Tag, error)
	GetAllTags() ([]*Tag, error)
	DeleteTag(uint) error
	DeleteTagByName(string) error
}

TagRepo defines the storage interface for tag.

type TagUseCase

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

TagUseCase defines the use case for tag.

func NewTagUseCase

func NewTagUseCase(repo TagRepo, logger log.Logger) *TagUseCase

func (*TagUseCase) CreateTag

func (uc *TagUseCase) CreateTag(c *Tag) error

func (*TagUseCase) DeleteTag

func (uc *TagUseCase) DeleteTag(id uint) error

func (*TagUseCase) DeleteTagByName

func (uc *TagUseCase) DeleteTagByName(name string) error

func (*TagUseCase) GetAllTags

func (uc *TagUseCase) GetAllTags() ([]*Tag, error)

func (*TagUseCase) GetTagByID

func (uc *TagUseCase) GetTagByID(id uint) (*Tag, error)

func (*TagUseCase) GetTagByName

func (uc *TagUseCase) GetTagByName(name string) (*Tag, error)

Jump to

Keyboard shortcuts

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