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