This commit is contained in:
parent
7c41247a04
commit
d8ccefd89b
84
cmd/main.go
84
cmd/main.go
|
@ -25,7 +25,7 @@ func main() {
|
|||
}
|
||||
|
||||
ctx := context.Background()
|
||||
mids1 := []int64{
|
||||
mids := []int64{
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
|
@ -343,9 +343,6 @@ func main() {
|
|||
195763,
|
||||
197811,
|
||||
199188,
|
||||
}
|
||||
|
||||
mids2 := []int64{
|
||||
202826,
|
||||
204372,
|
||||
205940,
|
||||
|
@ -644,62 +641,47 @@ func main() {
|
|||
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 {
|
||||
fmt.Printf("Open File Err : %v", err)
|
||||
}
|
||||
defer outfile1.Close()
|
||||
writer1 := bufio.NewWriter(outfile1)
|
||||
defer outfile.Close()
|
||||
writer := bufio.NewWriter(outfile)
|
||||
|
||||
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)
|
||||
zoneMp := make(map[int64]*dbstruct.Zone, 0)
|
||||
for _, zone := range zones {
|
||||
zoneMp[zone.GetMid()] = zone
|
||||
}
|
||||
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)
|
||||
for _, account := range accounts {
|
||||
base64DecryptedBytes, _ := base64.StdEncoding.DecodeString(*account.MobilePhone)
|
||||
phone, err := cryptoService.DecryptByAES(base64DecryptedBytes)
|
||||
if err != nil {
|
||||
fmt.Printf("GetAccountListByMids fail, err :%v\n", err)
|
||||
fmt.Printf("DecryptByAES err :%v\n", err)
|
||||
}
|
||||
|
||||
zones, err := client.GetZoneListByMids(ctx, mids)
|
||||
if err != nil {
|
||||
fmt.Printf("GetZoneListByMids fail, err :%v\n", err)
|
||||
}
|
||||
|
||||
zoneMp := make(map[int64]*dbstruct.Zone, 0)
|
||||
for _, zone := range zones {
|
||||
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)
|
||||
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)
|
||||
fmt.Printf("%v\n", str)
|
||||
writer.WriteString(str)
|
||||
}
|
||||
|
||||
fmt.Println("End importing...")
|
||||
|
|
Loading…
Reference in New Issue