fix:解决因username为空导致同步失败,解决departments字段长度问题 (#200)
This commit is contained in:
parent
cbca69dc49
commit
718e02369a
|
@ -2,7 +2,6 @@ package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/eryajf/go-ldap-admin/config"
|
"github.com/eryajf/go-ldap-admin/config"
|
||||||
"github.com/eryajf/go-ldap-admin/model"
|
"github.com/eryajf/go-ldap-admin/model"
|
||||||
"github.com/eryajf/go-ldap-admin/public/common"
|
"github.com/eryajf/go-ldap-admin/public/common"
|
||||||
|
@ -255,6 +254,13 @@ func BuildUserData(flag string, remoteData map[string]interface{}) (*model.User,
|
||||||
return nil, tools.NewOperationError(err)
|
return nil, tools.NewOperationError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 校验username是否为空,username为必填项
|
||||||
|
name := gjson.Get(string(output), fieldRelation["username"]).String()
|
||||||
|
if len(name) == 0 {
|
||||||
|
common.Log.Warnf("%s 该用户未填写username", output)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
u := &model.User{}
|
u := &model.User{}
|
||||||
for system, remote := range fieldRelation {
|
for system, remote := range fieldRelation {
|
||||||
switch system {
|
switch system {
|
||||||
|
@ -310,9 +316,11 @@ func ConvertUserData(flag string, remoteData []map[string]interface{}) (users []
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if user != nil {
|
||||||
user.DepartmentId = tools.SliceToString(groupIds, ",")
|
user.DepartmentId = tools.SliceToString(groupIds, ",")
|
||||||
users = append(users, user)
|
users = append(users, user)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ type User struct {
|
||||||
Mobile string `gorm:"type:varchar(15);not null;unique;comment:'手机号'" json:"mobile"` // 手机号
|
Mobile string `gorm:"type:varchar(15);not null;unique;comment:'手机号'" json:"mobile"` // 手机号
|
||||||
Avatar string `gorm:"type:varchar(255);comment:'头像'" json:"avatar"` // 头像
|
Avatar string `gorm:"type:varchar(255);comment:'头像'" json:"avatar"` // 头像
|
||||||
PostalAddress string `gorm:"type:varchar(255);comment:'地址'" json:"postalAddress"` // 地址
|
PostalAddress string `gorm:"type:varchar(255);comment:'地址'" json:"postalAddress"` // 地址
|
||||||
Departments string `gorm:"type:varchar(128);comment:'部门'" json:"departments"` // 部门
|
Departments string `gorm:"type:varchar(512);comment:'部门'" json:"departments"` // 部门
|
||||||
Position string `gorm:"type:varchar(128);comment:'职位'" json:"position"` // 职位
|
Position string `gorm:"type:varchar(128);comment:'职位'" json:"position"` // 职位
|
||||||
Introduction string `gorm:"type:varchar(255);comment:'个人简介'" json:"introduction"` // 个人简介
|
Introduction string `gorm:"type:varchar(255);comment:'个人简介'" json:"introduction"` // 个人简介
|
||||||
Status uint `gorm:"type:tinyint(1);default:1;comment:'状态:1在职, 2离职'" json:"status"` // 状态
|
Status uint `gorm:"type:tinyint(1);default:1;comment:'状态:1在职, 2离职'" json:"status"` // 状态
|
||||||
|
|
Loading…
Reference in New Issue