|
@@ -77,6 +77,7 @@ func (a *Action) OrgAdd() {
|
|
|
return
|
|
|
}
|
|
|
name := a.GetString("name")
|
|
|
+
|
|
|
mail := a.GetString("email")
|
|
|
if phone == "" && a.GetSession("userId") != nil {
|
|
|
userId, _ := a.GetSession("userId").(string)
|
|
@@ -453,11 +454,19 @@ func (a *Action) Add() {
|
|
|
name = string([]rune(name)[:30])
|
|
|
}
|
|
|
phone := a.GetString("phone")
|
|
|
+ user_name := a.GetString("user_name")
|
|
|
mail := a.GetString("mail")
|
|
|
if mail != "" && !jy.IsEmail(mail) {
|
|
|
R.InvalidReqParam(a.ResponseWriter, a.Request, "name")
|
|
|
return
|
|
|
}
|
|
|
+ userName := a.GetString("user_name")
|
|
|
+ if userName != "" && len(userName) > 0 {
|
|
|
+ if !VarUser.UserNameExist(userName, a.GetString("phone")) {
|
|
|
+ a.ServeJson(Result{Data: M{"status": 0}, Error_msg: "账户名已存在", Error_code: -2})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
status, user_id := func() (int, int64) {
|
|
|
if VarUser.AddIsExists(frameworkEntId, phone) {
|
|
|
return -1, 0
|
|
@@ -467,10 +476,11 @@ func (a *Action) Add() {
|
|
|
var user_id int64
|
|
|
if Mysql.ExecTx("新增员工", func(tx *sql.Tx) bool {
|
|
|
uid, ok := VarUser.Add(tx, frameworkEntId, &User{
|
|
|
- Dept_id: id,
|
|
|
- Name: name,
|
|
|
- Mail: mail,
|
|
|
- Phone: phone,
|
|
|
+ Dept_id: id,
|
|
|
+ Name: name,
|
|
|
+ Mail: mail,
|
|
|
+ Phone: phone,
|
|
|
+ User_name: user_name,
|
|
|
}, Config.PaymentAddress, "", Config.Nsq, Config.Nsq_Topic)
|
|
|
user_id = uid
|
|
|
return ok
|
|
@@ -564,6 +574,7 @@ func (a *Action) Detail() {
|
|
|
"phone": user.Phone,
|
|
|
"role": user.Role,
|
|
|
"mail": user.Mail,
|
|
|
+ "user_name": user.User_name,
|
|
|
},
|
|
|
})
|
|
|
}
|
|
@@ -610,7 +621,13 @@ func (a *Action) Update() {
|
|
|
return
|
|
|
}
|
|
|
status := 0
|
|
|
-
|
|
|
+ userName := a.GetString("user_name")
|
|
|
+ if userName != "" && len(userName) > 0 {
|
|
|
+ if !VarUser.UserNameExist(userName, a.GetString("phone")) {
|
|
|
+ a.ServeJson(Result{Data: M{"status": status}, Error_msg: "账户名已存在", Error_code: -2})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
if a.GetString("phone") != "" && a.GetString("name") != "" {
|
|
|
// 开放更新手机号和用户名 20210429 海康威视需求添加
|
|
|
// 1. 查询一下手机号是否已存在
|
|
@@ -627,11 +644,12 @@ func (a *Action) Update() {
|
|
|
var updateUser = &CurrentUser{}
|
|
|
entinfo := updateUser.EntInfo(frameworkEntId, id)
|
|
|
// 管理员则需要改entniche_info entniche_user 两张表以及jyqyfw user表 普通用户一张表
|
|
|
- if VarUser.UpdateInfo(a.GetString("mail"), a.GetString("phone"), a.GetString("name"), id, did, frameworkEntId, entinfo.Ent.Phone, entinfo.Ent.Name, entinfo.Role_admin_system) {
|
|
|
+ if VarUser.UpdateInfo(a.GetString("mail"), a.GetString("phone"), a.GetString("name"), id, did, frameworkEntId, entinfo.Ent.Phone, entinfo.Ent.Name, a.GetString("user_name"), entinfo.Role_admin_system) {
|
|
|
status = 1
|
|
|
}
|
|
|
} else if VarUser.Update(a.GetString("mail"), id, did, frameworkEntId) {
|
|
|
status = 1
|
|
|
}
|
|
|
+
|
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
|
}
|