forked from JointCloud/pcm-coordinator
提交任务信息修改
This commit is contained in:
parent
0f6f62ff08
commit
c76fa0492e
|
@ -158,6 +158,7 @@ type (
|
|||
type (
|
||||
GeneralTaskReq {
|
||||
Token string `json:"token,optional"`
|
||||
UserId int64 `json:"userId,optional"`
|
||||
Name string `json:"name"`
|
||||
AdapterIds []string `json:"adapterIds"`
|
||||
ClusterIds []string `json:"clusterIds"`
|
||||
|
|
|
@ -30,6 +30,8 @@ type (
|
|||
StdInput string `json:"stdInput,optional"`
|
||||
ClusterType string `json:"clusterType,optional"`
|
||||
Partition string `json:"partition"`
|
||||
UserId int64 `json:"userId,optional"`
|
||||
Token string `json:"token,optional"`
|
||||
}
|
||||
|
||||
commitHpcTaskResp {
|
||||
|
|
|
@ -5,7 +5,9 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -17,8 +19,14 @@ func CommitGeneralTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
// 获取token信息
|
||||
token := r.Header.Get("Authorization")
|
||||
req.Token = token
|
||||
// 获取用户信息
|
||||
userStr := r.Header.Get("User")
|
||||
user := &models.JccUserInfo{}
|
||||
json.Unmarshal([]byte(userStr), user)
|
||||
req.UserId = user.Id
|
||||
l := cloud.NewCommitGeneralTaskLogic(r.Context(), svcCtx)
|
||||
err := l.CommitGeneralTask(&req)
|
||||
result.HttpResult(r, w, nil, err)
|
||||
|
|
|
@ -16,7 +16,6 @@ func PageListTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := core.NewPageListTaskLogic(r.Context(), svcCtx)
|
||||
resp, err := l.PageListTask(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
|
|
|
@ -5,7 +5,9 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -16,6 +18,14 @@ func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
// 获取token信息
|
||||
token := r.Header.Get("Authorization")
|
||||
req.Token = token
|
||||
// 获取用户信息
|
||||
userStr := r.Header.Get("User")
|
||||
user := &models.JccUserInfo{}
|
||||
json.Unmarshal([]byte(userStr), user)
|
||||
req.UserId = user.Id
|
||||
|
||||
l := hpc.NewCommitHpcTaskLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CommitHpcTask(&req)
|
||||
|
|
|
@ -113,6 +113,7 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
|||
clusterId, _ := strconv.ParseUint(r.ClusterId, 10, 64)
|
||||
taskCloud.AdapterId = uint(adapterId)
|
||||
taskCloud.AdapterName = adapterName
|
||||
taskCloud.UserId = req.UserId
|
||||
taskCloud.ClusterId = uint(clusterId)
|
||||
taskCloud.ClusterName = r.ClusterName
|
||||
taskCloud.Status = constants.Saved
|
||||
|
|
|
@ -142,6 +142,7 @@ type Region struct {
|
|||
|
||||
type GeneralTaskReq struct {
|
||||
Token string `json:"token,optional"`
|
||||
UserId int64 `json:"userId,optional"`
|
||||
Name string `json:"name"`
|
||||
AdapterIds []string `json:"adapterIds"`
|
||||
ClusterIds []string `json:"clusterIds"`
|
||||
|
@ -1299,6 +1300,8 @@ type CommitHpcTaskReq struct {
|
|||
StdInput string `json:"stdInput,optional"`
|
||||
ClusterType string `json:"clusterType,optional"`
|
||||
Partition string `json:"partition"`
|
||||
UserId int64 `json:"userId,optional"`
|
||||
Token string `json:"token,optional"`
|
||||
}
|
||||
|
||||
type CommitHpcTaskResp struct {
|
||||
|
|
|
@ -19,6 +19,7 @@ type TaskCloudModel struct {
|
|||
YamlString string `json:"yamlString" gorm:"not null;comment:入参"`
|
||||
Result string `json:"result" gorm:"comment:运行结果"`
|
||||
Namespace string `json:"namespace" gorm:"comment:命名空间"`
|
||||
UserId int64 `json:"userId" gorm:"comment:用户id"`
|
||||
base.BaseModel
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ type (
|
|||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy int64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime time.Time `db:"updated_time"` // 更新时间
|
||||
|
||||
UserId int64 `db:"user_id"`
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package models
|
||||
|
||||
type JccUserInfo struct {
|
||||
UserName string `json:"user_name"`
|
||||
Scope []string `json:"scope"`
|
||||
Id int64 `json:"id"`
|
||||
Exp int64 `json:"exp"`
|
||||
Authorities []string `json:"authorities"`
|
||||
Jti string `json:"jti"`
|
||||
ClientID string `json:"client_id"`
|
||||
}
|
|
@ -17,7 +17,8 @@ type EvidenceParam struct {
|
|||
func Evidence(EvidenceParam EvidenceParam) error {
|
||||
httpClient := resty.New().R()
|
||||
_, err := httpClient.SetHeader("Content-Type", "application/json").
|
||||
SetBody(&EvidenceParam).
|
||||
SetHeader("Authorization", EvidenceParam.Token).
|
||||
SetBody(&EvidenceParam.Args).
|
||||
Post(EvidenceParam.Url)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue