package monitoring

import (
	"context"

	"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
	"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type AdapterInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAdapterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdapterInfoLogic {
	return &AdapterInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AdapterInfoLogic) AdapterInfo(req *types.AdapterInfoReq) (resp *types.AdapterInfoResp, err error) {
	// todo: add your logic here and delete this line
	resp = &types.AdapterInfoResp{}
	l.svcCtx.DbEngin.Raw("select ta.name , ta.version  from t_adapter  ta,t_cluster tc where tc.id = ? and tc.adapter_id = ta.id", req.ClusterId).Scan(resp)
	return resp, nil
}
