feat: user improve
CI / changes (push) Successful in 1m31s
CI / ad (push) Successful in 32s
CI / admin (push) Successful in 26s
CI / analysis (push) Successful in 28s
CI / bff (push) Successful in 23s
CI / chore (push) Successful in 24s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 21s
CI / factory (push) Successful in 18s
CI / message (push) Successful in 18s
CI / order (push) Successful in 21s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 19s
CI / product (push) Successful in 21s
CI / record (push) Successful in 21s
CI / sale (push) Successful in 20s
CI / store (push) Successful in 25s
CI / support (push) Successful in 21s
CI / task (push) Successful in 20s
CI / user (push) Successful in 22s
CI / water (push) Successful in 20s
CI / wecom (push) Successful in 21s
CI / ws (push) Successful in 8s

This commit is contained in:
zzw
2026-10-27 13:01:24 +08:00
parent 70543fbcb0
commit b77a1f1b95
20 changed files with 1110 additions and 171 deletions
+6 -1
View File
@@ -36,6 +36,7 @@ type UploadInput struct {
Filename string
Content []byte
ContentType string
Dir string // 可选,覆盖配置 oss.dir
}
func LoadConfig() Config {
@@ -84,7 +85,11 @@ func Upload(in UploadInput) (*Result, error) {
return nil, fmt.Errorf("file too large, max %d bytes", MaxUploadBytes)
}
objectKey := buildObjectKey(cfg.Dir, in.Filename)
dir := cfg.Dir
if strings.TrimSpace(in.Dir) != "" {
dir = in.Dir
}
objectKey := buildObjectKey(dir, in.Filename)
endpoint := normalizeEndpoint(cfg.Endpoint, cfg.BucketName)
client, err := alioss.New(endpoint, cfg.AccessKeyId, cfg.AccessKeySecret)
+6 -2
View File
@@ -228,11 +228,15 @@ func ParseCustomTime(s string) (CustomTime, error) {
return ct, nil
}
// ParseDateOnly 解析 YYYY-MM-DD;空串返回零值(写入 DB 为 NULL)
// ParseDateOnly 解析 YYYY-MM-DD;兼容带时间的字符串,只取日期部分;空串返回零值(写入 DB 为 NULL)
func ParseDateOnly(s string) (CustomTime, error) {
if s == "" {
s = strings.TrimSpace(s)
if s == "" || isZeroDate(s) {
return CustomTime{}, nil
}
if len(s) >= len(time.DateOnly) {
s = s[:len(time.DateOnly)]
}
t, err := time.ParseInLocation(time.DateOnly, s, AsiaShanghai)
if err != nil {
return CustomTime{}, fmt.Errorf("invalid date format: %s", s)