123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- 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,
- }
- }
|