package cloud import ( "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" "k8s.io/apimachinery/pkg/util/json" "net/http" "github.com/zeromicro/go-zero/rest/httpx" "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" ) func CommitGeneralTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GeneralTaskReq if err := httpx.Parse(r, &req); err != nil { result.ParamErrorResult(r, w, err) return } // 获取ip信息 ip := utils.GetClientIP(r) req.UserIp = ip // 获取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) resp, err := l.CommitGeneralTask(&req) result.HttpResult(r, w, resp, err) } }