init push

This commit is contained in:
2026-07-16 22:16:45 +07:00
commit 8b068bdb10
1021 changed files with 332816 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package dto
import (
"bytes"
"encoding/json"
)
// NullInt allows PATCH semantics:
// - field omitted => Set=false (no change)
// - value null => Set=true, Valid=false (set DB NULL)
// - value number => Set=true, Valid=true, Value=<number>
type NullInt struct {
Set bool
Valid bool
Value int
}
func (n *NullInt) UnmarshalJSON(data []byte) error {
n.Set = true
trimmed := bytes.TrimSpace(data)
if bytes.Equal(trimmed, []byte("null")) {
n.Valid = false
n.Value = 0
return nil
}
var v int
if err := json.Unmarshal(trimmed, &v); err != nil {
return err
}
n.Valid = true
n.Value = v
return nil
}