package jd_cookie

import (
	"context"
	"kami/api/jd_cookie/v1"
	"kami/internal/errHandler"
	"kami/internal/service"

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

func (c *ControllerV1) GetAccount(ctx context.Context, req *v1.GetAccountReq) (res *v1.GetAccountRes, err error) {
	_, err = service.SysAuth().LoginOnlyIFrame(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
		return
	}
	account, err := service.JdCookie().GetAccount(ctx, req.CookieId)
	if err != nil {
		return nil, err
	}

	res = &v1.GetAccountRes{
		Account: account,
	}

	return res, nil
}
