예제 #1
0
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
}
예제 #2
0
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
}