From 23845d73341d8b721041a541b452d7296d7a623e Mon Sep 17 00:00:00 2001 From: eryajf Date: Wed, 8 Nov 2023 14:58:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=97=B6=E5=A4=84=E7=90=86=E7=A6=BB=E8=81=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/dingtalk_logic.go | 10 +++++++--- logic/feishu_logic.go | 6 +++++- logic/wecom_logic.go | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/logic/dingtalk_logic.go b/logic/dingtalk_logic.go index 4fe930e..fd60417 100644 --- a/logic/dingtalk_logic.go +++ b/logic/dingtalk_logic.go @@ -16,7 +16,7 @@ import ( type DingTalkLogic struct { } -//通过钉钉获取部门信息 +// 通过钉钉获取部门信息 func (d *DingTalkLogic) SyncDingTalkDepts(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) { // 1.获取所有部门 deptSource, err := dingtalk.GetAllDepts() @@ -78,7 +78,7 @@ func (d DingTalkLogic) AddDepts(group *model.Group) error { return nil } -//根据现有数据库同步到的部门信息,开启用户同步 +// 根据现有数据库同步到的部门信息,开启用户同步 func (d DingTalkLogic) SyncDingTalkUsers(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) { // 1.获取钉钉用户列表 staffSource, err := dingtalk.GetAllUsers() @@ -111,7 +111,11 @@ func (d DingTalkLogic) SyncDingTalkUsers(c *gin.Context, req interface{}) (data } // 4.遍历id,开始处理 for _, uid := range userIds { - if isql.User.Exist(tools.H{"source_user_id": fmt.Sprintf("%s_%s", config.Conf.DingTalk.Flag, uid)}) { + if isql.User.Exist( + tools.H{ + "source_user_id": fmt.Sprintf("%s_%s", config.Conf.DingTalk.Flag, uid), + "status": 1, //只处理1在职的 + }) { user := new(model.User) err = isql.User.Find(tools.H{"source_user_id": fmt.Sprintf("%s_%s", config.Conf.DingTalk.Flag, uid)}, user) if err != nil { diff --git a/logic/feishu_logic.go b/logic/feishu_logic.go index 0dbf79a..117de73 100644 --- a/logic/feishu_logic.go +++ b/logic/feishu_logic.go @@ -107,7 +107,11 @@ func (d FeiShuLogic) SyncFeiShuUsers(c *gin.Context, req interface{}) (data inte } // 4.遍历id,开始处理 for _, uid := range userIds { - if isql.User.Exist(tools.H{"source_user_id": fmt.Sprintf("%s_%s", config.Conf.FeiShu.Flag, uid)}) { + if isql.User.Exist( + tools.H{ + "status": 1, //只处理1在职的 + "source_user_id": fmt.Sprintf("%s_%s", config.Conf.FeiShu.Flag, uid), + }) { user := new(model.User) err = isql.User.Find(tools.H{"source_union_id": fmt.Sprintf("%s_%s", config.Conf.FeiShu.Flag, uid)}, user) if err != nil { diff --git a/logic/wecom_logic.go b/logic/wecom_logic.go index 51640d5..5ed50cf 100644 --- a/logic/wecom_logic.go +++ b/logic/wecom_logic.go @@ -17,7 +17,7 @@ import ( type WeComLogic struct { } -//通过企业微信获取部门信息 +// 通过企业微信获取部门信息 func (d *WeComLogic) SyncWeComDepts(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) { // 1.获取所有部门 deptSource, err := wechat.GetAllDepts() @@ -80,7 +80,7 @@ func (d WeComLogic) AddDepts(group *model.Group) error { return nil } -//根据现有数据库同步到的部门信息,开启用户同步 +// 根据现有数据库同步到的部门信息,开启用户同步 func (d WeComLogic) SyncWeComUsers(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) { // 1.获取企业微信用户列表 staffSource, err := wechat.GetAllUsers() @@ -126,7 +126,7 @@ func (d WeComLogic) SyncWeComUsers(c *gin.Context, req interface{}) (data interf // 4.遍历id,开始处理 for _, userTmp := range res { user := new(model.User) - err = isql.User.Find(tools.H{"source_user_id": userTmp.SourceUserId}, user) + err = isql.User.Find(tools.H{"source_user_id": userTmp.SourceUserId, "status": 1}, user) if err != nil { return nil, tools.NewMySqlError(fmt.Errorf("在MySQL查询用户失败: " + err.Error())) }