comment

package
v1.6.12 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

internal/app/handler/comment/handler.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func NewHandler

func NewHandler(svc *comment.Service) *Handler

func (*Handler) AdminList

func (h *Handler) AdminList(c *gin.Context)

AdminList @Summary 管理员查询评论列表 @Description 根据多种条件分页查询评论 @Tags 评论管理 @Security BearerAuth @Accept json @Produce json @Param query query dto.AdminListRequest true "查询参数" @Success 200 {object} response.Response{data=dto.ListResponse} "成功响应" @Failure 400 {object} response.Response "请求参数错误" @Failure 401 {object} response.Response "未授权" @Failure 500 {object} response.Response "服务器内部错误" @Router /comments [get]

func (*Handler) Create

func (h *Handler) Create(c *gin.Context)

Create @Summary 创建新评论 @Description 为指定路径的页面创建一条新评论,可以是根评论或回复 @Tags 公开评论 @Accept json @Produce json @Param comment_request body dto.CreateRequest true "创建评论的请求体" @Success 200 {object} response.Response{data=dto.Response} "成功响应" @Failure 400 {object} response.Response "请求参数错误" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments [post]

func (*Handler) Delete

func (h *Handler) Delete(c *gin.Context)

Delete @Summary 管理员批量删除评论 @Description 根据评论的公共ID批量删除评论 @Tags 评论管理 @Security BearerAuth @Accept json @Produce json @Param delete_request body dto.DeleteRequest true "删除请求,包含ID列表" @Success 200 {object} response.Response{data=integer} "成功响应,返回删除的数量" @Failure 400 {object} response.Response "请求参数错误" @Failure 401 {object} response.Response "未授权" @Failure 500 {object} response.Response "服务器内部错误" @Router /comments [delete]

func (*Handler) ExportComments added in v1.6.11

func (h *Handler) ExportComments(c *gin.Context)

ExportComments @Summary 管理员导出评论 @Description 导出选定的评论或所有评论为 ZIP 文件 @Tags 评论管理 @Security BearerAuth @Accept json @Produce application/zip @Param export_request body dto.ExportRequest true "导出请求,包含ID列表(空则导出所有)" @Success 200 {file} file "ZIP文件下载" @Failure 400 {object} response.Response "请求参数错误" @Failure 401 {object} response.Response "未授权" @Failure 500 {object} response.Response "服务器内部错误" @Router /comments/export [post]

func (*Handler) GetQQInfo added in v1.6.9

func (h *Handler) GetQQInfo(c *gin.Context)

GetQQInfo @Summary 获取QQ信息 @Description 根据QQ号获取QQ昵称和头像URL。用于评论表单自动填充功能。 @Tags 公开评论 @Produce json @Param qq query string true "QQ号码" @Success 200 {object} response.Response{data=comment.QQInfoResponse} "成功响应" @Failure 400 {object} response.Response "请求参数错误" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments/qq-info [get]

func (*Handler) ImportComments added in v1.6.11

func (h *Handler) ImportComments(c *gin.Context)

ImportComments @Summary 管理员导入评论 @Description 从 JSON 或 ZIP 文件导入评论 @Tags 评论管理 @Security BearerAuth @Accept multipart/form-data @Produce json @Param file formData file true "评论数据文件(JSON或ZIP格式)" @Param skip_existing formData bool false "是否跳过已存在的评论" @Param default_status formData int false "默认状态(1:已发布, 2:待审核)" @Param keep_create_time formData bool false "是否保留原创建时间" @Success 200 {object} response.Response{data=dto.ImportResult} "导入成功" @Failure 400 {object} response.Response "参数错误" @Failure 401 {object} response.Response "未授权" @Failure 500 {object} response.Response "导入失败" @Router /comments/import [post]

func (*Handler) LikeComment

func (h *Handler) LikeComment(c *gin.Context)

LikeComment @Summary 点赞评论 @Description 为指定ID的评论增加一次点赞 @Tags 公开评论 @Produce json @Param id path string true "评论的公共ID" @Success 200 {object} response.Response{data=integer} "成功响应,返回最新的点赞数" @Failure 400 {object} response.Response "请求参数错误" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments/{id}/like [post]

func (*Handler) ListByPath

func (h *Handler) ListByPath(c *gin.Context)

ListByPath @Summary 获取指定路径的评论列表(分页) @Description 分页获取指定路径下的根评论,并附带其所有子评论 @Tags 公开评论 @Produce json @Param target_path query string true "目标路径 (例如 /posts/some-slug)" @Param page query int false "页码" default(1) @Param pageSize query int false "每页数量" default(10) @Success 200 {object} response.Response{data=dto.ListResponse} "成功响应" @Failure 400 {object} response.Response "请求参数错误" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments [get]

func (*Handler) ListChildren

func (h *Handler) ListChildren(c *gin.Context)

