diff --git a/infra/conf/common.go b/infra/conf/common.go index fd6e732a..1cda2459 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -2,6 +2,7 @@ package conf import ( "encoding/json" + "fmt" "strconv" "strings" @@ -258,6 +259,18 @@ type Int32Range struct { To int32 } +func (v Int32Range) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +func (v Int32Range) String() string { + if v.Left == v.Right { + return strconv.Itoa(int(v.Left)) + } else { + return fmt.Sprintf("%d-%d", v.Left, v.Right) + } +} + func (v *Int32Range) UnmarshalJSON(data []byte) error { defer v.ensureOrder() var str string