...
|
...
|
@@ -2,6 +2,7 @@ package service_gateway |
|
|
|
|
|
import (
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -11,8 +12,9 @@ type HttplibUserServiceGateway struct { |
|
|
}
|
|
|
|
|
|
// GetUser 获取用户
|
|
|
func (serviceGateway *HttplibUserServiceGateway) GetUser(uid int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "users/get-user"}, "/")
|
|
|
func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, uid int64) (map[string]interface{}, error) {
|
|
|
companyIdStr := strconv.FormatInt(companyId, 10)
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr + "/users/get-user"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "get")
|
|
|
options := make(map[string]interface{})
|
|
|
options["uid"] = uid
|
...
|
...
|
@@ -25,7 +27,8 @@ func (serviceGateway *HttplibUserServiceGateway) GetUser(uid int64) (map[string] |
|
|
|
|
|
// GetCompany 获取公司
|
|
|
func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "companies/ge-company"}, "/")
|
|
|
companyIdStr := strconv.FormatInt(companyId, 10)
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr}, "/")
|
|
|
request := serviceGateway.createRequest(url, "get")
|
|
|
options := make(map[string]interface{})
|
|
|
options["companyId"] = companyId
|
...
|
...
|
@@ -37,8 +40,10 @@ func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (ma |
|
|
}
|
|
|
|
|
|
// GetOrganization 获取组织信息
|
|
|
func (serviceGateway *HttplibUserServiceGateway) GetOrganization(organizationId int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "orgs/get-org"}, "/")
|
|
|
func (serviceGateway *HttplibUserServiceGateway) GetOrganization(companyId int64, organizationId int64) (map[string]interface{}, error) {
|
|
|
companyIdStr := strconv.FormatInt(companyId, 10)
|
|
|
organizationIdStr := strconv.FormatInt(organizationId, 10)
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr + "/orgs/" + organizationIdStr}, "/")
|
|
|
request := serviceGateway.createRequest(url, "get")
|
|
|
options := make(map[string]interface{})
|
|
|
options["orgId"] = organizationId
|
...
|
...
|
@@ -49,8 +54,8 @@ func (serviceGateway *HttplibUserServiceGateway) GetOrganization(organizationId |
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
// UserInMenu 获取用户菜单模块权限
|
|
|
func (serviceGateway *HttplibUserServiceGateway) UserInMenu(menuCode string) (map[string]interface{}, error) {
|
|
|
// UserInMenu 判断用户是否具有模块权限
|
|
|
func (serviceGateway *HttplibUserServiceGateway) UserInMenu(companyId int64, userId int64, menuCode string) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "users/menu"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "get")
|
|
|
options := make(map[string]interface{})
|
...
|
...
|
@@ -62,6 +67,19 @@ func (serviceGateway *HttplibUserServiceGateway) UserInMenu(menuCode string) (ma |
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
// UserInOrganization 判断用户是否存在组织内
|
|
|
func (serviceGateway *HttplibUserServiceGateway) UserInOrganization(companyId int64, orgId int64, userId int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "users/menu"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "get")
|
|
|
options := make(map[string]interface{})
|
|
|
options["orgId"] = orgId
|
|
|
request.JSONBody(options)
|
|
|
response := make(map[string]interface{})
|
|
|
request.ToJSON(&response)
|
|
|
data, err := serviceGateway.responseHandle(response)
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
func NewHttplibUserServiceGateway() *HttplibUserServiceGateway {
|
|
|
return &HttplibUserServiceGateway{
|
|
|
httplibBaseServiceGateway: httplibBaseServiceGateway{
|
...
|
...
|
|