package core

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 GetPublicNetworkLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

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

func (l *GetPublicNetworkLogic) GetPublicNetwork(req *types.PublicNetworkReq) (resp *types.PublicNetworkResp, err error) {
	// todo: add your logic here and delete this line
	resp = &types.PublicNetworkResp{}
	var networkDict []types.NetworkDict
	sqlStrTask := "SELECT * FROM `vm_network_dict`"
	txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&networkDict)
	if txTask.Error != nil {
		logx.Error(err)
		return nil, txTask.Error
	}
	resp.Code = 200
	resp.Message = "success"
	resp.NetworkDict = networkDict
	return resp, nil
}
