// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.8.0
// - protoc             v3.12.4
// source: svapi/comment.proto

package svapi

import (
	context "context"
	http "github.com/go-kratos/kratos/v2/transport/http"
	binding "github.com/go-kratos/kratos/v2/transport/http/binding"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the kratos package it is being compiled against.
var _ = new(context.Context)
var _ = binding.EncodeURL

const _ = http.SupportPackageIsVersion1

const OperationCommentServiceCreateComment = "/svapi.CommentService/CreateComment"
const OperationCommentServiceListChildComment = "/svapi.CommentService/ListChildComment"
const OperationCommentServiceListComment4Video = "/svapi.CommentService/ListComment4Video"
const OperationCommentServiceRemoveComment = "/svapi.CommentService/RemoveComment"

type CommentServiceHTTPServer interface {
	// CreateComment 创建评论
	CreateComment(context.Context, *CreateCommentRequest) (*CreateCommentResponse, error)
	ListChildComment(context.Context, *ListChildCommentRequest) (*ListChildCommentResponse, error)
	// ListComment4Video 列出视频的评论
	ListComment4Video(context.Context, *ListComment4VideoRequest) (*ListComment4VideoResponse, error)
	// RemoveComment 删除评论
	RemoveComment(context.Context, *RemoveCommentRequest) (*RemoveCommentResponse, error)
}

func RegisterCommentServiceHTTPServer(s *http.Server, srv CommentServiceHTTPServer) {
	r := s.Route("/")
	r.POST("/comment", _CommentService_CreateComment0_HTTP_Handler(srv))
	r.DELETE("/comment", _CommentService_RemoveComment0_HTTP_Handler(srv))
	r.POST("/comment/video", _CommentService_ListComment4Video0_HTTP_Handler(srv))
	r.POST("/comment/child", _CommentService_ListChildComment0_HTTP_Handler(srv))
}

func _CommentService_CreateComment0_HTTP_Handler(srv CommentServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in CreateCommentRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationCommentServiceCreateComment)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.CreateComment(ctx, req.(*CreateCommentRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

func _CommentService_RemoveComment0_HTTP_Handler(srv CommentServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in RemoveCommentRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationCommentServiceRemoveComment)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.RemoveComment(ctx, req.(*RemoveCommentRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

func _CommentService_ListComment4Video0_HTTP_Handler(srv CommentServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in ListComment4VideoRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationCommentServiceListComment4Video)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.ListComment4Video(ctx, req.(*ListComment4VideoRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

func _CommentService_ListChildComment0_HTTP_Handler(srv CommentServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in ListChildCommentRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationCommentServiceListChildComment)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.ListChildComment(ctx, req.(*ListChildCommentRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

type CommentServiceHTTPClient interface {
	CreateComment(ctx context.Context, req *CreateCommentRequest, opts ...http.CallOption) (rsp *CreateCommentResponse, err error)
	ListChildComment(ctx context.Context, req *ListChildCommentRequest, opts ...http.CallOption) (rsp *ListChildCommentResponse, err error)
	ListComment4Video(ctx context.Context, req *ListComment4VideoRequest, opts ...http.CallOption) (rsp *ListComment4VideoResponse, err error)
	RemoveComment(ctx context.Context, req *RemoveCommentRequest, opts ...http.CallOption) (rsp *RemoveCommentResponse, err error)
}

type CommentServiceHTTPClientImpl struct {
	cc *http.Client
}

func NewCommentServiceHTTPClient(client *http.Client) CommentServiceHTTPClient {
	return &CommentServiceHTTPClientImpl{client}
}

func (c *CommentServiceHTTPClientImpl) CreateComment(ctx context.Context, in *CreateCommentRequest, opts ...http.CallOption) (*CreateCommentResponse, error) {
	var out CreateCommentResponse
	pattern := "/comment"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationCommentServiceCreateComment))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}

func (c *CommentServiceHTTPClientImpl) ListChildComment(ctx context.Context, in *ListChildCommentRequest, opts ...http.CallOption) (*ListChildCommentResponse, error) {
	var out ListChildCommentResponse
	pattern := "/comment/child"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationCommentServiceListChildComment))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}

func (c *CommentServiceHTTPClientImpl) ListComment4Video(ctx context.Context, in *ListComment4VideoRequest, opts ...http.CallOption) (*ListComment4VideoResponse, error) {
	var out ListComment4VideoResponse
	pattern := "/comment/video"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationCommentServiceListComment4Video))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}

func (c *CommentServiceHTTPClientImpl) RemoveComment(ctx context.Context, in *RemoveCommentRequest, opts ...http.CallOption) (*RemoveCommentResponse, error) {
	var out RemoveCommentResponse
	pattern := "/comment"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationCommentServiceRemoveComment))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "DELETE", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}
