...
|
...
|
@@ -353,16 +353,16 @@ func editUserRole(usercompanyid int64, userid int64, companyid int64, roleids [] |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func editUserCompany(userCompanyid int64, userid int64, nickname string, o orm.Ormer) error {
|
|
|
m := &models.UserCompany{
|
|
|
Id: userCompanyid,
|
|
|
NickName: nickname,
|
|
|
UserId: userid,
|
|
|
}
|
|
|
// func editUserCompany(userCompanyid int64, userid int64, nickname string, o orm.Ormer) error {
|
|
|
// m := &models.UserCompany{
|
|
|
// Id: userCompanyid,
|
|
|
// NickName: nickname,
|
|
|
// UserId: userid,
|
|
|
// }
|
|
|
|
|
|
err := models.UpdateUserCompanyById(m, []string{"NickName", "UserId"}, o)
|
|
|
return err
|
|
|
}
|
|
|
// err := models.UpdateUserCompanyById(m, []string{"NickName", "UserId"}, o)
|
|
|
// return err
|
|
|
// }
|
|
|
|
|
|
//校验user和公司的关系是否正确
|
|
|
func validUserCompany(userCompanyid int64, companyid int64) (*models.UserCompany, error) {
|
...
|
...
|
@@ -406,34 +406,34 @@ func UserEdit(param protocol.RequestUserEdit) error { |
|
|
log.Error(err.Error())
|
|
|
return err
|
|
|
}
|
|
|
//检查用户手机号是否生变更
|
|
|
var (
|
|
|
usrData *models.User
|
|
|
)
|
|
|
usrData, err = models.GetUserById(ucompany.UserId)
|
|
|
_, err = models.GetUserById(ucompany.UserId)
|
|
|
if err != nil {
|
|
|
log.Error("获取用户数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
o := orm.NewOrm()
|
|
|
o.Begin()
|
|
|
if usrData.Phone != param.Phone {
|
|
|
//手机号变更
|
|
|
uid, err := addNewUser(param.Name, param.Phone, o)
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Error("手机号变更,新增用户失败;%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
ucompany.UserId = uid
|
|
|
}
|
|
|
//检查用户手机号是否生变更
|
|
|
// var (
|
|
|
// usrData *models.User
|
|
|
// )
|
|
|
// if usrData.Phone != param.Phone {
|
|
|
// //手机号变更
|
|
|
// uid, err := addNewUser(param.Name, param.Phone, o)
|
|
|
// if err != nil {
|
|
|
// o.Rollback()
|
|
|
// log.Error("手机号变更,新增用户失败;%s", err)
|
|
|
// return protocol.NewErrWithMessage("1")
|
|
|
// }
|
|
|
// ucompany.UserId = uid
|
|
|
// }
|
|
|
//用户数据更新
|
|
|
err = editUserCompany(param.UserCompanyID, ucompany.UserId, param.Name, o)
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Error("editUserCompany err:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
// err = editUserCompany(param.UserCompanyID, ucompany.UserId, param.Name, o)
|
|
|
// if err != nil {
|
|
|
// o.Rollback()
|
|
|
// log.Error("editUserCompany err:%s", err)
|
|
|
// return protocol.NewErrWithMessage("1")
|
|
|
// }
|
|
|
//添加角色
|
|
|
err = editUserRole(param.UserCompanyID, ucompany.UserId, param.CompanyId, param.Roles, o)
|
|
|
if err != nil {
|
...
|
...
|
|