ListChildren @Summary 获取指定评论的子评论列表(分页) @Description 分页获取指定根评论下的所有回复评论 @Tags 公开评论 @Produce json @Param id path string true "父评论的公共ID" @Param page query int false "页码" default(1) @Param pageSize query int false "每页数量" default(10) @Success 200 {object} response.Response{data=dto.ListResponse} "成功响应" @Failure 400 {object} response.Response "请求参数错误" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments/{id}/children [get]

func (*Handler) ListLatest added in v1.0.27

func (h *Handler) ListLatest(c *gin.Context)

ListLatest @Summary 公开获取最新评论列表 @Description 分页获取全站所有最新的已发布评论 @Tags 公开评论 @Produce json @Param page query int false "页码" default(1) @Param pageSize query int false "每页数量" default(10) @Success 200 {object} response.Response{data=dto.ListResponse} "成功响应" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments/latest [get]

func (*Handler) SetPin

func (h *Handler) SetPin(c *gin.Context)

SetPin @Summary 管理员置顶或取消置顶评论 @Description 设置或取消指定ID评论的置顶状态 @Tags 评论管理 @Security BearerAuth @Accept json @Produce json @Param id path string true "评论的公共ID" @Param pin_request body dto.SetPinRequest true "置顶请求" @Success 200 {object} response.Response{data=dto.Response} "成功响应,返回更新后的评论对象" @Failure 400 {object} response.Response "请求参数错误" @Failure 401 {object} response.Response "未授权" @Failure 404 {object} response.Response "评论不存在" @Failure 500 {object} response.Response "服务器内部错误" @Router /comments/{id}/pin [put]

func (*Handler) UnlikeComment

func (h *Handler) UnlikeComment(c *gin.Context)

UnlikeComment @Summary 取消点赞评论 @Description 为指定ID的评论减少一次点赞 @Tags 公开评论 @Produce json @Param id path string true "评论的公共ID" @Success 200 {object} response.Response{data=integer} "成功响应,返回最新的点赞数" @Failure 400 {object} response.Response "请求参数错误" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments/{id}/unlike [post]

func (*Handler) UpdateCommentInfo added in v1.6.11

func (h *Handler) UpdateCommentInfo(c *gin.Context)

UpdateCommentInfo @Summary 管理员更新评论信息 @Description 根据评论ID更新评论的内容、昵称、邮箱和网站等信息 @Tags 评论管理 @Security BearerAuth @Accept json @Produce json @Param id path string true "评论公共ID" @Param update_request body dto.UpdateCommentRequest true "更新请求,可包含 content、nickname、email、website" @Success 200 {object} response.Response{data=dto.Response} "更新成功" @Failure 400 {object} response.Response "请求参数错误" @Failure 401 {object} response.Response "未授权" @Failure 500 {object} response.Response "服务器内部错误" @Router /comments/{id}/info [put]

func (*Handler) UpdateContent added in v1.3.9

func (h *Handler) UpdateContent(c *gin.Context)

UpdateContent @Summary 管理员更新评论内容 @Description 根据评论ID更新评论的内容 @Tags 评论管理 @Security BearerAuth @Accept json @Produce json @Param id path string true "评论公共ID" @Param update_request body dto.UpdateContentRequest true "更新请求,包含新的内容" @Success 200 {object} response.Response{data=dto.Response} "更新成功" @Failure 400 {object} response.Response "请求参数错误" @Failure 401 {object} response.Response "未授权" @Failure 500 {object} response.Response "服务器内部错误" @Router /comments/{id} [put]

func (*Handler) UpdateStatus

func (h *Handler) UpdateStatus(c *gin.Context)

UpdateStatus @Summary 管理员更新评论状态 @Description 更新指定ID的评论的状态(例如,通过审核发布或设为待审核) @Tags 评论管理 @Security BearerAuth @Accept json @Produce json @Param id path string true "评论的公共ID" @Param status_request body dto.UpdateStatusRequest true "新的状态 (1: 已发布, 2: 待审核)" @Success 200 {object} response.Response{data=dto.Response} "成功响应,返回更新后的评论对象" @Failure 400 {object} response.Response "请求参数错误" @Failure 401 {object} response.Response "未授权" @Failure 404 {object} response.Response "评论不存在" @Failure 500 {object} response.Response "服务器内部错误" @Router /comments/{id}/status [put]

func (*Handler) UploadCommentImage

func (h *Handler) UploadCommentImage(c *gin.Context)

UploadCommentImage @Summary 上传评论图片 @Description 上传一张图片,用于插入到评论中。返回图片的内部URI。 @Tags 公开评论 @Security BearerAuth @Accept multipart/form-data @Produce json @Param file formData file true "图片文件" @Success 200 {object} response.Response{data=dto.UploadImageResponse} "成功响应,返回文件信息" @Failure 400 {object} response.Response "请求错误,例如没有上传文件" @Failure 401 {object} response.Response "未授权" @Failure 500 {object} response.Response "服务器内部错误" @Router /public/comments/upload [post]

Directories

Path Synopsis
internal/app/handler/comment/dto/dto.go
internal/app/handler/comment/dto/dto.go

Jump to

Keyboard shortcuts

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