package merchant

import (
	"context"
	"kami/internal/errHandler"
	"kami/internal/service"

	"github.com/gogf/gf/v2/errors/gcode"

	"kami/api/merchant/v1"
)

func (c *ControllerV1) MerchantAllList(ctx context.Context, req *v1.MerchantAllListReq) (res *v1.MerchantAllListRes, err error) {
	_, err = service.SysAuth().LoginOnlyIFrame(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
		return
	}
	res = &v1.MerchantAllListRes{}
	list, total, err := service.Merchant().All(ctx)
	if err != nil {
		return
	}
	res.List = list
	res.Total = total
	return
}
