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,28 +641,6 @@ func main() {
460716, 460716,
} }
outfile1, err := os.OpenFile("/app/dataprep/outfile1.txt", os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
fmt.Printf("Open File Err : %v", err)
}
defer outfile1.Close()
writer1 := bufio.NewWriter(outfile1)
outfile2, err := os.OpenFile("/app/dataprep/outfile2.txt", os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
fmt.Printf("Open File Err : %v", err)
}
defer outfile2.Close()
writer2 := bufio.NewWriter(outfile2)
midss := [][]int64{mids1, mids2}
for i, mids := range midss {
var writer *bufio.Writer
if i == 0 {
writer = writer1
} else {
writer = writer2
}
accounts, err := client.GetAccountListByMids(ctx, mids) accounts, err := client.GetAccountListByMids(ctx, mids)
if err != nil { if err != nil {
fmt.Printf("GetAccountListByMids fail, err :%v\n", err) fmt.Printf("GetAccountListByMids fail, err :%v\n", err)
@ -676,6 +651,14 @@ func main() {
fmt.Printf("GetZoneListByMids fail, err :%v\n", err) 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 {
fmt.Printf("Open File Err : %v", err)
}
defer outfile.Close()
writer := bufio.NewWriter(outfile)
zoneMp := make(map[int64]*dbstruct.Zone, 0) zoneMp := make(map[int64]*dbstruct.Zone, 0)
for _, zone := range zones { for _, zone := range zones {
zoneMp[zone.GetMid()] = zone zoneMp[zone.GetMid()] = zone
@ -687,7 +670,6 @@ func main() {
if err != nil { if err != nil {
fmt.Printf("DecryptByAES err :%v\n", err) fmt.Printf("DecryptByAES err :%v\n", err)
} }
fmt.Printf("phone: %v\n", string(phone))
phoneStr := string(phone) phoneStr := string(phone)
mid := account.GetMid() mid := account.GetMid()
name := account.GetName() name := account.GetName()
@ -698,9 +680,9 @@ func main() {
count = zone.GetZoneMomentCount() count = zone.GetZoneMomentCount()
} }
str := fmt.Sprintf("%v %v %v %v %v\n", mid, name, userId, phoneStr, count) str := fmt.Sprintf("%v %v %v %v %v\n", mid, name, userId, phoneStr, count)
fmt.Printf("%v\n", str)
writer.WriteString(str) writer.WriteString(str)
} }
}
fmt.Println("End importing...") fmt.Println("End importing...")
} }