|
@@ -31,8 +31,12 @@ type User struct {
|
|
Dept_name string //部门名称
|
|
Dept_name string //部门名称
|
|
Role string //角色
|
|
Role string //角色
|
|
Power int //权限
|
|
Power int //权限
|
|
|
|
+<<<<<<< HEAD
|
|
NicheDis int //商机分配权限
|
|
NicheDis int //商机分配权限
|
|
Role_id int
|
|
Role_id int
|
|
|
|
+=======
|
|
|
|
+ User_name string
|
|
|
|
+>>>>>>> feature/v1.0.3
|
|
}
|
|
}
|
|
|
|
|
|
type CompletionUserInfo struct {
|
|
type CompletionUserInfo struct {
|
|
@@ -71,7 +75,7 @@ func (u *User) GetByPhone(phone string) *[]*User {
|
|
|
|
|
|
//根据id获取带有角色的员工信息
|
|
//根据id获取带有角色的员工信息
|
|
func (u *User) GetAllInfoById(entId, userId int) *User {
|
|
func (u *User) GetAllInfoById(entId, userId int) *User {
|
|
- r := Mysql.SelectBySql(`SELECT a.id,a.name,a.phone,a.mail,c.name as dept_name,c.id as dept_id,e.name as role from entniche_user a
|
|
|
|
|
|
+ r := Mysql.SelectBySql(`SELECT a.id,a.name,a.user_name,a.phone,a.mail,c.name as dept_name,c.id as dept_id,e.name as role from entniche_user a
|
|
INNER JOIN entniche_department_user b on (a.id=? and a.ent_id=? and a.id=b.user_id)
|
|
INNER JOIN entniche_department_user b on (a.id=? and a.ent_id=? and a.id=b.user_id)
|
|
INNER JOIN entniche_department c on (b.dept_id=c.id)
|
|
INNER JOIN entniche_department c on (b.dept_id=c.id)
|
|
LEFT JOIN entniche_user_role d on (a.id=d.user_id)
|
|
LEFT JOIN entniche_user_role d on (a.id=d.user_id)
|
|
@@ -143,11 +147,13 @@ func (u *User) Add(tx *sql.Tx, entId int, user *User, paymentAddress, source, ns
|
|
"ent_id": entId,
|
|
"ent_id": entId,
|
|
"createtime": nowFormat,
|
|
"createtime": nowFormat,
|
|
"timestamp": nowFormat,
|
|
"timestamp": nowFormat,
|
|
|
|
+ "user_name": user.User_name,
|
|
})
|
|
})
|
|
dept_user_id := Mysql.InsertByTx(tx, Entniche_department_user, map[string]interface{}{
|
|
dept_user_id := Mysql.InsertByTx(tx, Entniche_department_user, map[string]interface{}{
|
|
"dept_id": user.Dept_id,
|
|
"dept_id": user.Dept_id,
|
|
"user_id": user_id,
|
|
"user_id": user_id,
|
|
})
|
|
})
|
|
|
|
+
|
|
if user_id <= 0 || dept_user_id < 0 {
|
|
if user_id <= 0 || dept_user_id < 0 {
|
|
return user_id, false
|
|
return user_id, false
|
|
}
|
|
}
|
|
@@ -182,7 +188,37 @@ func (u *User) Add(tx *sql.Tx, entId int, user *User, paymentAddress, source, ns
|
|
})
|
|
})
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ //entniche_user表,用户名字段 user_name
|
|
|
|
+ //base_user表,用户名字段 user_name
|
|
|
|
+ //mog库user表,用户名字段 user_name
|
|
|
|
+ if user.User_name != "" && len(user.User_name) > 0 {
|
|
|
|
+ Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set user_name=? where phone=? and ent_id!=?`, user.User_name, user.Phone, entId)
|
|
|
|
+ data, _ := MQFW.Find("user", map[string]interface{}{
|
|
|
|
+ "i_appid": 2,
|
|
|
|
+ "$or": []map[string]interface{}{
|
|
|
|
+ {"s_phone": user.Phone},
|
|
|
|
+ {"s_m_phone": user.Phone},
|
|
|
|
+ },
|
|
|
|
+ }, `{"s_phone":-1}`, `{"_id":1,"base_user_id":1}`, false, 0, 1)
|
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
|
+ for _, v := range *data {
|
|
|
|
+ userId := BsonIdToSId(v["_id"])
|
|
|
|
+ baseUserId := v["base_user_id"]
|
|
|
|
+ MQFW.UpdateById("user", userId, map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "user_name": user.User_name,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ Base.Update("base_user", map[string]interface{}{
|
|
|
|
+ "id": baseUserId,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "user_name": user.User_name,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
return user_id, respData.Fool
|
|
return user_id, respData.Fool
|
|
}
|
|
}
|
|
|
|
|
|
@@ -276,12 +312,67 @@ func (u *User) ResetPasswords(power_virtual_account int, virtual_account_rule, p
|
|
func (u *User) PhoneExist(phone string, entId int) *[]map[string]interface{} {
|
|
func (u *User) PhoneExist(phone string, entId int) *[]map[string]interface{} {
|
|
return Mysql.SelectBySql("select id from entniche_user where phone=? and ent_id=?", phone, entId)
|
|
return Mysql.SelectBySql("select id from entniche_user where phone=? and ent_id=?", phone, entId)
|
|
}
|
|
}
|
|
|
|
+func (u *User) UserNameExist(userName, phone string) bool {
|
|
|
|
+ user, ok := MQFW.FindOne("user", map[string]interface{}{
|
|
|
|
+ "i_appid": 2,
|
|
|
|
+ "user_name": userName,
|
|
|
|
+ })
|
|
|
|
+ if ok && user != nil && len(*user) > 0 {
|
|
|
|
+ s_phone := qutil.InterfaceToStr((*user)["s_phone"])
|
|
|
|
+ s_m_phone := qutil.InterfaceToStr((*user)["s_m_phone"])
|
|
|
|
+ if s_phone != "" {
|
|
|
|
+ if s_phone == phone {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if s_m_phone != "" {
|
|
|
|
+ if s_phone == phone {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (u *User) UpdateUserName(tx *sql.Tx, entId, userId int, user_name, phone string) {
|
|
|
|
+ //entniche_user表,用户名字段 user_name
|
|
|
|
+ //base_user表,用户名字段 user_name
|
|
|
|
+ //mog库user表,用户名字段 user_name
|
|
|
|
+ if user_name != "" && len(user_name) > 0 {
|
|
|
|
+ Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set user_name=? where phone=? and ent_id!=?`, user_name, phone, entId)
|
|
|
|
+ data, _ := MQFW.Find("user", map[string]interface{}{
|
|
|
|
+ "i_appid": 2,
|
|
|
|
+ "$or": []map[string]interface{}{
|
|
|
|
+ {"s_phone": phone},
|
|
|
|
+ {"s_m_phone": phone},
|
|
|
|
+ },
|
|
|
|
+ }, `{"s_phone":-1}`, `{"_id":1,"base_user_id":1}`, false, 0, 1)
|
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
|
+ for _, v := range *data {
|
|
|
|
+ userId := BsonIdToSId(v["_id"])
|
|
|
|
+ baseUserId := v["base_user_id"]
|
|
|
|
+ MQFW.UpdateById("user", userId, map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "user_name": user_name,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ Base.Update("base_user", map[string]interface{}{
|
|
|
|
+ "id": baseUserId,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "user_name": user_name,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
// 修改用户信息包括用户名和手机号 20210429海康威视需求新增的
|
|
// 修改用户信息包括用户名和手机号 20210429海康威视需求新增的
|
|
-func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId, entId int, entPhone string, entName string, isAdmin bool) bool {
|
|
|
|
|
|
+func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId, entId int, entPhone string, entName, user_name string, isAdmin bool) bool {
|
|
if isAdmin {
|
|
if isAdmin {
|
|
ok := Mysql.ExecTx("修改员工", func(tx *sql.Tx) bool {
|
|
ok := Mysql.ExecTx("修改员工", func(tx *sql.Tx) bool {
|
|
- ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set mail=?,phone=?,name=?,timestamp=? where id=? and ent_id=?`, mail, phone, name, NowFormat(Date_Full_Layout), userId, entId)
|
|
|
|
|
|
+ ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set mail=?,phone=?,name=?,timestamp=? ,user_name=? where id=? and ent_id=?`, mail, phone, name, NowFormat(Date_Full_Layout), user_name, userId, entId)
|
|
MQFW.Update("ent_user", map[string]interface{}{"i_entid": entId, "i_userid": userId}, map[string]interface{}{
|
|
MQFW.Update("ent_user", map[string]interface{}{"i_entid": entId, "i_userid": userId}, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"o_pushset.s_email": mail,
|
|
"o_pushset.s_email": mail,
|
|
@@ -289,6 +380,7 @@ func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId
|
|
}, true, false)
|
|
}, true, false)
|
|
ok_2 := Mysql.UpdateOrDeleteBySqlByTx(tx, "update entniche_info set admin=?,phone=? where id=?", name, phone, entId)
|
|
ok_2 := Mysql.UpdateOrDeleteBySqlByTx(tx, "update entniche_info set admin=?,phone=? where id=?", name, phone, entId)
|
|
ok_3 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
|
|
ok_3 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
|
|
|
|
+ u.UpdateUserName(tx, entId, userId, user_name, phone)
|
|
return ok_1 != -1 && ok_3 && ok_2 != -1
|
|
return ok_1 != -1 && ok_3 && ok_2 != -1
|
|
})
|
|
})
|
|
if ok {
|
|
if ok {
|
|
@@ -303,13 +395,14 @@ func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
return Mysql.ExecTx("修改员工", func(tx *sql.Tx) bool {
|
|
return Mysql.ExecTx("修改员工", func(tx *sql.Tx) bool {
|
|
- ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set mail=?,phone=?,name=?,timestamp=? where id=? and ent_id=?`, mail, phone, name, NowFormat(Date_Full_Layout), userId, entId)
|
|
|
|
|
|
+ ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set mail=?,phone=?,name=?,timestamp=? ,user_name=? where id=? and ent_id=?`, mail, phone, name, NowFormat(Date_Full_Layout), user_name, userId, entId)
|
|
MQFW.Update("ent_user", map[string]interface{}{"i_entid": entId, "i_userid": userId}, map[string]interface{}{
|
|
MQFW.Update("ent_user", map[string]interface{}{"i_entid": entId, "i_userid": userId}, map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"o_pushset.s_email": mail,
|
|
"o_pushset.s_email": mail,
|
|
},
|
|
},
|
|
}, true, false)
|
|
}, true, false)
|
|
ok_2 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
|
|
ok_2 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
|
|
|
|
+ u.UpdateUserName(tx, entId, userId, user_name, phone)
|
|
return ok_1 == 1 && ok_2
|
|
return ok_1 == 1 && ok_2
|
|
})
|
|
})
|
|
}
|
|
}
|