package main import ( "fmt" qu "qfw/util" "unicode/utf8" ) func projectcodeFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) { projectcode := qu.ObjToString(tmp["projectcode"]) reason,desc:=fmt.Sprintf("%d初始分",score),"" /*错误项*/ l := utf8.RuneCountInString(projectcode) if l > 19 || l < 5 { return map[string]interface{}{ "score":int64(0), "reason":"错误:长度", } } if isRegTimeDateCode(projectcode) { return map[string]interface{}{ "score":int64(0), "reason":"错误:日期格式", } } if codeUnConReg.MatchString(projectcode) { return map[string]interface{}{ "score":int64(0), "reason":"错误:黑名单", } } if !isAlphanumeric(projectcode) { return map[string]interface{}{ "score":int64(0), "reason":"错误:不含字母数字", } } /*减分项 "符号过多": 1, "连续中文": 2, */ countArr := isCharCount(projectcode) if countArr[3] > 6 { desc = "符号过多" reason+="~"+desc score -= qu.Int64All(projectcode_score[desc]) } //连续中文长度超过X个 if codeUnLenReg.MatchString(projectcode) { desc = "连续中文" reason+="~"+desc score -= qu.Int64All(projectcode_score[desc]) } return map[string]interface{}{ "score":score, "reason":reason, } }