From 4b109b238e5040703f857e27ecfbf978a5e1227d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Tue, 26 Sep 2023 14:29:41 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 6 ++++++ tasks/friends.go | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..75d62f4 --- /dev/null +++ b/readme.md @@ -0,0 +1,6 @@ + + +### 手动打包镜像 +```shell +docker build --push -t repo.lxh.io/lxh/go-wxhelper:latest . +``` \ No newline at end of file diff --git a/tasks/friends.go b/tasks/friends.go index e898739..0e7618d 100644 --- a/tasks/friends.go +++ b/tasks/friends.go @@ -15,13 +15,15 @@ import ( // 同步群成员 +// http客户端 +var hc = resty.New() + // syncFriends // @description: 同步好友列表 func syncFriends() { var base model.Response[[]model.FriendItem] - res := resty.New() - resp, err := res.R(). + resp, err := hc.R(). SetHeader("Content-Type", "application/json;chartset=utf-8"). SetResult(&base). Post("http://10.0.0.73:19088/api/getContactList") @@ -98,8 +100,7 @@ func syncGroupUsers(tx *gorm.DB, gid string) { } pbs, _ := json.Marshal(param) - res := resty.New() - _, err := res.R(). + _, err := hc.R(). SetHeader("Content-Type", "application/json;chartset=utf-8"). SetBody(string(pbs)). SetResult(&baseResp). @@ -114,7 +115,7 @@ func syncGroupUsers(tx *gorm.DB, gid string) { log.Printf(" 群成员数: %d", len(wxIds)) // 修改不在数组的群成员状态为不在 - err = tx.Model(&entity.GroupUser{}).Where("wxid NOT IN (?)", wxIds).Update("is_member", false).Error + err = tx.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Where("wxid NOT IN (?)", wxIds).Update("is_member", false).Error if err != nil { log.Printf("修改群成员状态失败: %s", err.Error()) return @@ -177,8 +178,7 @@ func getContactProfile(wxid string) (ent model.ContactProfile, err error) { } pbs, _ := json.Marshal(param) - client := resty.New() - _, err = client.R(). + _, err = hc.R(). SetHeader("Content-Type", "application/json;chartset=utf-8"). SetBody(string(pbs)). SetResult(&baseResp).