package advice

import (
	"ai_scheduler/internal/biz"
	"ai_scheduler/internal/config"
	"ai_scheduler/internal/entitys"
	"ai_scheduler/internal/pkg"

	"github.com/gofiber/fiber/v2"
)

// ClientService 数据处理
type ClientService struct {
	AdviceClientBiz *biz.AdviceClientBiz
	cfg             *config.Config
}

// NewDataService
func NewClientService(
	AdviceClientBiz *biz.AdviceClientBiz,
	cfg *config.Config,
) *ClientService {
	return &ClientService{
		AdviceClientBiz: AdviceClientBiz,
		cfg:             cfg,
	}
}

func (d *ClientService) Add(c *fiber.Ctx) error {
	req := &entitys.AdvicerClientAddReq{}
	if err := c.BodyParser(req); err != nil {
		return err
	}
	id, err := d.AdviceClientBiz.Add(c.UserContext(), req)
	return pkg.HandleResponse(c, id, err)
}

func (d *ClientService) Update(c *fiber.Ctx) error {
	req := &entitys.AdvicerrClientUpdateReq{}
	if err := c.BodyParser(req); err != nil {
		return err
	}
	return d.AdviceClientBiz.Update(c.UserContext(), req)
}

func (d *ClientService) List(c *fiber.Ctx) error {
	req := &entitys.AdvicerClientListReq{}
	if err := c.BodyParser(req); err != nil {
		return err
	}
	list, err := d.AdviceClientBiz.List(c.UserContext(), req)
	return pkg.HandleResponse(c, list, err)
}

func (d *ClientService) Del(c *fiber.Ctx) error {
	req := &entitys.AdvicerClientDelReq{}
	if err := c.BodyParser(req); err != nil {
		return err
	}

	return d.AdviceClientBiz.Del(c.UserContext(), req)
}
