This commit is contained in:
Leufolium 2024-07-28 18:40:29 +08:00
parent 7c41247a04
commit d8ccefd89b
1 changed files with 33 additions and 51 deletions

View File

@ -25,7 +25,7 @@ func main() {
} }
ctx := context.Background() ctx := context.Background()
mids1 := []int64{ mids := []int64{
3, 3,
4, 4,
5, 5,
@ -343,9 +343,6 @@ func main() {
195763, 195763,
197811, 197811,
199188, 199188,
}
mids2 := []int64{
202826, 202826,
204372, 204372,
205940, 205940,
@ -644,62 +641,47 @@ func main() {
460716, 460716,
} }
outfile1, err := os.OpenFile("/app/dataprep/outfile1.txt", os.O_WRONLY|os.O_CREATE, 0666) accounts, err := client.GetAccountListByMids(ctx, mids)
if err != nil {
fmt.Printf("GetAccountListByMids fail, err :%v\n", err)
}
zones, err := client.GetZoneListByMids(ctx, mids)
if err != nil {
fmt.Printf("GetZoneListByMids fail, err :%v\n", err)
}
outfilePath := "/app/dataprep/outfile.txt"
outfile, err := os.OpenFile(outfilePath, os.O_WRONLY|os.O_CREATE, 0666)
if err != nil { if err != nil {
fmt.Printf("Open File Err : %v", err) fmt.Printf("Open File Err : %v", err)
} }
defer outfile1.Close() defer outfile.Close()
writer1 := bufio.NewWriter(outfile1) writer := bufio.NewWriter(outfile)
outfile2, err := os.OpenFile("/app/dataprep/outfile2.txt", os.O_WRONLY|os.O_CREATE, 0666) zoneMp := make(map[int64]*dbstruct.Zone, 0)
if err != nil { for _, zone := range zones {
fmt.Printf("Open File Err : %v", err) zoneMp[zone.GetMid()] = zone
} }
defer outfile2.Close()
writer2 := bufio.NewWriter(outfile2)
midss := [][]int64{mids1, mids2} for _, account := range accounts {
for i, mids := range midss { base64DecryptedBytes, _ := base64.StdEncoding.DecodeString(*account.MobilePhone)
var writer *bufio.Writer phone, err := cryptoService.DecryptByAES(base64DecryptedBytes)
if i == 0 {
writer = writer1
} else {
writer = writer2
}
accounts, err := client.GetAccountListByMids(ctx, mids)
if err != nil { if err != nil {
fmt.Printf("GetAccountListByMids fail, err :%v\n", err) fmt.Printf("DecryptByAES err :%v\n", err)
} }
phoneStr := string(phone)
zones, err := client.GetZoneListByMids(ctx, mids) mid := account.GetMid()
if err != nil { name := account.GetName()
fmt.Printf("GetZoneListByMids fail, err :%v\n", err) userId := account.GetUserId()
} count := int64(0)
zone, ok := zoneMp[mid]
zoneMp := make(map[int64]*dbstruct.Zone, 0) if ok {
for _, zone := range zones { count = zone.GetZoneMomentCount()
zoneMp[zone.GetMid()] = zone
}
for _, account := range accounts {
base64DecryptedBytes, _ := base64.StdEncoding.DecodeString(*account.MobilePhone)
phone, err := cryptoService.DecryptByAES(base64DecryptedBytes)
if err != nil {
fmt.Printf("DecryptByAES err :%v\n", err)
}
fmt.Printf("phone: %v\n", string(phone))
phoneStr := string(phone)
mid := account.GetMid()
name := account.GetName()
userId := account.GetUserId()
count := int64(0)
zone, ok := zoneMp[mid]
if ok {
count = zone.GetZoneMomentCount()
}
str := fmt.Sprintf("%v %v %v %v %v\n", mid, name, userId, phoneStr, count)
writer.WriteString(str)
} }
str := fmt.Sprintf("%v %v %v %v %v\n", mid, name, userId, phoneStr, count)
fmt.Printf("%v\n", str)
writer.WriteString(str)
} }
fmt.Println("End importing...") fmt.Println("End importing...")