示例#1
0
// TODO
func (o TemplateManager) GetLayerForListTemplate(sId int, listTemplate ListTemplate) map[string]interface{} {
	_, db := global.GetConnection(sId)

	result := map[string]interface{}{}
	resultLi := map[string]interface{}{}
	layerManager := layer.GetInstance()

	listTemplateIterator := ListTemplateIterator{}
	var iterateResult interface{} = ""
	listTemplateIterator.IterateTemplateColumn(listTemplate, &iterateResult, func(column Column, iterateResult *interface{}) {
		if column.Dictionary != "" {
			layerMap := layerManager.GetLayerBySession(sId, db, column.Dictionary)
			if layerMap != nil {
				items := layerMap["items"]
				if items != nil {
					dictMap := map[string]interface{}{}
					for _, item := range items.([]map[string]interface{}) {
						dictMap[fmt.Sprint(item["code"])] = item
					}
					result[column.Dictionary] = dictMap
					resultLi[column.Dictionary] = items
				} else {
					result[column.Dictionary] = map[string]interface{}{}
					resultLi[column.Dictionary] = []interface{}{}
				}
			}
		}
	})

	return map[string]interface{}{
		"layerBo":   result,
		"layerBoLi": resultLi,
	}
}
示例#2
0
func (o TemplateManager) GetLayerForFormTemplate(sId int, formTemplate FormTemplate) map[string]interface{} {
	_, db := global.GetConnection(sId)

	result := map[string]interface{}{}
	resultLi := map[string]interface{}{}
	layerManager := layer.GetInstance()
	for _, item := range formTemplate.FormElemLi {
		if item.XMLName.Local == "column-model" {
			for _, column := range item.ColumnModel.ColumnLi {
				if column.Dictionary != "" {
					layerMap := layerManager.GetLayerBySession(sId, db, column.Dictionary)
					if layerMap != nil {
						items := layerMap["items"]
						if items != nil {
							dictMap := map[string]interface{}{}
							for _, item := range items.([]map[string]interface{}) {
								dictMap[fmt.Sprint(item["code"])] = item
							}
							result[column.Dictionary] = dictMap
							resultLi[column.Dictionary] = items
						} else {
							result[column.Dictionary] = map[string]interface{}{}
							resultLi[column.Dictionary] = []interface{}{}
						}
					}
				}
			}
		}
	}

	return map[string]interface{}{
		"layerBo":   result,
		"layerBoLi": resultLi,
	}
}