Browse Source

提交任务信息修改

pull/399/head
zhangwei 10 months ago
parent
commit
c76fa0492e
11 changed files with 40 additions and 3 deletions
  1. +1
    -0
      desc/core/pcm-core.api
  2. +2
    -0
      desc/hpc/pcm-hpc.api
  3. +8
    -0
      internal/handler/cloud/commitgeneraltaskhandler.go
  4. +0
    -1
      internal/handler/core/pagelisttaskhandler.go
  5. +10
    -0
      internal/handler/hpc/commithpctaskhandler.go
  6. +1
    -0
      internal/logic/cloud/commitgeneraltasklogic.go
  7. +3
    -0
      internal/types/types.go
  8. +1
    -0
      pkg/models/cloud/task_cloud.go
  9. +1
    -1
      pkg/models/taskhpcmodel_gen.go
  10. +11
    -0
      pkg/models/userInfo.go
  11. +2
    -1
      pkg/utils/remoteUtil/BlockChain.go

+ 1
- 0
desc/core/pcm-core.api View File

@@ -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"`


+ 2
- 0
desc/hpc/pcm-hpc.api View File

@@ -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 {


+ 8
- 0
internal/handler/cloud/commitgeneraltaskhandler.go View File

@@ -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)


+ 0
- 1
internal/handler/core/pagelisttaskhandler.go View File

@@ -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)


+ 10
- 0
internal/handler/hpc/commithpctaskhandler.go View File

@@ -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)


+ 1
- 0
internal/logic/cloud/commitgeneraltasklogic.go View File

@@ -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


+ 3
- 0
internal/types/types.go View File

@@ -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 {


+ 1
- 0
pkg/models/cloud/task_cloud.go View File

@@ -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
} }




+ 1
- 1
pkg/models/taskhpcmodel_gen.go View File

@@ -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"`
} }
) )




+ 11
- 0
pkg/models/userInfo.go View File

@@ -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"`
}

+ 2
- 1
pkg/utils/remoteUtil/BlockChain.go View File

@@ -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


Loading…
Cancel
Save