|
|
|
@ -94,6 +94,11 @@ func (in Input) Int16(k string) (v int16) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (in Input) String(k string) (v string) { |
|
|
|
func (in Input) String(k string) (v string) { |
|
|
|
|
|
|
|
if k == "pt" && in != nil { |
|
|
|
|
|
|
|
if _, ok := in[k]; !ok { |
|
|
|
|
|
|
|
in[k] = KPriceTypeDefault |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
v, err := cast.ToStringE(in.get(k, "string")) |
|
|
|
v, err := cast.ToStringE(in.get(k, "string")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
panic(fmt.Errorf("input string parse error: %s", k)) |
|
|
|
panic(fmt.Errorf("input string parse error: %s", k)) |
|
|
|
@ -109,6 +114,15 @@ func (in Input) Time(k string) (v time.Time) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (in Input) PriceType(k ...string) (v KPriceType) { |
|
|
|
|
|
|
|
key := "pt" |
|
|
|
|
|
|
|
if len(k) > 0 { |
|
|
|
|
|
|
|
key = k[0] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
v = KPriceType(in.String(key)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (in Input) Decode(k string, point any) { |
|
|
|
func (in Input) Decode(k string, point any) { |
|
|
|
t := fmt.Sprintf("%T", point) |
|
|
|
t := fmt.Sprintf("%T", point) |
|
|
|
v := in.get(k, t) |
|
|
|
v := in.get(k, t) |
|
|
|
@ -143,6 +157,7 @@ const ( |
|
|
|
InputTypeInt |
|
|
|
InputTypeInt |
|
|
|
InputTypeUInt |
|
|
|
InputTypeUInt |
|
|
|
InputTypeTime |
|
|
|
InputTypeTime |
|
|
|
|
|
|
|
InputTypeKPriceType |
|
|
|
InputTypeUFloats // float数组
|
|
|
|
InputTypeUFloats // float数组
|
|
|
|
InputTypeUFloats2D // float二维数组
|
|
|
|
InputTypeUFloats2D // float二维数组
|
|
|
|
InputTypeSelect // 单选
|
|
|
|
InputTypeSelect // 单选
|
|
|
|
@ -154,6 +169,7 @@ type InputArg struct { |
|
|
|
Desc string `json:"desc"` |
|
|
|
Desc string `json:"desc"` |
|
|
|
Type InputType `json:"type"` // 参数类型
|
|
|
|
Type InputType `json:"type"` // 参数类型
|
|
|
|
Options []InputOption `json:"options"` // 单选/多选选项列表
|
|
|
|
Options []InputOption `json:"options"` // 单选/多选选项列表
|
|
|
|
|
|
|
|
Default any `json:"default"` // 默认值 TODO 构造context前将默认值置入input
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type InputOption struct { |
|
|
|
type InputOption struct { |
|
|
|
|