|
|
@@ -3,6 +3,7 @@ package service
|
|
|
import (
|
|
|
"context"
|
|
|
"dashoo.cn/opms_libary/myerrors"
|
|
|
+ "dashoo.cn/opms_libary/request"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/container/gmap"
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
@@ -218,7 +219,7 @@ type DeptIdReq struct {
|
|
|
Include bool `json:"include,omitempty"`
|
|
|
}
|
|
|
|
|
|
-// GetUsersByDept 根据部门获取用户获取系统
|
|
|
+// GetUsersByDept 根据部门获取用户
|
|
|
func GetUsersByDept(ctx context.Context, req *DeptIdReq) (map[string]int, error) {
|
|
|
srv := micro_srv.InitMicroSrvClient("User", "micro_srv.auth")
|
|
|
defer srv.Close()
|
|
|
@@ -240,3 +241,41 @@ func GetUsersByDept(ctx context.Context, req *DeptIdReq) (map[string]int, error)
|
|
|
}
|
|
|
return res, nil
|
|
|
}
|
|
|
+
|
|
|
+type SysUserSearchReq struct {
|
|
|
+ KeyWords string `json:"keyWords"`
|
|
|
+ DeptId int `json:"deptId"` //部门id
|
|
|
+ DeptIds []int //所属部门id数据
|
|
|
+ Phone string `json:"phone"`
|
|
|
+ Status string `json:"status"`
|
|
|
+ Roles []string `json:"roles"`
|
|
|
+ Posts []string `json:"posts"`
|
|
|
+ Groups []string `json:"groups"`
|
|
|
+ request.PageReq
|
|
|
+}
|
|
|
+
|
|
|
+// GetUsersByRoleCode 根据角色编码获取用户
|
|
|
+func GetUsersByRoleCode(ctx context.Context, roleCode []string, pageSize ...int) (map[string]int, error) {
|
|
|
+ srv := micro_srv.InitMicroSrvClient("User", "micro_srv.auth")
|
|
|
+ defer srv.Close()
|
|
|
+ resp := &comm_def.CommonMsg{}
|
|
|
+ req := &SysUserSearchReq{Roles: roleCode}
|
|
|
+ if len(pageSize) > 0 {
|
|
|
+ req.PageSize = pageSize[0]
|
|
|
+ }
|
|
|
+ err := srv.Call(ctx, "GetList", req, resp)
|
|
|
+ if err != nil {
|
|
|
+ return nil, myerrors.MicroCallError("根据角色编码获取用户失败")
|
|
|
+ }
|
|
|
+ if resp.Data == nil {
|
|
|
+ return nil, myerrors.TipsError("用户不存在")
|
|
|
+ }
|
|
|
+ data := resp.Data.(map[string]interface{})
|
|
|
+ list := data["list"].([]interface{})
|
|
|
+ res := map[string]int{}
|
|
|
+ for _, i := range list {
|
|
|
+ info := i.(map[string]interface{})
|
|
|
+ res[info["NickName"].(string)] = gconv.Int(info["Id"])
|
|
|
+ }
|
|
|
+ return res, nil
|
|
|
+}
|