切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
唐旭辉
5 years ago
提交
f7f6823cab73ea362a75f30c27d8790644c87081
1 个父辈
ec1d9e69
紧急更新 合伙人新增类型:业务-产品应用合伙人
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
93 行增加
和
56 行删除
pkg/application/partnerInfo/command/create_partner_info.go
pkg/application/partnerInfo/command/update_partner_info.go
pkg/constant/common.go
pkg/domain/partner_info.go
pkg/infrastructure/service_gateway/httplib_service_gateway.go
pkg/infrastructure/service_gateway/httplib_usercenter_service.go
pkg/application/partnerInfo/command/create_partner_info.go
查看文件 @
f7f6823
...
...
@@ -32,7 +32,8 @@ func (command CreatePartnerInfoCommand) ValidateCommand() error {
}
if
!
(
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_1
||
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_2
||
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_3
)
{
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_3
||
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_4
)
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙类别错误"
)
}
if
len
(
command
.
PartnerName
)
==
0
{
...
...
pkg/application/partnerInfo/command/update_partner_info.go
查看文件 @
f7f6823
...
...
@@ -28,7 +28,8 @@ func (command *UpdatePartnerInfoCommand) ValidateCommand() error {
}
if
!
(
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_1
||
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_2
||
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_3
)
{
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_3
||
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_4
)
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙类别错误"
)
}
if
command
.
RegionInfo
==
nil
{
...
...
pkg/constant/common.go
查看文件 @
f7f6823
...
...
@@ -7,8 +7,28 @@ const SERVICE_NAME = "partnermg"
var
LOG_LEVEL
=
"debug"
var
LOG_File
=
"./logs/partnermg.log"
var
(
UCENTER_HOST
=
"http://suplus-ucenter-dev.fjmaimaimai.com"
//统一用户中心地址
UCENTER_SECRET
=
"cykbjnfqgctn"
UCENTER_APP_KEY
=
"39aefef9e22744a3b2d2d3791824ae7b"
UCENTER_CHECK_ALT
=
"rsF0pL!6DwjBO735"
)
func
init
()
{
if
os
.
Getenv
(
"LOG_LEVEL"
)
!=
""
{
LOG_LEVEL
=
os
.
Getenv
(
"LOG_LEVEL"
)
}
if
os
.
Getenv
(
"UCENTER_HOST"
)
!=
""
{
LOG_LEVEL
=
os
.
Getenv
(
"UCENTER_HOST"
)
}
if
os
.
Getenv
(
"UCENTER_SECRET"
)
!=
""
{
LOG_LEVEL
=
os
.
Getenv
(
"UCENTER_SECRET"
)
}
if
os
.
Getenv
(
"UCENTER_APP_KEY"
)
!=
""
{
LOG_LEVEL
=
os
.
Getenv
(
"UCENTER_APP_KEY"
)
}
if
os
.
Getenv
(
"UCENTER_CHECK_ALT"
)
!=
""
{
LOG_LEVEL
=
os
.
Getenv
(
"UCENTER_CHECK_ALT"
)
}
}
...
...
pkg/domain/partner_info.go
查看文件 @
f7f6823
...
...
@@ -11,12 +11,12 @@ const (
PARTNER_STATUS_YES
int
=
1
)
//合伙类别 (1.事业合伙人 2.业务合伙人 4.研发合伙人)
//按二进制位区分:001 = 1; 010 = 2; 100=4
//合伙类别 (1.事业合伙人 2.业务合伙人 3.研发合伙人)
const
(
PARTNER_CATEGORY_1
int
=
1
PARTNER_CATEGORY_2
int
=
2
PARTNER_CATEGORY_3
int
=
4
PARTNER_CATEGORY_3
int
=
3
PARTNER_CATEGORY_4
int
=
4
)
//partnerCategoryMap 合伙类别键值对 (只读,请勿在运行时修改)
...
...
@@ -24,6 +24,7 @@ var partnerCategoryMap = map[int]string{
PARTNER_CATEGORY_1
:
"事业合伙人"
,
PARTNER_CATEGORY_2
:
"业务合伙人"
,
PARTNER_CATEGORY_3
:
"研发合伙人"
,
PARTNER_CATEGORY_4
:
"业务-产品应用合伙人"
,
}
type
PartnerInfo
struct
{
...
...
pkg/infrastructure/service_gateway/httplib_service_gateway.go
查看文件 @
f7f6823
package
service_gateway
import
(
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"github.com/astaxie/beego/httplib"
)
type
httplibBaseServiceGateway
struct
{
...
...
@@ -15,48 +9,3 @@ type httplibBaseServiceGateway struct {
connectTimeout
time
.
Duration
readWriteTimeout
time
.
Duration
}
func
(
serviceGateway
*
httplibBaseServiceGateway
)
createRequest
(
url
string
,
method
string
)
*
httplib
.
BeegoHTTPRequest
{
var
request
*
httplib
.
BeegoHTTPRequest
switch
method
{
case
"get"
:
request
=
httplib
.
Get
(
url
)
break
case
"post"
:
request
=
httplib
.
Post
(
url
)
break
case
"put"
:
request
=
httplib
.
Put
(
url
)
break
case
"delete"
:
request
=
httplib
.
Delete
(
url
)
break
case
"head"
:
request
=
httplib
.
Head
(
url
)
break
default
:
request
=
httplib
.
Get
(
url
)
}
return
request
.
SetTimeout
(
serviceGateway
.
connectTimeout
,
serviceGateway
.
readWriteTimeout
)
}
func
(
serviceGateway
*
httplibBaseServiceGateway
)
responseHandle
(
response
map
[
string
]
interface
{})
(
map
[
string
]
interface
{},
error
)
{
data
:=
make
(
map
[
string
]
interface
{})
var
err
error
if
code
,
ok
:=
response
[
"code"
];
ok
{
code
:=
code
.
(
float64
)
if
code
==
0
{
data
=
response
[
"data"
]
.
(
map
[
string
]
interface
{})
}
else
{
msg
:=
response
[
"msg"
]
.
(
string
)
err
=
fmt
.
Errorf
(
strings
.
Join
([]
string
{
strconv
.
FormatFloat
(
code
,
'f'
,
-
1
,
64
),
msg
},
" "
))
}
}
else
{
jsonBytes
,
marshalErr
:=
json
.
Marshal
(
response
)
if
marshalErr
!=
nil
{
err
=
marshalErr
}
err
=
fmt
.
Errorf
(
"无法解析的网关服务数据返回格式:%s"
,
string
(
jsonBytes
))
}
return
data
,
err
}
...
...
pkg/infrastructure/service_gateway/httplib_usercenter_service.go
0 → 100644
查看文件 @
f7f6823
package
service_gateway
import
(
"crypto/sha1"
"fmt"
"net/http"
"time"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
)
type
MmmUserCenterServiceGateway
struct
{
httplibBaseServiceGateway
}
func
NewMmmUserCenterServiceGateway
()
*
MmmUserCenterServiceGateway
{
return
&
MmmUserCenterServiceGateway
{
httplibBaseServiceGateway
{
baseURL
:
constant
.
UCENTER_HOST
,
connectTimeout
:
100
*
time
.
Second
,
readWriteTimeout
:
30
*
time
.
Second
,
}}
}
func
(
gateway
MmmUserCenterServiceGateway
)
buildHeader
()
http
.
Header
{
var
h
=
http
.
Header
{}
nowTime
:=
fmt
.
Sprint
(
time
.
Now
()
.
Unix
())
str
:=
fmt
.
Sprintf
(
"%s%s%s"
,
nowTime
,
constant
.
UCENTER_SECRET
,
constant
.
UCENTER_CHECK_ALT
)
bt
:=
sha1
.
Sum
([]
byte
(
str
))
checksum
:=
fmt
.
Sprintf
(
"%x"
,
bt
)
h
.
Set
(
"Content-Type"
,
"application/json"
)
h
.
Set
(
"appKey"
,
constant
.
UCENTER_APP_KEY
)
h
.
Set
(
"nonce"
,
""
)
h
.
Set
(
"curTime"
,
nowTime
)
h
.
Set
(
"checkSum"
,
checksum
)
h
.
Set
(
"Accept"
,
"application/json"
)
return
h
}
type
ResponseLogin
struct
{
Code
int
`json:"code"`
Msg
string
`json:"msg"`
Data
struct
{
Id
int64
`json:"id"`
//统一用户中心的id,对应本系统中users表的open_id
Phone
string
`json:"phone"`
NickName
string
`json:"nickname"`
//昵称
Avatar
string
`json:"avatar"`
//头像
Imtoken
string
`json:"imtoken"`
//网易云imtoken
Accid
int64
`json:"accid"`
//网易云id
CustomerAccount
int64
`json:"customerAccount"`
//客服id
CompanyId
int64
`json:"companyId"`
//总后台的公司id
Muid
int64
`json:"muid"`
//企业平台的用户id,对应本系统中users表的id
}
`json:"data"`
}
func
(
gateway
MmmUserCenterServiceGateway
)
RequestUCenterLoginBySecret
(
secret
string
)
(
*
ResponseLogin
,
error
)
{
// param := map[string]interface{}{
// "type": 3, //登录方式 固定值
// "secret": url.QueryEscape(secret), //必要的转换
// }
// url := "/auth/serverLogin"
// httpRequest := gateway.createRequest(url, "post")
// httpRequest.
return
nil
,
nil
}
...
...
请
注册
或
登录
后发表评论