pcm-coordinator/internal/handler/cloud/commitgeneraltaskhandler.go

42 lines
1.2 KiB
Go
Raw Normal View History

package cloud
import (
2025-08-15 17:36:05 +08:00
"net/http"
2025-01-15 09:39:40 +08:00
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
2025-02-17 21:53:56 +08:00
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
2025-01-15 09:39:40 +08:00
"k8s.io/apimachinery/pkg/util/json"
2025-06-18 19:12:17 +08:00
"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) {
2025-01-02 17:47:36 +08:00
var req types.GeneralTaskReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
2025-02-17 19:18:17 +08:00
// 获取ip信息
2025-02-17 21:53:56 +08:00
ip := utils.GetClientIP(r)
req.UserIp = ip
2025-01-15 09:39:40 +08:00
// 获取token信息
2025-01-02 17:47:36 +08:00
token := r.Header.Get("Authorization")
req.Token = token
2025-01-15 09:39:40 +08:00
// 获取用户信息
userStr := r.Header.Get("User")
user := &models.JccUserInfo{}
json.Unmarshal([]byte(userStr), user)
req.UserId = user.Id
2025-08-15 17:36:05 +08:00
req.UserName = user.UserName
l := cloud.NewCommitGeneralTaskLogic(r.Context(), svcCtx)
2025-06-18 19:12:17 +08:00
resp, err := l.CommitGeneralTask(&req)
result.HttpResult(r, w, resp, err)
}
}