update api
This commit is contained in:
parent
66dc370c4b
commit
dee975c73c
|
@ -110,3 +110,34 @@ func TrainJobDetail(ctx *gin.Context) {
|
|||
|
||||
model.Response(ctx, http.StatusOK, common.SUCCESS, resp.Payload)
|
||||
}
|
||||
|
||||
func TrainJobLog(ctx *gin.Context) {
|
||||
var param model.TrainJobLog
|
||||
if err := ctx.BindJSON(¶m); err != nil {
|
||||
model.Response(ctx, http.StatusBadRequest, common.INVALIDPARAMS, err)
|
||||
return
|
||||
}
|
||||
|
||||
ip := ctx.Query(common.IPADDR)
|
||||
if ip == "" {
|
||||
model.Response(ctx, 401, "addr为必填字段", nil)
|
||||
return
|
||||
}
|
||||
token := ctx.Query(common.ACCESSTOKEN)
|
||||
if token == "" {
|
||||
model.Response(ctx, 401, "token为必填字段", nil)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := service.TrainJobLog(ip, token, ¶m)
|
||||
if err != nil {
|
||||
model.Response(ctx, 500, common.INVOKEERROR, err)
|
||||
return
|
||||
}
|
||||
|
||||
if resp == "" {
|
||||
model.Response(ctx, 500, common.INVOKEERROR, nil)
|
||||
}
|
||||
|
||||
model.Response(ctx, http.StatusOK, common.SUCCESS, resp)
|
||||
}
|
||||
|
|
|
@ -148,3 +148,7 @@ type KS struct {
|
|||
Key string `json:"key"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
type TrainJobLog struct {
|
||||
JobId string `json:"jobId"`
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ func Create() (*gin.Engine, error) {
|
|||
job.POST("/create", apis.CreateTrainJob)
|
||||
job.GET("/list", apis.GetTrainJobList)
|
||||
job.GET("/detail", apis.TrainJobDetail)
|
||||
job.GET("/log", apis.TrainJobLog)
|
||||
|
||||
//billing
|
||||
bill := v1.Group("bill")
|
||||
|
|
|
@ -62,3 +62,21 @@ func TrainJobDetail(ip, token string, param *model.TrainJobDetailParam) (*model.
|
|||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func TrainJobLog(ip, token string, param *model.TrainJobLog) (string, error) {
|
||||
var reqUrl = ip + common.Forward_Slash + common.GetTrainJobLog
|
||||
|
||||
req := common.GetRestyRequest()
|
||||
resp, err := req.
|
||||
SetHeader("Authorization", "Bearer "+token).
|
||||
SetPathParam("taskId", param.JobId).
|
||||
SetPathParam("taskNum", "task0").
|
||||
SetPathParam("num", "0").
|
||||
SetBody(param).
|
||||
Get(reqUrl)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return resp.String(), nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue