37 lines
921 B
Go
37 lines
921 B
Go
package cloud
|
|
|
|
import (
|
|
"context"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
|
)
|
|
|
|
type CloudListLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewCloudListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CloudListLogic {
|
|
return &CloudListLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *CloudListLogic) CloudList() (resp *types.CloudListResp, err error) {
|
|
// 查询数据库中数算任务列表
|
|
var clouds []*models.Cloud
|
|
tx := l.svcCtx.DbEngin.Find(&clouds)
|
|
if tx.Error != nil {
|
|
return nil, tx.Error
|
|
}
|
|
result := types.CloudListResp{}
|
|
utils.Convert(clouds, &result.Clouds)
|
|
return &result, nil
|
|
}
|