From c1781ce5b02ca713cc74cbe065b31b6bb19fecb6 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Sat, 2 Mar 2024 16:27:32 +0800 Subject: [PATCH] feat: Some of the notes were translated --- .../openim/mysql/v3/friend_request.go | 40 +++++++++-------- tools/infra/infra.go | 2 +- tools/url2im/main.go | 43 ++++++++++++++----- 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/tools/data-conversion/openim/mysql/v3/friend_request.go b/tools/data-conversion/openim/mysql/v3/friend_request.go index 51ea0ef6e..4fc5ba7c1 100644 --- a/tools/data-conversion/openim/mysql/v3/friend_request.go +++ b/tools/data-conversion/openim/mysql/v3/friend_request.go @@ -38,29 +38,33 @@ func (FriendRequestModel) TableName() string { } type FriendRequestModelInterface interface { - // 插入多条记录 + // Insert multiple records Create(ctx context.Context, friendRequests []*FriendRequestModel) (err error) - // 删除记录 + + // Delete a record Delete(ctx context.Context, fromUserID, toUserID string) (err error) - // 更新零值 - UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]interface{}) (err error) - // 更新多条记录 (非零值) + + // Update records with zero values based on a map of changes + UpdateByMap(ctx context.Context, formUserID, toUserID string, args map[string]interface{}) (err error) + + // Update multiple records (non-zero values) Update(ctx context.Context, friendRequest *FriendRequestModel) (err error) - // 获取来指定用户的好友申请 未找到 不返回错误 + + // Find a friend request sent to a specific user; does not return an error if not found Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error) + + // Alias for Find (retrieves a friend request between two users) Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error) - // 获取toUserID收到的好友申请列表 - FindToUserID( - ctx context.Context, - toUserID string, - pageNumber, showNumber int32, - ) (friendRequests []*FriendRequestModel, total int64, err error) - // 获取fromUserID发出去的好友申请列表 - FindFromUserID( - ctx context.Context, - fromUserID string, - pageNumber, showNumber int32, - ) (friendRequests []*FriendRequestModel, total int64, err error) + + // Get a list of friend requests received by `toUserID` + FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error) + + // Get a list of friend requests sent by `fromUserID` + FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error) + + // Find all friend requests between two users (both directions) FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*FriendRequestModel, err error) + + // Create a new transaction NewTx(tx any) FriendRequestModelInterface } diff --git a/tools/infra/infra.go b/tools/infra/infra.go index da7adf48e..bc01a00eb 100644 --- a/tools/infra/infra.go +++ b/tools/infra/infra.go @@ -47,5 +47,5 @@ Keep checking for updates! ` blue.Println(message) - printLinks() // 调用函数以打印链接信息 + printLinks() // Call the function to print the link information } diff --git a/tools/url2im/main.go b/tools/url2im/main.go index 8d6151b09..28c1e1c43 100644 --- a/tools/url2im/main.go +++ b/tools/url2im/main.go @@ -31,17 +31,38 @@ import ( */ func main() { - var conf pkg.Config // 后面带*的为必填项 - flag.StringVar(&conf.TaskPath, "task", "take.txt", "task path") // 任务日志文件* - flag.StringVar(&conf.ProgressPath, "progress", "", "progress path") // 进度日志文件 - flag.IntVar(&conf.Concurrency, "concurrency", 1, "concurrency num") // 并发数 - flag.IntVar(&conf.Retry, "retry", 1, "retry num") // 重试次数 - flag.StringVar(&conf.TempDir, "temp", "", "temp dir") // 临时文件夹 - flag.Int64Var(&conf.CacheSize, "cache", 1024*1024*100, "cache size") // 缓存大小(超过时,下载到磁盘) - flag.Int64Var((*int64)(&conf.Timeout), "timeout", 5000, "timeout") // 请求超时时间(毫秒) - flag.StringVar(&conf.Api, "api", "http://127.0.0.1:10002", "api") // im地址* - flag.StringVar(&conf.UserID, "userID", "openIM123456", "userID") // im管理员 - flag.StringVar(&conf.Secret, "secret", "openIM123", "secret") // im config secret + var conf pkg.Config // Configuration object, '*' denotes required fields + + // *Required*: Path for the task log file + flag.StringVar(&conf.TaskPath, "task", "take.txt", "Path for the task log file") + + // Optional: Path for the progress log file + flag.StringVar(&conf.ProgressPath, "progress", "", "Path for the progress log file") + + // Number of concurrent operations + flag.IntVar(&conf.Concurrency, "concurrency", 1, "Number of concurrent operations") + + // Number of retry attempts + flag.IntVar(&conf.Retry, "retry", 1, "Number of retry attempts") + + // Optional: Path for the temporary directory + flag.StringVar(&conf.TempDir, "temp", "", "Path for the temporary directory") + + // Cache size in bytes (downloads move to disk when exceeded) + flag.Int64Var(&conf.CacheSize, "cache", 1024*1024*100, "Cache size in bytes") + + // Request timeout in milliseconds + flag.Int64Var((*int64)(&conf.Timeout), "timeout", 5000, "Request timeout in milliseconds") + + // *Required*: API endpoint for the IM service + flag.StringVar(&conf.Api, "api", "http://127.0.0.1:10002", "API endpoint for the IM service") + + // IM administrator's user ID + flag.StringVar(&conf.UserID, "userID", "openIM123456", "IM administrator's user ID") + + // Secret for the IM configuration + flag.StringVar(&conf.Secret, "secret", "openIM123", "Secret for the IM configuration") + flag.Parse() if !filepath.IsAbs(conf.TaskPath) { var err error