refactor: migrate to xorm

This commit is contained in:
2025-06-10 14:12:40 +03:00
parent 65ab4de561
commit e259184a89
19 changed files with 261 additions and 481 deletions

View File

@ -80,20 +80,8 @@ func (d *Decoder) DecodeVar(name string, val any) error {
dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
WeaklyTypedInput: true,
DecodeHook: mapstructure.DecodeHookFuncValue(func(from, to reflect.Value) (interface{}, error) {
if strings.Contains(to.Type().String(), "db.JSON") {
valType := to.FieldByName("Val").Type()
if !from.Type().AssignableTo(valType) {
return nil, InvalidTypeError{name, from.Type().String(), valType.String()}
}
to.FieldByName("Val").Set(from)
return to, nil
}
return from.Interface(), nil
}),
Result: val,
TagName: "sh",
Result: val,
TagName: "sh",
})
if err != nil {
return err