1 Star 1 Fork 0

Ostaer/go-workwx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
user_info_helper.go 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
qinhf3 提交于 2019-12-30 23:39 +08:00 . Implement api to get user info by department id
package workwx
import (
"fmt"
"strconv"
)
func reshapeDeptInfo(
ids []int64,
orders []uint32,
leaderStatuses []int,
) []UserDeptInfo {
if len(ids) != len(orders) {
panic("should never happen")
}
if len(ids) != len(leaderStatuses) {
panic("should never happen")
}
result := make([]UserDeptInfo, len(ids))
for i := range ids {
result[i].DeptID = ids[i]
result[i].Order = orders[i]
result[i].IsLeader = leaderStatuses[i] != 0
}
return result
}
func mustFromGenderStr(x string) UserGender {
n, err := strconv.Atoi(x)
if err != nil {
panic(fmt.Sprintf("gender string parse failed: %+v", err))
}
return UserGender(n)
}
func (x respUserDetail) intoUserInfo() UserInfo {
deptInfo := reshapeDeptInfo(x.DeptIDs, x.DeptOrder, x.IsLeaderInDept)
return UserInfo{
UserID: x.UserID,
Name: x.Name,
Position: x.Position,
Departments: deptInfo,
Mobile: x.Mobile,
Gender: mustFromGenderStr(x.Gender),
Email: x.Email,
AvatarURL: x.AvatarURL,
Telephone: x.Telephone,
IsEnabled: x.IsEnabled != 0,
Alias: x.Alias,
Status: UserStatus(x.Status),
QRCodeURL: x.QRCodeURL,
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ostaer/go-workwx.git
git@gitee.com:ostaer/go-workwx.git
ostaer
go-workwx
go-workwx
b16c285aee72

搜索帮助