func makeFields(oItemDef itemDef.ItemDef, names []string) itemDef.ItemDef { fields := make([]itemDef.Field, len(names)) fieldMap := oItemDef.GetFieldMap() for idx, name := range names { if field, ok := fieldMap[name]; ok { fields[idx] = field } else { beego.Error("Field not found", name, idx) } } oItemDef.Fields = fields return oItemDef }
func (this *BaseController) GetQueryParamFromJsonMap(requestMap map[string]interface{}, oItemDef itemDef.ItemDef) map[string]interface{} { queryParams := make(t.Params, 0) fieldMap := oItemDef.GetFieldMap() for k, v := range requestMap { if field, ok := fieldMap[k]; ok { if fv, fok := field.GetCheckedValue(v); fok { queryParams[k] = fv } else { beego.Error(fmt.Sprintf("Check param[%s]value %v error", k, v)) } } else { beego.Error(fmt.Sprintf("Check param[%s]value %v error no such field", k, v)) } } return queryParams }