...
|
...
|
@@ -227,13 +227,45 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro |
|
|
}
|
|
|
for i := range datas {
|
|
|
data := datas[i]
|
|
|
var oldUser domain.Users
|
|
|
oldUser, err = usersRepository.FindOne(domain.UsersFindOneQuery{
|
|
|
var (
|
|
|
oldUser *domain.Users
|
|
|
userExist bool
|
|
|
)
|
|
|
oldUser, userExist, err = usersRepository.FindOneWithExist(domain.UsersFindOneQuery{
|
|
|
Id: data.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return lib.ThrowError(lib.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
if !userExist {
|
|
|
//不存在可更新数据,执行添加数据的操作
|
|
|
newUser := domain.Users{
|
|
|
Id: data.Id,
|
|
|
CompanyId: data.CompanyId,
|
|
|
OpenId: data.OpenId,
|
|
|
Name: data.Name,
|
|
|
Sex: data.Sex,
|
|
|
JobNum: data.JobNum,
|
|
|
Phone: data.Phone,
|
|
|
PrivatePhone: data.PrivatePhone,
|
|
|
Email: data.Email,
|
|
|
ExtensionNum: data.ExtensionNum,
|
|
|
Workspace: data.WorkSpace,
|
|
|
Status: data.Status,
|
|
|
Avatar: data.Avatar,
|
|
|
Remarks: data.Remarks,
|
|
|
ChargeStatus: data.ChargeStatus,
|
|
|
Permission: []domain.AdminPermissionBase{}, //初始化权限
|
|
|
AccessPartners: []domain.Partner{}, //默认初始化
|
|
|
AdminType: data.AdminType,
|
|
|
IsSenior: 2,
|
|
|
}
|
|
|
newUser.EntryTime, _ = time.Parse("2006-01-02", data.EntryTime)
|
|
|
if err = usersRepository.Add(&newUser); err != nil {
|
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
continue
|
|
|
} else {
|
|
|
entryTime, _ := time.Parse("2006-01-02", data.EntryTime)
|
|
|
_ = oldUser.Update(map[string]interface{}{
|
|
|
"CompanyId": data.CompanyId,
|
...
|
...
|
@@ -252,10 +284,11 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro |
|
|
"EntryTime": entryTime,
|
|
|
"AdminType": data.AdminType,
|
|
|
})
|
|
|
if err = usersRepository.Edit(&oldUser); err != nil {
|
|
|
if err = usersRepository.Edit(oldUser); err != nil {
|
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
return err
|
|
|
}
|
...
|
...
|
|