// Code generated by hertz generator.

package core_api

import (
	"context"

	"github.com/xh-polaris/meowchat-core-api/biz/adaptor"
	"github.com/xh-polaris/meowchat-core-api/provider"

	"github.com/cloudwego/hertz/pkg/app"
	"github.com/cloudwego/hertz/pkg/protocol/consts"

	"github.com/xh-polaris/meowchat-core-api/biz/application/dto/meowchat/core_api"
)

// GetComments .
// @router /comment/get_comments [GET]
func GetComments(ctx context.Context, c *app.RequestContext) {
	var err error
	var req core_api.GetCommentsReq
	err = c.BindAndValidate(&req)
	if err != nil {
		c.String(consts.StatusBadRequest, err.Error())
		return
	}

	p := provider.Get()
	resp, err := p.CommentService.GetComments(ctx, &req)
	adaptor.PostProcess(ctx, c, &req, resp, err)
}

// NewComment .
// @router /comment/new_comment [POST]
func NewComment(ctx context.Context, c *app.RequestContext) {
	var err error
	var req core_api.NewCommentReq
	err = c.BindAndValidate(&req)
	if err != nil {
		c.String(consts.StatusBadRequest, err.Error())
		return
	}

	p := provider.Get()
	resp, err := p.CommentService.NewComment(ctx, &req)
	adaptor.PostProcess(ctx, c, &req, resp, err)
}

// DeleteComment .
// @router /comment/delete_comment [POST]
func DeleteComment(ctx context.Context, c *app.RequestContext) {
	var err error
	var req core_api.DeleteCommentReq
	err = c.BindAndValidate(&req)
	if err != nil {
		c.String(consts.StatusBadRequest, err.Error())
		return
	}

	p := provider.Get()
	resp, err := p.CommentService.DeleteComment(ctx, &req)
	adaptor.PostProcess(ctx, c, &req, resp, err)
}
