dtp/cmd/main.go

38 lines
723 B
Go
Raw Normal View History

2023-12-24 15:29:12 +08:00
package main
import (
"context"
"fmt"
2024-06-13 13:02:43 +08:00
"strings"
2023-12-24 15:29:12 +08:00
2024-06-13 13:02:43 +08:00
"github.com/Leufolium/test/es"
"github.com/mozillazg/go-pinyin"
2023-12-24 15:29:12 +08:00
)
func main() {
fmt.Println("Start importing...")
2024-06-13 13:02:43 +08:00
client, err := es.NewElasticSearch()
2023-12-24 15:29:12 +08:00
if err != nil {
2024-06-13 13:02:43 +08:00
fmt.Printf("es client init fail : %v", err)
2023-12-24 15:29:12 +08:00
return
}
2024-03-16 23:39:10 +08:00
ctx := context.Background()
2024-06-13 13:02:43 +08:00
list, err := client.GetStreamerAcctList(ctx)
if err != nil {
fmt.Printf("GetStreamerAcctList err :%v", err)
}
2024-06-14 08:21:41 +08:00
fmt.Printf("总共%v个", len(list))
2024-03-16 23:54:18 +08:00
2024-06-13 13:02:43 +08:00
for _, acct := range list {
acct.PinYin = strings.Join(pinyin.LazyConvert(acct.Name, nil), "")
err := client.UpdateStreamerAcct(ctx, acct)
if err != nil {
fmt.Printf("UpdateStreamerAcct err :%v", err)
}
2023-12-24 15:29:12 +08:00
}
fmt.Println("End importing...")
}