package bundle

import (
	"context"
	"fonchain-fiee/api/bundle"
	"fonchain-fiee/api/cast"
	"fonchain-fiee/pkg/service"

	"github.com/gin-gonic/gin"
)

func BundleExtend(c *gin.Context) {
	var req bundle.BundleExtendRequest
	if err := c.ShouldBindJSON(&req); err != nil {
		service.Error(c, err)
		return
	}
	res, err := service.BundleProvider.BundleExtend(context.Background(), &req)
	if err != nil {
		service.Error(c, err)
		return
	}
	service.Success(c, res)
}

func BundleExtendRecordsList(c *gin.Context) {
	var req bundle.BundleExtendRecordsListRequest
	if err := c.ShouldBindJSON(&req); err != nil {
		service.Error(c, err)
		return
	}
	res, err := service.BundleProvider.BundleExtendRecordsList(context.Background(), &req)
	if err != nil {
		service.Error(c, err)
		return
	}
	service.Success(c, res)
}

func GetBundleBalance(c *gin.Context) {
	var req bundle.GetBundleBalanceListReq
	if err := c.ShouldBindJSON(&req); err != nil {
		service.Error(c, err)
		return
	}
	res, err := service.BundleProvider.GetBundleBalanceList(context.Background(), &req)
	if err != nil {
		service.Error(c, err)
		return
	}
	service.Success(c, res)
}

func GetUsedRecordList(c *gin.Context) {
	var req bundle.GetUsedRecordListReq
	if err := c.ShouldBindJSON(&req); err != nil {
		service.Error(c, err)
		return
	}
	res, err := service.BundleProvider.GetUsedRecordList(context.Background(), &req)
	if err != nil {
		service.Error(c, err)
		return
	}
	service.Success(c, res)
}

func GetWorkDetail(c *gin.Context) {
	var req cast.WorkDetailReq
	if err := c.ShouldBindJSON(&req); err != nil {
		service.Error(c, err)
		return
	}
	res, err := service.CastProvider.WorkDetail(context.Background(), &req)
	if err != nil {
		service.Error(c, err)
		return
	}
	service.Success(c, res)
}
