package admin

import (
	"context"
	"server/internal/model"
	"server/internal/service"

	"github.com/gogf/gf/v2/frame/g"

	v1 "server/api/admin/v1"
)

func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) {
	adminId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
	out, err := service.Admin().Info(ctx, &model.AdminInfoIn{AdminId: adminId})

	if err != nil {
		return nil, err
	}
	return &v1.InfoRes{
		Id:       out.Id,
		Username: out.Username,
		Role:     out.Role,
	}, nil
}
