2024-09-04 00:50:43 +08:00
|
|
|
package importfunc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-09-04 01:12:48 +08:00
|
|
|
"encoding/base64"
|
2024-09-04 00:50:43 +08:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
mycrypto "github.com/Leufolium/test/crypto"
|
|
|
|
"github.com/Leufolium/test/dbstruct"
|
|
|
|
"github.com/Leufolium/test/mongo"
|
|
|
|
"github.com/Leufolium/test/mysql"
|
|
|
|
"github.com/Leufolium/test/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ImportZoneMemberInfo() {
|
|
|
|
fmt.Println("Start importing...")
|
|
|
|
|
|
|
|
mcli, err := mongo.NewMongo()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("mongo client init fail : %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
mysqlcli, err := mysql.NewMysql()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("mysql client init fail : %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
limit := 1000
|
|
|
|
offset := 0
|
|
|
|
|
|
|
|
streamers, err := mcli.GetStreamerList(ctx, offset, limit)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("GetStreamerListfail : %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
mids := make([]int64, 0)
|
|
|
|
for _, streamer := range streamers {
|
|
|
|
mids = append(mids, streamer.GetMid())
|
|
|
|
}
|
|
|
|
accounts, _ := mcli.GetAccountListByMids(ctx, mids)
|
|
|
|
acctMp := make(map[int64]*dbstruct.Account)
|
|
|
|
for _, acct := range accounts {
|
|
|
|
acctMp[acct.GetMid()] = acct
|
|
|
|
}
|
|
|
|
zones, _ := mcli.GetZoneListByMids(ctx, mids)
|
|
|
|
zoneMp := make(map[int64]*dbstruct.Zone)
|
|
|
|
for _, zone := range zones {
|
|
|
|
zoneMp[zone.GetMid()] = zone
|
|
|
|
}
|
|
|
|
|
|
|
|
zids := make([]int64, 0)
|
|
|
|
for _, zone := range zones {
|
|
|
|
zids = append(zids, zone.GetId())
|
|
|
|
}
|
|
|
|
|
|
|
|
zmlist, err := mysqlcli.GetZoneMemberCountGroupByZid(ctx, nil, zids)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("GetZoneMemberCountGroupByZid : %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
zmMp := make(map[int64]*dbstruct.ZoneMemberCount)
|
|
|
|
for _, zm := range zmlist {
|
|
|
|
zmMp[zm.GetZid()] = zm
|
|
|
|
}
|
|
|
|
|
2024-09-04 00:58:36 +08:00
|
|
|
mycrypto.CryptoServiceInstance().Init()
|
|
|
|
|
|
|
|
fmt.Printf("user_id\t昵称\t手机号\t空间动态数\t空间人数\n")
|
2024-09-04 00:50:43 +08:00
|
|
|
|
|
|
|
for _, streamer := range streamers {
|
|
|
|
|
|
|
|
acct, ok := acctMp[streamer.GetMid()]
|
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
userId := acct.GetUserId()
|
|
|
|
name := acct.GetName()
|
|
|
|
mobilephonestr := util.DerefString(acct.MobilePhone)
|
2024-09-04 01:12:48 +08:00
|
|
|
base64DecryptedBytes, _ := base64.StdEncoding.DecodeString(mobilephonestr)
|
|
|
|
dcrb, err := mycrypto.CryptoServiceInstance().DecryptByAES(base64DecryptedBytes)
|
2024-09-04 00:50:43 +08:00
|
|
|
if err != nil {
|
2024-09-04 01:09:05 +08:00
|
|
|
fmt.Printf("DecryptByAES : %v, mobielphonestr : %v", err, mobilephonestr)
|
2024-09-04 00:50:43 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
mobilephone := string(dcrb)
|
|
|
|
zmmtcount := int64(0)
|
|
|
|
zmbcount := int64(0)
|
|
|
|
zone, ok := zoneMp[streamer.GetMid()]
|
|
|
|
if ok {
|
|
|
|
zmmtcount = zone.GetZoneMomentCount()
|
|
|
|
zmb, ok := zmMp[zone.GetId()]
|
|
|
|
if ok {
|
|
|
|
zmbcount = zmb.GetNum()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 00:58:36 +08:00
|
|
|
fmt.Printf("%d\t%s\t%s\t%d\t%d\n", userId, name, mobilephone, zmmtcount, zmbcount)
|
2024-09-04 00:50:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("End importing...")
|
|
|
|
}
|