package inference

import (
	"context"
	"gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"

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

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

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

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

func (l *ModelNamesByTypeLogic) ModelNamesByType(req *types.ModelNamesReq) (resp *types.ModelNamesResp, err error) {
	resp = &types.ModelNamesResp{}
	models, err := storeLink.GetModelNamesByType(req.Type)
	if err != nil {
		logx.Errorf("ModelNamesByType err: %v", err)
		return nil, err
	}
	resp.ModelNames = models
	return resp, nil
}
