fix:提交寒武纪数据集代码
This commit is contained in:
parent
87cf22db9e
commit
768c9d10ac
|
@ -0,0 +1,51 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/common"
|
||||
"PCM/common/tool"
|
||||
"context"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/hanwuji"
|
||||
"PCM/adaptor/PCM-AI/PCM-HANWUJI/rpc/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateDataSetLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetLogic {
|
||||
return &CreateDataSetLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// get modelarts Token
|
||||
func (l *CreateDataSetLogic) CreateDataSet(in *hanwuji.CreateDataSetReq) (*hanwuji.CreateDataSetResq, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp hanwuji.CreateDataSetResq
|
||||
url := "http://192.168.242.41:8001/openaiserver/v1/datasetmanage/dataset"
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, url, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 201 {
|
||||
json.Unmarshal(body, &resp)
|
||||
} else if statusCode == 400 {
|
||||
json.Unmarshal(body, &resp)
|
||||
}
|
||||
return &hanwuji.CreateDataSetResq{}, nil
|
||||
}
|
|
@ -3,3 +3,26 @@ syntax = "proto3";
|
|||
package hanwuji;
|
||||
option go_package = "/hanwuji";
|
||||
|
||||
/******************find CreateDataset start*************************/
|
||||
|
||||
|
||||
message CreateDataSetReq {
|
||||
repeated string applyIds = 1; // @gotags: copier:"ApplyIds"
|
||||
string desc = 2; // @gotags: copier:"Desc"
|
||||
string name = 3; // @gotags: copier:"Name"
|
||||
string typeId = 4; // @gotags: copier:"TypeId"
|
||||
|
||||
}
|
||||
|
||||
message CreateDataSetResq{
|
||||
string id =1; // @gotags: copier:"Id"
|
||||
string version =2; // @gotags: copier:"Version"
|
||||
}
|
||||
|
||||
/******************find CreateDataset end*************************/
|
||||
|
||||
service Hanwuji{
|
||||
|
||||
//get modelarts Token
|
||||
rpc CreateDataSet(CreateDataSetReq) returns (CreateDataSetResq);
|
||||
}
|
Loading…
Reference in New Issue