123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package userAnalysis
- import (
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/util/gconv"
- )
- type (
- UserAnalysis struct {
- UserMapping map[string]BaseUserId //职位id、mongouserId对应的baseUserId
- BinPhone, BindMail map[BaseUserId]bool
- Vip, Vip15, Vip30 map[BaseUserId]bool
- Member, MemberExpire map[BaseUserId]bool
- }
- BaseUserId int64
- AnalysisRes struct {
- Name, Code string //标签名字
- Data map[BaseUserId]bool //数据
- }
- )
- func NewManager() *UserAnalysis {
- return &UserAnalysis{
- UserMapping: map[string]BaseUserId{},
- BinPhone: map[BaseUserId]bool{},
- BindMail: map[BaseUserId]bool{},
- Vip: map[BaseUserId]bool{},
- Vip15: map[BaseUserId]bool{},
- Vip30: map[BaseUserId]bool{},
- Member: map[BaseUserId]bool{},
- MemberExpire: map[BaseUserId]bool{},
- }
- }
- func (ua *UserAnalysis) LoadMapping() error {
- data, err := g.DB().Query(ctx, "SELECT mgoUserId,positionId,baseUserId FROM dwd_mgo_position")
- if err != nil {
- return err
- }
- newMapping := map[string]BaseUserId{}
- for _, m := range data.List() {
- var (
- mgoUserId = gconv.String(m["mgoUserId"])
- positionId = gconv.String(m["positionId"])
- baseUserId = BaseUserId(gconv.Int64(m["baseUserId"]))
- )
- newMapping[mgoUserId] = baseUserId
- newMapping[positionId] = baseUserId
- }
- ua.UserMapping = newMapping
- return nil
- }
|