From 347b0e12297887f86351eead4846d85f16c7a82b Mon Sep 17 00:00:00 2001 From: dailz Date: Fri, 10 Apr 2026 09:25:46 +0800 Subject: [PATCH] fix: remove redundant binding tags and clarify logger compress logic - Remove binding:"required" from model fields that are manually validated in handlers. - Add parentheses to logger compress default to clarify operator precedence. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- internal/logger/logger.go | 2 +- internal/model/job.go | 2 +- internal/model/template.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 5a47d81..ed92466 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -47,7 +47,7 @@ func NewLogger(cfg config.LogConfig) (*zap.Logger, error) { maxSize := applyDefaultInt(cfg.MaxSize, 100) maxBackups := applyDefaultInt(cfg.MaxBackups, 5) maxAge := applyDefaultInt(cfg.MaxAge, 30) - compress := cfg.Compress || cfg.MaxSize == 0 && cfg.MaxBackups == 0 && cfg.MaxAge == 0 + compress := cfg.Compress || (cfg.MaxSize == 0 && cfg.MaxBackups == 0 && cfg.MaxAge == 0) lj := &lumberjack.Logger{ Filename: cfg.FilePath, diff --git a/internal/model/job.go b/internal/model/job.go index f42e633..8fbe41c 100644 --- a/internal/model/job.go +++ b/internal/model/job.go @@ -2,7 +2,7 @@ package model // SubmitJobRequest is the API request for submitting a job. type SubmitJobRequest struct { - Script string `json:"script" binding:"required"` + Script string `json:"script"` Partition string `json:"partition,omitempty"` QOS string `json:"qos,omitempty"` CPUs int32 `json:"cpus,omitempty"` diff --git a/internal/model/template.go b/internal/model/template.go index 5e8d2e5..f19dfb1 100644 --- a/internal/model/template.go +++ b/internal/model/template.go @@ -22,9 +22,9 @@ func (JobTemplate) TableName() string { return "job_templates" } // CreateTemplateRequest is the API request for creating a template. type CreateTemplateRequest struct { - Name string `json:"name" binding:"required"` + Name string `json:"name"` Description string `json:"description,omitempty"` - Script string `json:"script" binding:"required"` + Script string `json:"script"` Partition string `json:"partition,omitempty"` QOS string `json:"qos,omitempty"` CPUs int `json:"cpus,omitempty"`