Skip to content

Commit

Permalink
Merge pull request #269 from eryajf:fix_leaveUser
Browse files Browse the repository at this point in the history
fix: 修复同步用户时处理离职用户的异常
  • Loading branch information
eryajf authored Nov 8, 2023
2 parents d9bb571 + 23845d7 commit ae087f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions logic/dingtalk_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion logic/feishu_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions logic/wecom_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()))
}
Expand Down

0 comments on commit ae087f2

Please sign in to comment.