// 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"
)

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

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

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

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

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

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