Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenweijian
hilo-user
Commits
c8ceb9f4
Commit
c8ceb9f4
authored
Jun 29, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
派对申请
parent
bbd96593
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
16 deletions
+70
-16
bizCode.go
myerr/bizerr/bizCode.go
+1
-0
party_invite.go
route/invite_r/party_invite.go
+15
-16
middleHandle.go
route/middleHandle.go
+54
-0
No files found.
myerr/bizerr/bizCode.go
View file @
c8ceb9f4
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
var
(
var
(
// 一般性错误
// 一般性错误
HttpSecret
=
myerr
.
NewBusinessCode
(
1000
,
"http secret err"
,
myerr
.
BusinessData
{})
TokenInvalid
=
myerr
.
NewBusinessCode
(
1001
,
"token invalid"
,
myerr
.
BusinessData
{})
TokenInvalid
=
myerr
.
NewBusinessCode
(
1001
,
"token invalid"
,
myerr
.
BusinessData
{})
ExternalIdNoExist
=
myerr
.
NewBusinessCode
(
1003
,
"externalId no exist"
,
myerr
.
BusinessData
{})
ExternalIdNoExist
=
myerr
.
NewBusinessCode
(
1003
,
"externalId no exist"
,
myerr
.
BusinessData
{})
CodeNoExist
=
myerr
.
NewBusinessCode
(
1005
,
"code no exist"
,
myerr
.
BusinessData
{})
CodeNoExist
=
myerr
.
NewBusinessCode
(
1005
,
"code no exist"
,
myerr
.
BusinessData
{})
...
...
route/invite_r/party_invite.go
View file @
c8ceb9f4
...
@@ -10,7 +10,6 @@ import (
...
@@ -10,7 +10,6 @@ import (
"hilo-user/domain/model/invite_m"
"hilo-user/domain/model/invite_m"
"hilo-user/domain/model/promotion_m"
"hilo-user/domain/model/promotion_m"
"hilo-user/domain/model/user_m"
"hilo-user/domain/model/user_m"
"hilo-user/myerr"
"hilo-user/myerr/bizerr"
"hilo-user/myerr/bizerr"
"hilo-user/req"
"hilo-user/req"
"hilo-user/resp"
"hilo-user/resp"
...
@@ -131,8 +130,8 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -131,8 +130,8 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
type
paramStr
struct
{
type
paramStr
struct
{
PageIndex
int
`form:"pageIndex" binding:"required"`
PageIndex
int
`form:"pageIndex" binding:"required"`
PageSize
int
`form:"pageSize" binding:"required"`
PageSize
int
`form:"pageSize" binding:"required"`
BeginTime
string
`form:"beginTime" binding:"required
"`
BeginTime
time
.
Time
`form:"beginTime" binding:"required" time_format:"2006-01-02
"`
EndTime
string
`form:"endTime" binding:"required
"`
EndTime
time
.
Time
`form:"endTime" binding:"required" time_format:"2006-01-02
"`
Type
int
`form:"type" binding:"required"`
Type
int
`form:"type" binding:"required"`
}
}
...
@@ -144,15 +143,15 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -144,15 +143,15 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
bizerr
.
InvalidParameter
return
myCtx
,
bizerr
.
InvalidParameter
}
}
beginTime
,
err
:=
time
.
ParseInLocation
(
utils
.
DATE_FORMAT
,
param
.
BeginTime
,
time
.
Local
)
//
beginTime, err := time.ParseInLocation(utils.DATE_FORMAT, param.BeginTime, time.Local)
if
err
!=
nil
{
//
if err != nil {
return
nil
,
myerr
.
WrapErr
(
err
)
//
return nil, myerr.WrapErr(err)
}
//
}
endTime
,
err
:=
time
.
ParseInLocation
(
utils
.
DATE_FORMAT
,
param
.
EndTime
,
time
.
Local
)
//
endTime, err := time.ParseInLocation(utils.DATE_FORMAT, param.EndTime, time.Local)
if
err
!=
nil
{
//
if err != nil {
return
nil
,
myerr
.
WrapErr
(
err
)
//
return nil, myerr.WrapErr(err)
}
//
}
endTime
=
utils
.
GetDayEndTime
(
e
ndTime
)
param
.
EndTime
=
utils
.
GetDayEndTime
(
param
.
E
ndTime
)
userId
,
err
:=
req
.
GetUserId
(
c
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myCtx
,
err
return
myCtx
,
err
...
@@ -168,7 +167,7 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -168,7 +167,7 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
}
}
}
}
list
,
total
,
err
:=
invite_m
.
GetApplyList
(
model
,
agentIds
,
param
.
PageIndex
,
param
.
PageSize
,
param
.
Type
,
beginTime
,
e
ndTime
)
list
,
total
,
err
:=
invite_m
.
GetApplyList
(
model
,
agentIds
,
param
.
PageIndex
,
param
.
PageSize
,
param
.
Type
,
param
.
BeginTime
,
param
.
E
ndTime
)
if
err
!=
nil
{
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetApplyList param:%v, err:%v"
,
param
,
err
)
model
.
Log
.
Errorf
(
"GetApplyList param:%v, err:%v"
,
param
,
err
)
return
myCtx
,
err
return
myCtx
,
err
...
...
route/middleHandle.go
View file @
c8ceb9f4
...
@@ -2,6 +2,8 @@ package route
...
@@ -2,6 +2,8 @@ package route
import
(
import
(
"bytes"
"bytes"
"crypto/md5"
"fmt"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/resource/config"
...
@@ -12,6 +14,7 @@ import (
...
@@ -12,6 +14,7 @@ import (
"hilo-user/resp"
"hilo-user/resp"
"io/ioutil"
"io/ioutil"
"runtime/debug"
"runtime/debug"
"strconv"
"strings"
"strings"
"time"
"time"
)
)
...
@@ -133,3 +136,54 @@ func LoggerHandle(c *gin.Context) {
...
@@ -133,3 +136,54 @@ func LoggerHandle(c *gin.Context) {
latency
:=
end
.
Sub
(
start
)
latency
:=
end
.
Sub
(
start
)
mycontext
.
CreateMyContext
(
c
.
Keys
)
.
Log
.
Infof
(
"request end fullPath:%v,url:%v, method: %v, traceId:%v, latency:%v userId:%v"
,
c
.
FullPath
(),
reqUri
,
method
,
traceId
,
latency
,
userId
)
mycontext
.
CreateMyContext
(
c
.
Keys
)
.
Log
.
Infof
(
"request end fullPath:%v,url:%v, method: %v, traceId:%v, latency:%v userId:%v"
,
c
.
FullPath
(),
reqUri
,
method
,
traceId
,
latency
,
userId
)
}
}
//http信息解密(web)
func
HttpWebSecretHandle
(
c
*
gin
.
Context
)
{
traceId
,
_
:=
c
.
Keys
[
mycontext
.
TRACEID
]
timestamp
:=
c
.
GetHeader
(
"timestamp"
)
//时间戳,单位秒
nonce
:=
c
.
GetHeader
(
"nonce"
)
//随机数字
signature
:=
c
.
GetHeader
(
"signature"
)
//sha1加密结果
mylogrus
.
MyLog
.
Debugf
(
"handle secret begin timestamp:%v, nonce:%v, signature:%v traceId:%v"
,
timestamp
,
nonce
,
signature
,
traceId
)
if
nonce
==
"hilo"
{
mylogrus
.
MyLog
.
Infof
(
"no check http secret handle"
)
}
else
{
if
timestamp
==
""
||
nonce
==
""
||
signature
==
""
{
resp
.
ResponseBusiness
(
c
,
bizerr
.
HttpSecret
)
c
.
Abort
()
return
}
timestampInt
,
err
:=
strconv
.
ParseInt
(
timestamp
,
10
,
64
)
if
err
!=
nil
{
resp
.
ResponseBusiness
(
c
,
bizerr
.
HttpSecret
)
c
.
Abort
()
return
}
nowTimestamp
:=
time
.
Now
()
.
Unix
()
v
:=
nowTimestamp
-
timestampInt
//10分钟内有效,改成60分钟,20210402产品让我改成60分钟,原因:依旧有用户时间戳不对,达到了30分钟
if
v
<
-
60
*
60
||
v
>
60
*
60
{
mylogrus
.
MyLog
.
Warnf
(
"handle secret err, timestampInt:%v, nowTimestamp:%v, v:%v, traceId:%v"
,
timestampInt
,
nowTimestamp
,
v
,
traceId
)
//2021/11/05 产品让我关的,因为中东用户时间戳有问题
/* ResponseBusiness(c, bizerr.HttpSecret)
c.Abort()
return*/
}
str
:=
timestamp
+
config
.
GetConfigApp
()
.
WEB_SECRET
+
nonce
//避免web的暴露,让用户知道app的api加密方式。
h
:=
md5
.
New
()
//h := sha1.New()
h
.
Write
([]
byte
(
str
))
newSignature
:=
fmt
.
Sprintf
(
"%x"
,
h
.
Sum
(
nil
))
//newSignature := string(sha1.New().Sum([]byte(str))[:])
if
signature
!=
newSignature
{
mylogrus
.
MyLog
.
Errorf
(
"handle secret err signature:%v, newSignature:%v, traceId:%v"
,
signature
,
newSignature
,
traceId
)
resp
.
ResponseBusiness
(
c
,
bizerr
.
HttpSecret
)
c
.
Abort
()
return
}
}
c
.
Next
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment