-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
package feishu | ||
|
||
import ( | ||
"github.com/ncuhome/GeniusAuthoritarian/pkg/feishuApi" | ||
) | ||
|
||
type UserSync interface { | ||
IsInvalid() bool | ||
Departments(groupMap map[string]uint) []uint | ||
} | ||
|
||
func NewUser(data *feishuApi.User) *User { | ||
return &User{ | ||
data: data, | ||
} | ||
} | ||
|
||
type User struct { | ||
data *feishuApi.User | ||
departments []uint | ||
} | ||
|
||
func (u User) IsInvalid() bool { | ||
return !u.data.Status.IsActivated || u.data.Status.IsFrozen || u.data.Status.IsResigned || u.data.Mobile == "" || // 账号未异常 | ||
u.data.EmployeeType != 1 // 仅允许正式员工状态账号 | ||
} | ||
|
||
func (u User) Departments(groupMap map[string]uint) []uint { | ||
var departments = make([]uint, len(u.data.DepartmentIds)) | ||
var validLength int | ||
for _, groupOpenID := range u.data.DepartmentIds { | ||
id, ok := groupMap[groupOpenID] | ||
if !ok { | ||
continue | ||
} | ||
departments[validLength] = id | ||
validLength++ | ||
} | ||
return departments[:validLength] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters