scoreprojectcode.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package main
  2. import (
  3. "fmt"
  4. qu "qfw/util"
  5. "unicode/utf8"
  6. )
  7. func projectcodeFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) {
  8. projectcode := qu.ObjToString(tmp["projectcode"])
  9. reason,desc:=fmt.Sprintf("%d初始分",score),""
  10. /*错误项*/
  11. l := utf8.RuneCountInString(projectcode)
  12. if l > 19 || l < 5 {
  13. return map[string]interface{}{
  14. "score":int64(0),
  15. "reason":"错误:长度",
  16. }
  17. }
  18. if isRegTimeDateCode(projectcode) {
  19. return map[string]interface{}{
  20. "score":int64(0),
  21. "reason":"错误:日期格式",
  22. }
  23. }
  24. if codeUnConReg.MatchString(projectcode) {
  25. return map[string]interface{}{
  26. "score":int64(0),
  27. "reason":"错误:黑名单",
  28. }
  29. }
  30. if !isAlphanumeric(projectcode) {
  31. return map[string]interface{}{
  32. "score":int64(0),
  33. "reason":"错误:不含字母数字",
  34. }
  35. }
  36. /*减分项
  37. "符号过多": 1,
  38. "连续中文": 2,
  39. */
  40. countArr := isCharCount(projectcode)
  41. if countArr[3] > 6 {
  42. desc = "符号过多"
  43. reason+="~"+desc
  44. score -= qu.Int64All(projectcode_score[desc])
  45. }
  46. //连续中文长度超过X个
  47. if codeUnLenReg.MatchString(projectcode) {
  48. desc = "连续中文"
  49. reason+="~"+desc
  50. score -= qu.Int64All(projectcode_score[desc])
  51. }
  52. return map[string]interface{}{
  53. "score":score,
  54. "reason":reason,
  55. }
  56. }