feat: Enhance Swagger documentation with new admin and user endpoints
Some checks failed
build quyun / Build (push) Failing after 2m1s
Some checks failed
build quyun / Build (push) Failing after 2m1s
- Added definitions for admin authentication, media, posts, orders, and user management. - Implemented new API paths for admin functionalities including authentication, media management, order processing, and user statistics. - Updated existing endpoints to improve clarity and structure in the Swagger documentation. - Introduced new response schemas for various operations to standardize API responses.
This commit is contained in:
@@ -21,9 +21,15 @@ type posts struct{}
|
||||
|
||||
// List posts
|
||||
//
|
||||
// @Router /admin/posts [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
// @Summary 作品列表
|
||||
// @Tags Admin Posts
|
||||
// @Produce json
|
||||
// @Param pagination query requests.Pagination false "分页参数"
|
||||
// @Param query query ListQuery false "筛选条件"
|
||||
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
|
||||
// @Router /admin/posts [get]
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery) (*requests.Pager, error) {
|
||||
conds := []gen.Condition{
|
||||
models.PostQuery.Title.Like(*query.Keyword),
|
||||
@@ -69,8 +75,14 @@ type PostForm struct {
|
||||
|
||||
// Create
|
||||
//
|
||||
// @Router /admin/posts [post]
|
||||
// @Bind form body
|
||||
// @Summary 创建作品
|
||||
// @Tags Admin Posts
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body PostForm true "请求体"
|
||||
// @Success 200 {object} any "成功"
|
||||
// @Router /admin/posts [post]
|
||||
// @Bind form body
|
||||
func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
||||
post := models.Post{
|
||||
Title: form.Title,
|
||||
@@ -107,9 +119,16 @@ func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
||||
|
||||
// Update posts
|
||||
//
|
||||
// @Router /admin/posts/:id [put]
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
// @Summary 更新作品
|
||||
// @Tags Admin Posts
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Param form body PostForm true "请求体"
|
||||
// @Success 200 {object} any "成功"
|
||||
// @Router /admin/posts/:id [put]
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (ctl *posts) Update(ctx fiber.Ctx, id int64, form *PostForm) error {
|
||||
post, err := services.Posts.FindByID(ctx, id)
|
||||
if err != nil {
|
||||
@@ -147,8 +166,13 @@ func (ctl *posts) Update(ctx fiber.Ctx, id int64, form *PostForm) error {
|
||||
|
||||
// Delete posts
|
||||
//
|
||||
// @Router /admin/posts/:id [delete]
|
||||
// @Bind id path
|
||||
// @Summary 删除作品
|
||||
// @Tags Admin Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 204 {object} any "成功"
|
||||
// @Router /admin/posts/:id [delete]
|
||||
// @Bind id path
|
||||
func (ctl *posts) Delete(ctx fiber.Ctx, id int64) error {
|
||||
post, err := services.Posts.FindByID(ctx, id)
|
||||
if err != nil {
|
||||
@@ -172,8 +196,13 @@ type PostItem struct {
|
||||
|
||||
// Show posts by id
|
||||
//
|
||||
// @Router /admin/posts/:id [get]
|
||||
// @Bind id path
|
||||
// @Summary 作品详情
|
||||
// @Tags Admin Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Success 200 {object} PostItem "成功"
|
||||
// @Router /admin/posts/:id [get]
|
||||
// @Bind id path
|
||||
func (ctl *posts) Show(ctx fiber.Ctx, id int64) (*PostItem, error) {
|
||||
post, err := services.Posts.FindByID(ctx, id)
|
||||
if err != nil {
|
||||
@@ -194,9 +223,15 @@ func (ctl *posts) Show(ctx fiber.Ctx, id int64) (*PostItem, error) {
|
||||
|
||||
// SendTo
|
||||
//
|
||||
// @Router /admin/posts/:id/send-to/:userId [post]
|
||||
// @Bind id path
|
||||
// @Bind userId path
|
||||
// @Summary 赠送作品给用户
|
||||
// @Tags Admin Posts
|
||||
// @Produce json
|
||||
// @Param id path int64 true "作品 ID"
|
||||
// @Param userId path int64 true "用户 ID"
|
||||
// @Success 200 {object} any "成功"
|
||||
// @Router /admin/posts/:id/send-to/:userId [post]
|
||||
// @Bind id path
|
||||
// @Bind userId path
|
||||
func (ctl *posts) SendTo(ctx fiber.Ctx, id, userId int64) error {
|
||||
post, err := services.Posts.FindByID(ctx, id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user