|
@@ -2,11 +2,14 @@ package controllers
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
|
+ "fmt"
|
|
|
|
|
+ "github.com/nsqio/go-nsq"
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
|
|
"dashoo.cn/base_common/business/auth"
|
|
"dashoo.cn/base_common/business/auth"
|
|
|
"dashoo.cn/base_common/business/permission"
|
|
"dashoo.cn/base_common/business/permission"
|
|
|
"dashoo.cn/base_common/business/userRole"
|
|
"dashoo.cn/base_common/business/userRole"
|
|
|
|
|
+ "dashoo.cn/base_common/utils"
|
|
|
"dashoo.cn/mcs_api/business/accountinfo"
|
|
"dashoo.cn/mcs_api/business/accountinfo"
|
|
|
"dashoo.cn/mcs_api/business/authcodeman"
|
|
"dashoo.cn/mcs_api/business/authcodeman"
|
|
|
"dashoo.cn/mcs_api/business/company"
|
|
"dashoo.cn/mcs_api/business/company"
|
|
@@ -15,7 +18,6 @@ import (
|
|
|
"dashoo.cn/mcs_api/business/logsinfo"
|
|
"dashoo.cn/mcs_api/business/logsinfo"
|
|
|
"dashoo.cn/mcs_api/business/organize"
|
|
"dashoo.cn/mcs_api/business/organize"
|
|
|
"dashoo.cn/mcs_api/models"
|
|
"dashoo.cn/mcs_api/models"
|
|
|
- "dashoo.cn/base_common/utils"
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// Operations about Users
|
|
// Operations about Users
|
|
@@ -293,12 +295,14 @@ func (this *UserController) EditUser() {
|
|
|
userentity.Modifiedby = this.User.Realname
|
|
userentity.Modifiedby = this.User.Realname
|
|
|
userentity.Departmentid = model.DepartmentId
|
|
userentity.Departmentid = model.DepartmentId
|
|
|
userentity.Departmentname = model.DepartmentName
|
|
userentity.Departmentname = model.DepartmentName
|
|
|
|
|
+ userentity.Photo = model.Photo
|
|
|
|
|
|
|
|
- var cols []string = []string{"Realname", "Roleid", "Telephone", "Mobile", "Description", "Modifieduserid", "Modifiedby", "Departmentid", "Departmentname"}
|
|
|
|
|
|
|
+ var cols []string = []string{"Realname", "Roleid", "Telephone", "Mobile", "Description", "Modifieduserid", "Modifiedby", "Departmentid", "Departmentname", "Photo"}
|
|
|
|
|
|
|
|
err := svc.UpdateEntityAndBackupByCols(id, &userentity, &userentityempty, cols, utils.ToStr(this.User.Id), this.User.Realname)
|
|
err := svc.UpdateEntityAndBackupByCols(id, &userentity, &userentityempty, cols, utils.ToStr(this.User.Id), this.User.Realname)
|
|
|
|
|
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
|
|
+ sendFaceLockCheckMsg(id, "update")
|
|
|
errinfo.Message = "保存成功!"
|
|
errinfo.Message = "保存成功!"
|
|
|
errinfo.Code = 0
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
@@ -436,11 +440,12 @@ func (this *UserController) SetPermission() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ sendFaceLockCheckMsg(utils.ToStr(uid), "power")
|
|
|
|
|
+
|
|
|
errinfo.Message = "权限调整成功"
|
|
errinfo.Message = "权限调整成功"
|
|
|
errinfo.Code = 0
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// @Title 创建用户
|
|
// @Title 创建用户
|
|
@@ -490,7 +495,6 @@ func (this *UserController) ResetPassWord() {
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// @Title 创建用户
|
|
// @Title 创建用户
|
|
@@ -553,6 +557,7 @@ func (this *UserController) MemberSetting() {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ sendFaceLockCheckMsg(utils.ToStr(userentity.Id), "update")
|
|
|
errinfo.Message = "设置成功"
|
|
errinfo.Message = "设置成功"
|
|
|
errinfo.Code = 0
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
this.Data["json"] = &errinfo
|
|
@@ -726,3 +731,19 @@ func (this *UserController) GetUserModule() {
|
|
|
this.Data["json"] = model
|
|
this.Data["json"] = model
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// 发出人脸识别设备更新检查消息
|
|
|
|
|
+// action: update 用户照片更新,power 设备权限更新
|
|
|
|
|
+func sendFaceLockCheckMsg(userId, action string) {
|
|
|
|
|
+ nsqdAddr := utils.Cfg.MustValue("nsq", "nsqd_tcp_addr")
|
|
|
|
|
+ topic := utils.Cfg.MustValue("nsq", "topic")
|
|
|
|
|
+ config := nsq.NewConfig()
|
|
|
|
|
+ w, err := nsq.NewProducer(nsqdAddr, config)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("初始化NsqProducer失败:", err)
|
|
|
|
|
+ }
|
|
|
|
|
+ err = w.Publish(topic, []byte(userId+ "|" + action))
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Println("发送NSQ消息失败:", err)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|