示例#1
0
func getEnumValue(enumStr string, t string) []EnumValue {
	if enumStr == "" {
		return nil
	}
	enumList := strings.Split(enumStr, ",")
	var retList []EnumValue
	for _, v := range enumList {
		value := strings.TrimSpace(v)
		retList = append(retList, EnumValue{value, value, lang.GetLabel(value)})
	}
	return retList
}
示例#2
0
func transProductMap(oldMap map[string]interface{}) map[string]interface{} {
	var retMap = make(map[string]interface{}, len(oldMap)+1)
	for key, value := range oldMap {
		switch key {
		case s.Category:
			retMap[key] = lang.GetLabel(value.(string))
		default:
			retMap[key] = value
		}
	}
	productSn, _ := retMap[s.Sn]
	retMap[s.Supplier+s.Ext+s.Enum] = getSupplierList(productSn.(string))

	return retMap
}
示例#3
0
func transPurchaseMap(oldMap orm.Params) t.ItemMap {
	var retMap = make(t.ItemMap, 0)
	for key, value := range oldMap {
		retMap[strings.ToLower(key)] = value
	}
	if userName, ok := oldMap["user_name"]; ok {
		retMap["buyer"] = userName
	}
	category, _ := retMap[s.Category].(string)
	retMap[s.Category] = lang.GetLabel(category)
	if supplierSn, ok := retMap[s.Supplier]; ok && !u.IsNullStr(supplierSn) {
		if supplierMap, sok := supplierMgr.Get(supplierSn.(string)); sok {
			retMap[s.Supplier+s.EName] = u.GetStringValue(supplierMap, s.Name)
			retMap[s.Supplier+s.EKey] = u.GetStringValue(supplierMap, s.Keyword)
		}
	}
	return retMap
}
示例#4
0
func transList(oItemDef itemDef.ItemDef, resultMaps []map[string]interface{}) []map[string]interface{} {
	if len(resultMaps) < 0 {
		return resultMaps
	}
	retList := make([]map[string]interface{}, len(resultMaps))
	neetTransMap := oItemDef.GetNeedTrans()
	for idx, oldMap := range resultMaps {
		var retMap = make(map[string]interface{}, len(oldMap))
		for key, value := range oldMap {
			if _, ok := neetTransMap[key]; ok {
				retMap[key] = lang.GetLabel(value.(string))
			} else {
				retMap[key] = value
			}
		}
		retList[idx] = retMap
	}
	return retList
}