作者 陈志颖

feat:添加修改用户手机号

... ... @@ -76,7 +76,7 @@ spec:
- name: UCENTER_SECRET
value: "cykbjnfqgctn"
- name: UCENTER_APP_KEY
value: "39aefef9e22744a3b2d2d3791824ae7b"s
value: "39aefef9e22744a3b2d2d3791824ae7b"
- name: UCENTER_CHECK_ALT
value: "rsF0pL!6DwjBO735"
- name: BUSINESS_ADMIN_HOST
... ...
... ... @@ -76,6 +76,12 @@ type ImportEmployeeData struct {
Edit []EmployeeData `json:"edit"`
}
// ChangePhoneData 修改手机号
type ChangePhoneData struct {
OldPhone string `json:"oldPhone"`
NewPhone string `json:"newPhone"`
}
//SyncEmployeeService 同步用户数据
type SyncEmployeeService struct{}
... ... @@ -144,6 +150,18 @@ func (service SyncEmployeeService) DoAction(action string, byteData []byte) erro
// case "batchRemove":
// //移动通讯录用户部门 暂时不需要
// return nil
case "changePhone": // TODO 修改手机号
// 修改手机号
var (
err error
data ChangePhoneData
)
err = json.Unmarshal(byteData, &data)
if err != nil {
return fmt.Errorf("数据解析失败:%s", err)
}
return nil
case "import":
//批量导入
var (
... ... @@ -428,6 +446,31 @@ func (service SyncEmployeeService) updateUsersStatus(data ForbidAllowUserData) e
return err
}
// ChangePhone 修改手机号
func (service SyncEmployeeService) changePhone(data ChangePhoneData) error {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
err error
)
if err = transactionContext.StartTransaction(); err != nil {
return err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
var uDao *dao.UsersDao
if uDao, err = factory.CreateUsersDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
if err = uDao.UpdateUserPhone(data.OldPhone, data.NewPhone); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
err = transactionContext.CommitTransaction()
return err
}
//ChangeAdmin 变更公司负责人,超级管理员
func (service SyncEmployeeService) ChangeSuperAdmin(cmd command.ChanceSuperAdminCommand) error {
var (
... ...
... ... @@ -30,3 +30,14 @@ func (dao UsersDao) UpdateUserStatus(ids []int64, ststus int8) error {
Update()
return err
}
// UpdateUserPhone 更新用户手机号
func (dao UsersDao) UpdateUserPhone(oldPhone string, newPhone string) error {
tx := dao.transactionContext.PgTx
m := &models.Users{}
_, err := tx.Model(m).
Set("phone", newPhone).
Where("phone = ?", oldPhone).
Update()
return err
}
... ...