package util import ( "github.com/shopspring/decimal" qu "qfw/util" "reflect" "strconv" "strings" ) var Fields = map[string]interface{}{ "publishtime": 1, "detail": 1, "contenthtml": 1, "title": 1, "href": 1, "competehref": 1, "area": 1, "city": 1, "district": 1, "site": 1, "channel": 1, "spidercode": 1, "jsondata": 1, "_d": 1, "iscompete": 1, //由爬虫决定 "comeintime": 1, "projectinfo": 1, "T": 1, "dataging": 1, "infoformat": 1, //"publishdept": 1, //"type": 1, } const GTEID = "5a862f0640d2d9bbe88e3cec" //处理因前后端交互,字段类型转换 func FormatFields(tmp map[string]interface{}) { for k, v := range tmp { if k == "dataging" || k == "infoformat" { tmp[k] = qu.IntAll(v) } else if strings.HasSuffix(k, "time") { //处理时间字段 tmp[k] = qu.Int64All(v) } else if k == "budget" || k == "bidamount" { tmp[k] = qu.Float64All(v) } } } /** * 前端科学计数法处理 */ func FormatNumber(tmp map[string]interface{}) { for k, v := range tmp { if reflect.TypeOf(v).Name() == reflect.Float64.String() { num, _ := decimal.NewFromString(strconv.FormatFloat(qu.Float64All(v), 'e', -1, 64)) tmp[k], _ = num.Float64() } } }