mirror of
https://gitee.com/johng/gf
synced 2026-07-06 05:42:20 +08:00
improve function *Struct for ghttp.Request
This commit is contained in:
@ -189,6 +189,9 @@ func (r *Request) GetFormMapStrVar(kvMap ...map[string]interface{}) map[string]*
|
||||
// The optional parameter <mapping> is used to specify the key to attribute mapping.
|
||||
func (r *Request) GetFormStruct(pointer interface{}, mapping ...map[string]string) error {
|
||||
r.parseForm()
|
||||
if len(r.formMap) == 0 {
|
||||
return nil
|
||||
}
|
||||
return gconv.StructDeep(r.formMap, pointer, mapping...)
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +193,11 @@ func (r *Request) GetQueryMapStrVar(kvMap ...map[string]interface{}) map[string]
|
||||
// attribute mapping.
|
||||
func (r *Request) GetQueryStruct(pointer interface{}, mapping ...map[string]string) error {
|
||||
r.parseQuery()
|
||||
return gconv.StructDeep(r.GetQueryMap(), pointer, mapping...)
|
||||
m := r.GetQueryMap()
|
||||
if len(m) == 0 {
|
||||
return nil
|
||||
}
|
||||
return gconv.StructDeep(m, pointer, mapping...)
|
||||
}
|
||||
|
||||
// GetQueryToStruct is alias of GetQueryStruct. See GetQueryStruct.
|
||||
|
||||
@ -267,7 +267,11 @@ func (r *Request) GetRequestMapStrVar(kvMap ...map[string]interface{}) map[strin
|
||||
// the parameter <pointer> is a pointer to the struct object.
|
||||
// The optional parameter <mapping> is used to specify the key to attribute mapping.
|
||||
func (r *Request) GetRequestStruct(pointer interface{}, mapping ...map[string]string) error {
|
||||
return gconv.StructDeep(r.GetRequestMap(), pointer, mapping...)
|
||||
m := r.GetRequestMap()
|
||||
if len(m) == 0 {
|
||||
return nil
|
||||
}
|
||||
return gconv.StructDeep(m, pointer, mapping...)
|
||||
}
|
||||
|
||||
// GetRequestToStruct is alias of GetRequestStruct. See GetRequestStruct.
|
||||
|
||||
Reference in New Issue
Block a user