| @@ -158,6 +158,7 @@ type ( | |||||
| type ( | type ( | ||||
| GeneralTaskReq { | GeneralTaskReq { | ||||
| Token string `json:"token,optional"` | Token string `json:"token,optional"` | ||||
| UserId int64 `json:"userId,optional"` | |||||
| Name string `json:"name"` | Name string `json:"name"` | ||||
| AdapterIds []string `json:"adapterIds"` | AdapterIds []string `json:"adapterIds"` | ||||
| ClusterIds []string `json:"clusterIds"` | ClusterIds []string `json:"clusterIds"` | ||||
| @@ -30,6 +30,8 @@ type ( | |||||
| StdInput string `json:"stdInput,optional"` | StdInput string `json:"stdInput,optional"` | ||||
| ClusterType string `json:"clusterType,optional"` | ClusterType string `json:"clusterType,optional"` | ||||
| Partition string `json:"partition"` | Partition string `json:"partition"` | ||||
| UserId int64 `json:"userId,optional"` | |||||
| Token string `json:"token,optional"` | |||||
| } | } | ||||
| commitHpcTaskResp { | commitHpcTaskResp { | ||||
| @@ -5,7 +5,9 @@ import ( | |||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" | "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" | ||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" | "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" | ||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" | "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" | "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" | ||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | "net/http" | ||||
| ) | ) | ||||
| @@ -17,8 +19,14 @@ func CommitGeneralTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||||
| result.ParamErrorResult(r, w, err) | result.ParamErrorResult(r, w, err) | ||||
| return | return | ||||
| } | } | ||||
| // 获取token信息 | |||||
| token := r.Header.Get("Authorization") | token := r.Header.Get("Authorization") | ||||
| req.Token = token | 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) | l := cloud.NewCommitGeneralTaskLogic(r.Context(), svcCtx) | ||||
| err := l.CommitGeneralTask(&req) | err := l.CommitGeneralTask(&req) | ||||
| result.HttpResult(r, w, nil, err) | result.HttpResult(r, w, nil, err) | ||||
| @@ -16,7 +16,6 @@ func PageListTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||||
| result.ParamErrorResult(r, w, err) | result.ParamErrorResult(r, w, err) | ||||
| return | return | ||||
| } | } | ||||
| l := core.NewPageListTaskLogic(r.Context(), svcCtx) | l := core.NewPageListTaskLogic(r.Context(), svcCtx) | ||||
| resp, err := l.PageListTask(&req) | resp, err := l.PageListTask(&req) | ||||
| result.HttpResult(r, w, resp, err) | 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/logic/hpc" | ||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" | "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" | ||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" | "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" | "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" | ||||
| "k8s.io/apimachinery/pkg/util/json" | |||||
| "net/http" | "net/http" | ||||
| ) | ) | ||||
| @@ -16,6 +18,14 @@ func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||||
| result.ParamErrorResult(r, w, err) | result.ParamErrorResult(r, w, err) | ||||
| return | 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) | l := hpc.NewCommitHpcTaskLogic(r.Context(), svcCtx) | ||||
| resp, err := l.CommitHpcTask(&req) | resp, err := l.CommitHpcTask(&req) | ||||
| @@ -113,6 +113,7 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er | |||||
| clusterId, _ := strconv.ParseUint(r.ClusterId, 10, 64) | clusterId, _ := strconv.ParseUint(r.ClusterId, 10, 64) | ||||
| taskCloud.AdapterId = uint(adapterId) | taskCloud.AdapterId = uint(adapterId) | ||||
| taskCloud.AdapterName = adapterName | taskCloud.AdapterName = adapterName | ||||
| taskCloud.UserId = req.UserId | |||||
| taskCloud.ClusterId = uint(clusterId) | taskCloud.ClusterId = uint(clusterId) | ||||
| taskCloud.ClusterName = r.ClusterName | taskCloud.ClusterName = r.ClusterName | ||||
| taskCloud.Status = constants.Saved | taskCloud.Status = constants.Saved | ||||
| @@ -142,6 +142,7 @@ type Region struct { | |||||
| type GeneralTaskReq struct { | type GeneralTaskReq struct { | ||||
| Token string `json:"token,optional"` | Token string `json:"token,optional"` | ||||
| UserId int64 `json:"userId,optional"` | |||||
| Name string `json:"name"` | Name string `json:"name"` | ||||
| AdapterIds []string `json:"adapterIds"` | AdapterIds []string `json:"adapterIds"` | ||||
| ClusterIds []string `json:"clusterIds"` | ClusterIds []string `json:"clusterIds"` | ||||
| @@ -1299,6 +1300,8 @@ type CommitHpcTaskReq struct { | |||||
| StdInput string `json:"stdInput,optional"` | StdInput string `json:"stdInput,optional"` | ||||
| ClusterType string `json:"clusterType,optional"` | ClusterType string `json:"clusterType,optional"` | ||||
| Partition string `json:"partition"` | Partition string `json:"partition"` | ||||
| UserId int64 `json:"userId,optional"` | |||||
| Token string `json:"token,optional"` | |||||
| } | } | ||||
| type CommitHpcTaskResp struct { | type CommitHpcTaskResp struct { | ||||
| @@ -19,6 +19,7 @@ type TaskCloudModel struct { | |||||
| YamlString string `json:"yamlString" gorm:"not null;comment:入参"` | YamlString string `json:"yamlString" gorm:"not null;comment:入参"` | ||||
| Result string `json:"result" gorm:"comment:运行结果"` | Result string `json:"result" gorm:"comment:运行结果"` | ||||
| Namespace string `json:"namespace" gorm:"comment:命名空间"` | Namespace string `json:"namespace" gorm:"comment:命名空间"` | ||||
| UserId int64 `json:"userId" gorm:"comment:用户id"` | |||||
| base.BaseModel | base.BaseModel | ||||
| } | } | ||||
| @@ -77,7 +77,7 @@ type ( | |||||
| CreatedTime time.Time `db:"created_time"` // 创建时间 | CreatedTime time.Time `db:"created_time"` // 创建时间 | ||||
| UpdatedBy int64 `db:"updated_by"` // 更新人 | UpdatedBy int64 `db:"updated_by"` // 更新人 | ||||
| UpdatedTime time.Time `db:"updated_time"` // 更新时间 | 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 { | func Evidence(EvidenceParam EvidenceParam) error { | ||||
| httpClient := resty.New().R() | httpClient := resty.New().R() | ||||
| _, err := httpClient.SetHeader("Content-Type", "application/json"). | _, err := httpClient.SetHeader("Content-Type", "application/json"). | ||||
| SetBody(&EvidenceParam). | |||||
| SetHeader("Authorization", EvidenceParam.Token). | |||||
| SetBody(&EvidenceParam.Args). | |||||
| Post(EvidenceParam.Url) | Post(EvidenceParam.Url) | ||||
| if err != nil { | if err != nil { | ||||
| return err | return err | ||||