detect.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package models
  2. import (
  3. "annual-lottery2/models/model"
  4. "annual-lottery2/utils"
  5. "strings"
  6. "github.com/astaxie/beego"
  7. )
  8. // UserFilters 用户过滤
  9. func UserFilters(lvl string) ([]model.TaUser, string) {
  10. cf := "./conf/test.conf"
  11. usrs := make([]model.TaUser, 0)
  12. notIn := make([]string, 0)
  13. beego.Info("--------> 1")
  14. if !utils.FileExists(cf) {
  15. return usrs, ""
  16. }
  17. beego.Info("--------> 2")
  18. conf, err := utils.GetConfig(cf)
  19. if err != nil {
  20. return usrs, ""
  21. }
  22. beego.Info("--------> 3")
  23. pls := conf.String("conf")
  24. if pls == "" {
  25. return usrs, ""
  26. }
  27. for _, pl := range strings.Split(pls, ",") {
  28. for _, us := range strings.Split(conf.DefaultString(pl+"::us", ""), ",") {
  29. if us == "" {
  30. continue
  31. }
  32. usArr := strings.Split(us, "-")
  33. if pl == lvl {
  34. usrs = append(usrs, model.TaUser{
  35. UserName: usArr[1],
  36. UserOrg: usArr[0],
  37. })
  38. } else {
  39. notIn = append(notIn, "user_name = '"+usArr[1]+"' and user_org = '"+usArr[0]+"'")
  40. }
  41. }
  42. }
  43. notExists := ""
  44. if len(notIn) > 0 {
  45. notExists = "select * from ta_user o where o.user_id = t.user_id and ((" + strings.Join(notIn, ") or (") + "))"
  46. }
  47. return usrs, notExists
  48. }