切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
唐旭辉
5 years ago
提交
be2498c50ff12a1f4e88f10b7fb2ee358ec20492
1 个父辈
482e03d7
修复 登录相关问题
隐藏空白字符变更
内嵌
并排对比
正在显示
11 个修改的文件
包含
116 行增加
和
24 行删除
deploy/k8s/dev/partner.yaml
deploy/k8s/prd/partner.yaml
deploy/k8s/test/partner.yaml
pkg/application/unifiedUserCenter/service/company.go
pkg/application/users/service/service.go
pkg/constant/common.go
pkg/domain/company.go
pkg/infrastructure/pg/models/company.go
pkg/infrastructure/repository/pg_company_reponsitory.go
pkg/infrastructure/serviceGateway/httplib_business-admin_service.go
pkg/infrastructure/serviceGateway/httplib_usercenter_service.go
deploy/k8s/dev/partner.yaml
查看文件 @
be2498c
...
...
@@ -76,6 +76,8 @@ spec:
value
:
"
39aefef9e22744a3b2d2d3791824ae7b"
-
name
:
UCENTER_CHECK_ALT
value
:
"
6DwjBO735"
-
name
:
BUSINESS_ADMIN_HOST
value
:
"
http://suplus-business-admin-dev.fjmaimaimai.com"
volumes
:
-
name
:
accesslogs
emptyDir
:
{}
...
...
deploy/k8s/prd/partner.yaml
查看文件 @
be2498c
...
...
@@ -76,6 +76,8 @@ spec:
value
:
"
39aefef9e22744a3b2d2d3791824ae7b"
-
name
:
UCENTER_CHECK_ALT
value
:
"
rsF0pL!6DwjBO735"
-
name
:
BUSINESS_ADMIN_HOST
value
:
"
http://suplus-business-admin-prd.fjmaimaimai.com"
volumes
:
-
name
:
accesslogs
emptyDir
:
{}
\ No newline at end of file
...
...
deploy/k8s/test/partner.yaml
查看文件 @
be2498c
...
...
@@ -73,6 +73,8 @@ spec:
value
:
"
39aefef9e22744a3b2d2d3791824ae7b"
-
name
:
UCENTER_CHECK_ALT
value
:
"
rsF0pL!6DwjBO735"
-
name
:
BUSINESS_ADMIN_HOST
value
:
"
http://suplus-business-admin-test.fjmaimaimai.com"
volumes
:
-
name
:
accesslogs
emptyDir
:
{}
...
...
pkg/application/unifiedUserCenter/service/company.go
查看文件 @
be2498c
...
...
@@ -22,7 +22,6 @@ type CompanyBase struct {
AdminCompanyId
int
`json:"admin_company_id"`
//总后台的公司id
Logo
string
`json:"logo"`
//公司图标
Remarks
string
`json:"remarks"`
//备注
Status
int8
`json:"status"`
Abbreviation
string
`json:"abbreviation"`
}
...
...
@@ -110,9 +109,9 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
Logo
:
data
.
Company
.
Logo
,
Remarks
:
data
.
Company
.
Remarks
,
AdminCompanyId
:
data
.
Company
.
AdminCompanyId
,
Status
:
data
.
Company
.
Status
,
Enable
:
domain
.
CompanyEnableNo
,
//默认初始化值
Abbreviation
:
data
.
Company
.
Abbreviation
,
//Status: data.Company.Status,
Enable
:
domain
.
CompanyEnableYes
,
//默认初始化值
Abbreviation
:
data
.
Company
.
Abbreviation
,
}
err
=
companyRespository
.
Add
(
&
comany
)
if
err
!=
nil
{
...
...
@@ -183,7 +182,6 @@ func (service SyncCompanyService) updateCompany(data CompanytData) error {
"Logo"
:
data
.
Company
.
Logo
,
"Remarks"
:
data
.
Company
.
Remarks
,
"AdminCompanyId"
:
data
.
Company
.
AdminCompanyId
,
"Status"
:
data
.
Company
.
Status
,
"Abbreviation"
:
data
.
Company
.
Abbreviation
,
})
entryTime
,
_
:=
time
.
Parse
(
"2006-01-02"
,
data
.
User
.
EntryTime
)
...
...
pkg/application/users/service/service.go
查看文件 @
be2498c
...
...
@@ -31,11 +31,23 @@ func (service UsersService) UserLoginBySecretKey(cmd command.LoginBySecretKeyCom
e
:=
fmt
.
Sprintf
(
"通过密钥(code=%s)从统一用户中心获取数据失败:%s"
,
cmd
.
Code
,
err
.
Error
())
return
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
e
)
}
err
=
loginResp
.
IsOK
()
if
err
!=
nil
{
if
err
:=
loginResp
.
IsOK
();
err
!=
nil
{
e
:=
fmt
.
Sprintf
(
"登录失败:%s"
,
err
)
return
nil
,
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
e
)
}
adminBusinessService
:=
serviceGateway
.
NewMmmBusinessAdminServiceGateway
()
getUserAuthResp
,
err
:=
adminBusinessService
.
GetUserAuth
(
loginResp
.
Data
.
Muid
)
if
err
!=
nil
{
e
:=
fmt
.
Sprintf
(
"用户鉴权失败:%s"
,
err
)
return
nil
,
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
e
)
}
if
err
:=
getUserAuthResp
.
IsOK
();
err
!=
nil
{
return
nil
,
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
"该公司没有操作权限"
)
}
if
!
getUserAuthResp
.
Data
.
UserAuth
{
return
nil
,
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
"该公司没有操作权限"
)
}
var
(
transactionContext
,
_
=
factory
.
CreateTransactionContext
(
nil
)
)
...
...
@@ -69,9 +81,6 @@ func (service UsersService) UserLoginBySecretKey(cmd command.LoginBySecretKeyCom
e
:=
fmt
.
Sprintf
(
"获取公司(admin_company_id=%d)数据失败:%s"
,
loginResp
.
Data
.
CompanyId
,
err
.
Error
())
return
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
e
)
}
if
!
companyData
.
EnableIsOk
()
{
return
nil
,
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
"该公司没有操作权限"
)
}
//检索本系统的用户数据
usersData
,
err
=
userRespository
.
FindOne
(
domain
.
UsersFindOneQuery
{
Id
:
loginResp
.
Data
.
Muid
,
...
...
pkg/constant/common.go
查看文件 @
be2498c
...
...
@@ -14,6 +14,10 @@ var (
UCENTER_CHECK_ALT
=
"rsF0pL!6DwjBO735"
)
var
(
BUSINESS_ADMIN_HOST
=
"http://suplus-business-admin-dev.fjmaimaimai.com"
//企业平台的地址
)
func
init
()
{
if
os
.
Getenv
(
"LOG_LEVEL"
)
!=
""
{
LOG_LEVEL
=
os
.
Getenv
(
"LOG_LEVEL"
)
...
...
@@ -31,4 +35,8 @@ func init() {
UCENTER_CHECK_ALT
=
os
.
Getenv
(
"UCENTER_CHECK_ALT"
)
}
if
os
.
Getenv
(
"BUSINESS_ADMIN_HOST"
)
!=
""
{
BUSINESS_ADMIN_HOST
=
os
.
Getenv
(
"BUSINESS_ADMIN_HOST"
)
}
}
...
...
pkg/domain/company.go
查看文件 @
be2498c
...
...
@@ -33,9 +33,7 @@ type Company struct {
Remarks
string
`json:"remarks"`
// 总后台的公司id
AdminCompanyId
int
`json:"adminCompanyId"`
// 状态 1正常 2禁用
Status
int8
`json:"status"`
//是否开启机会模块,是否有效【1:有效】【2:无效】
//是否有效【1:有效】【2:无效】
Enable
int8
`json:"enable"`
// 创建时间
CreateAt
time
.
Time
`json:"createAt"`
...
...
@@ -45,9 +43,9 @@ type Company struct {
DeleteAt
time
.
Time
`json:"deleteAt"`
}
func
(
c
Company
)
StatusIsOk
()
bool
{
return
c
.
Status
==
companyStatusUsable
}
// func (c Company) StatusIsOk() bool {
// return c.Status == companyStatusUsable
// }
func
(
c
Company
)
EnableIsOk
()
bool
{
return
c
.
Enable
==
CompanyEnableYes
...
...
@@ -72,9 +70,6 @@ func (c *Company) Update(m map[string]interface{}) error {
if
v
,
ok
:=
m
[
"Remarks"
];
ok
{
c
.
Remarks
=
fmt
.
Sprint
(
v
)
}
if
v
,
ok
:=
m
[
"Status"
];
ok
{
c
.
Status
=
v
.
(
int8
)
}
if
v
,
ok
:=
m
[
"Enable"
];
ok
{
c
.
Enable
=
v
.
(
int8
)
}
...
...
pkg/infrastructure/pg/models/company.go
查看文件 @
be2498c
...
...
@@ -25,7 +25,7 @@ type Company struct {
// 总后台的公司id
AdminCompanyId
int
// 状态 1正常 2禁用
Status
int8
//
Status int8
//是否开启机会模块,是否有效【1:有效】【2:无效】
Enable
int8
// 创建时间
...
...
pkg/infrastructure/repository/pg_company_reponsitory.go
查看文件 @
be2498c
...
...
@@ -32,7 +32,6 @@ func (repository CompanyRepository) transformPgModelToDomainModel(m *models.Comp
Logo
:
m
.
Logo
,
Remarks
:
m
.
Remarks
,
AdminCompanyId
:
m
.
AdminCompanyId
,
Status
:
m
.
Status
,
Enable
:
m
.
Enable
,
CreateAt
:
m
.
CreateAt
,
UpdateAt
:
m
.
UpdateAt
,
...
...
@@ -52,7 +51,6 @@ func (reponsitory CompanyRepository) Add(m *domain.Company) error {
Logo
:
m
.
Logo
,
Remarks
:
m
.
Remarks
,
AdminCompanyId
:
m
.
AdminCompanyId
,
Status
:
m
.
Status
,
Enable
:
m
.
Enable
,
CreateAt
:
m
.
CreateAt
,
UpdateAt
:
m
.
UpdateAt
,
...
...
@@ -74,7 +72,6 @@ func (reponsitory CompanyRepository) Edit(m *domain.Company) error {
Logo
:
m
.
Logo
,
Remarks
:
m
.
Remarks
,
AdminCompanyId
:
m
.
AdminCompanyId
,
Status
:
m
.
Status
,
Enable
:
m
.
Enable
,
CreateAt
:
m
.
CreateAt
,
DeleteAt
:
m
.
DeleteAt
,
...
...
pkg/infrastructure/serviceGateway/httplib_business-admin_service.go
0 → 100644
查看文件 @
be2498c
package
serviceGateway
import
(
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/astaxie/beego/logs"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
)
type
MmmBusinessAdminServiceGateway
struct
{
baseURL
string
}
func
NewMmmBusinessAdminServiceGateway
()
*
MmmBusinessAdminServiceGateway
{
return
&
MmmBusinessAdminServiceGateway
{
baseURL
:
constant
.
BUSINESS_ADMIN_HOST
,
}
}
type
ResponseGetUserAuth
struct
{
UCenterCommonMsg
Data
struct
{
UserAuth
bool
`json:"userAuth"`
}
`json:"data"`
}
func
(
gateway
MmmBusinessAdminServiceGateway
)
httpDo
(
reqURL
string
,
mathod
string
,
bodyData
interface
{})
([]
byte
,
error
)
{
httpclient
:=
http
.
Client
{
Timeout
:
60
*
time
.
Second
,
//请求超时时间60秒
}
bt
:=
&
bytes
.
Buffer
{}
if
bodyData
!=
nil
{
enc
:=
json
.
NewEncoder
(
bt
)
enc
.
Encode
(
bodyData
)
}
logs
.
Info
(
"====>Send To URL:%s"
,
reqURL
)
logs
.
Info
(
"====>Send To BusinessAdmin:%s"
,
bt
.
String
())
req
,
err
:=
http
.
NewRequest
(
mathod
,
reqURL
,
bt
)
if
err
!=
nil
{
return
nil
,
err
}
resp
,
err
:=
httpclient
.
Do
(
req
)
if
err
!=
nil
{
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
return
nil
,
err
}
logs
.
Info
(
"<====BusinessAdmin Return:%s"
,
string
(
body
))
return
body
,
nil
}
func
(
gateway
MmmBusinessAdminServiceGateway
)
GetUserAuth
(
userId
int64
)
(
*
ResponseGetUserAuth
,
error
)
{
param
:=
map
[
string
]
interface
{}{}
url
:=
gateway
.
baseURL
+
"/auth/get-user-auth"
byteData
,
err
:=
gateway
.
httpDo
(
url
,
"POST"
,
param
)
if
err
!=
nil
{
return
nil
,
err
}
respData
:=
&
ResponseGetUserAuth
{}
err
=
json
.
Unmarshal
(
byteData
,
respData
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"body data %s; err:%s"
,
string
(
byteData
),
err
)
}
return
respData
,
nil
}
...
...
pkg/infrastructure/serviceGateway/httplib_usercenter_service.go
查看文件 @
be2498c
...
...
@@ -10,6 +10,7 @@ import (
"net/url"
"time"
"github.com/astaxie/beego/logs"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
)
...
...
@@ -59,6 +60,8 @@ func (gateway MmmUserCenterServiceGateway) httpDo(reqURL string, mathod string,
enc
:=
json
.
NewEncoder
(
bt
)
enc
.
Encode
(
bodyData
)
}
logs
.
Info
(
"====>Send To URL:%s"
,
reqURL
)
logs
.
Info
(
"====>Send To BusinessAdmin:%s"
,
bt
.
String
())
req
,
err
:=
http
.
NewRequest
(
mathod
,
reqURL
,
bt
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -73,6 +76,7 @@ func (gateway MmmUserCenterServiceGateway) httpDo(reqURL string, mathod string,
if
err
!=
nil
{
return
nil
,
err
}
logs
.
Info
(
"<====BusinessAdmin Return:%s"
,
string
(
body
))
return
body
,
nil
}
...
...
@@ -97,7 +101,7 @@ func (gateway MmmUserCenterServiceGateway) RequestUCenterLoginBySecret(secret st
"type"
:
3
,
//登录方式 固定值
"secret"
:
url
.
QueryEscape
(
secret
),
//必要的转换
}
url
:=
constant
.
UCENTER_HOST
+
"/auth/serverLogin"
url
:=
gateway
.
baseURL
+
"/auth/serverLogin"
byteData
,
err
:=
gateway
.
httpDo
(
url
,
"POST"
,
param
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -109,3 +113,5 @@ func (gateway MmmUserCenterServiceGateway) RequestUCenterLoginBySecret(secret st
}
return
respData
,
nil
}
//企业鉴权 接口
...
...
请
注册
或
登录
后发表评论