refactor(handler,server): disable SubmitApplication endpoint, replaced by POST /tasks

- Comment out SubmitApplication handler method

- Comment out route registration in server.go (interface + router + placeholder)

- Comment out related handler tests

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
dailz
2026-04-16 15:15:55 +08:00
parent 36d842350c
commit 7c374f4fd5
4 changed files with 20 additions and 8 deletions

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"strconv"
"strings"
"gcy_hpc_server/internal/model"
"gcy_hpc_server/internal/server"
@@ -139,7 +138,8 @@ func (h *ApplicationHandler) DeleteApplication(c *gin.Context) {
server.OK(c, gin.H{"message": "application deleted"})
}
func (h *ApplicationHandler) SubmitApplication(c *gin.Context) {
// [已禁用] 前端已全部迁移到 POST /tasks 接口,此端点不再使用。
/* func (h *ApplicationHandler) SubmitApplication(c *gin.Context) {
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
if err != nil {
h.logger.Warn("invalid application id for submit", zap.String("id", c.Param("id")))
@@ -171,4 +171,4 @@ func (h *ApplicationHandler) SubmitApplication(c *gin.Context) {
}
h.logger.Info("application submitted", zap.Int64("id", id), zap.Int32("job_id", resp.JobID))
server.Created(c, resp)
}
} */

View File

@@ -46,7 +46,7 @@ func setupApplicationRouter(h *ApplicationHandler) *gin.Engine {
apps.GET("/:id", h.GetApplication)
apps.PUT("/:id", h.UpdateApplication)
apps.DELETE("/:id", h.DeleteApplication)
apps.POST("/:id/submit", h.SubmitApplication)
// apps.POST("/:id/submit", h.SubmitApplication) // [已禁用] 已被 POST /tasks 取代
return r
}
@@ -344,6 +344,8 @@ func TestDeleteApplication_Success(t *testing.T) {
// ---- Submit Tests ----
// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉
/*
func TestSubmitApplication_Success(t *testing.T) {
slurmHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
@@ -378,7 +380,10 @@ func TestSubmitApplication_Success(t *testing.T) {
t.Fatalf("expected 201, got %d: %s", w2.Code, w2.Body.String())
}
}
*/
// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉
/*
func TestSubmitApplication_AppNotFound(t *testing.T) {
slurmHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
@@ -398,7 +403,10 @@ func TestSubmitApplication_AppNotFound(t *testing.T) {
t.Fatalf("expected 404, got %d: %s", w.Code, w.Body.String())
}
}
*/
// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉
/*
func TestSubmitApplication_ValidationFail(t *testing.T) {
slurmHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
@@ -430,6 +438,7 @@ func TestSubmitApplication_ValidationFail(t *testing.T) {
t.Fatalf("expected 400, got %d: %s", w2.Code, w2.Body.String())
}
}
*/
// ---- Logging Tests ----
@@ -529,6 +538,8 @@ func TestApplicationLogging_DeleteSuccess_LogsInfoWithID(t *testing.T) {
}
}
// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉
/*
func TestApplicationLogging_SubmitSuccess_LogsInfoWithID(t *testing.T) {
core, recorded := observer.New(zapcore.DebugLevel)
l := zap.New(core)
@@ -581,6 +592,7 @@ func TestApplicationLogging_SubmitSuccess_LogsInfoWithID(t *testing.T) {
t.Fatal("expected 'application submitted' log message")
}
}
*/
func TestApplicationLogging_CreateBadRequest_LogsWarn(t *testing.T) {
h, _, recorded := setupApplicationHandlerWithObserver()

View File

@@ -31,7 +31,7 @@ type ApplicationHandler interface {
GetApplication(c *gin.Context)
UpdateApplication(c *gin.Context)
DeleteApplication(c *gin.Context)
SubmitApplication(c *gin.Context)
// SubmitApplication(c *gin.Context) // [已禁用] 已被 POST /tasks 取代
}
type UploadHandler interface {
@@ -93,7 +93,7 @@ func NewRouter(jobH JobHandler, clusterH ClusterHandler, appH ApplicationHandler
apps.GET("/:id", appH.GetApplication)
apps.PUT("/:id", appH.UpdateApplication)
apps.DELETE("/:id", appH.DeleteApplication)
apps.POST("/:id/submit", appH.SubmitApplication)
// apps.POST("/:id/submit", appH.SubmitApplication) // [已禁用] 已被 POST /tasks 取代
files := v1.Group("/files")
@@ -164,7 +164,7 @@ func registerPlaceholderRoutes(v1 *gin.RouterGroup) {
apps.GET("/:id", notImplemented)
apps.PUT("/:id", notImplemented)
apps.DELETE("/:id", notImplemented)
apps.POST("/:id/submit", notImplemented)
// apps.POST("/:id/submit", notImplemented) // [已禁用] 已被 POST /tasks 取代
files := v1.Group("/files")

View File

@@ -32,7 +32,7 @@ func TestAllRoutesRegistered(t *testing.T) {
{"GET", "/api/v1/applications/:id"},
{"PUT", "/api/v1/applications/:id"},
{"DELETE", "/api/v1/applications/:id"},
{"POST", "/api/v1/applications/:id/submit"},
// {"POST", "/api/v1/applications/:id/submit"}, // [已禁用] 已被 POST /tasks 取代
}
routeMap := map[string]bool{}