refactor(passport): 重构设备注册请求结构体字段命名
- 将 RegDeviceRequest 结构体字段从小写改为大写首字母 - 更新 getSign 方法中字段引用以匹配新的命名规范 - 修改 initRemoteLoginRequest 中的字段赋值操作 - 调整 import 语句顺序并添加空行改善代码格式
This commit is contained in:
parent
063071bed0
commit
6a27326496
@ -3,26 +3,27 @@ package passport
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
type RegDeviceRequest struct {
|
||||
*requests.RpcRequest
|
||||
do string `position:"Body" field:"do" default:""`
|
||||
act string `position:"Body" field:"act" default:""`
|
||||
time int64 `position:"Body" field:"time" default:"0"`
|
||||
sign string `position:"Body" field:"sign" default:""`
|
||||
users string `position:"Body" field:"username" default:""`
|
||||
Do string `position:"Body" field:"do" default:""`
|
||||
Act string `position:"Body" field:"act" default:""`
|
||||
Time int64 `position:"Body" field:"time" default:"0"`
|
||||
Sign string `position:"Body" field:"sign" default:""`
|
||||
Users string `position:"Body" field:"username" default:""`
|
||||
}
|
||||
|
||||
func (b *RegDeviceRequest) getSign() {
|
||||
b.time = time.Now().Unix()
|
||||
rawStr := fmt.Sprintf("%d%s", b.time, KEY)
|
||||
b.Time = time.Now().Unix()
|
||||
rawStr := fmt.Sprintf("%d%s", b.Time, KEY)
|
||||
sign := md5.Sum([]byte(rawStr))
|
||||
b.sign = fmt.Sprintf("%x", sign)
|
||||
b.Sign = fmt.Sprintf("%x", sign)
|
||||
}
|
||||
|
||||
func (b *RegDeviceRequest) initRemoteLoginRequest() {
|
||||
@ -49,9 +50,9 @@ func CreateRegDeviceRequest(users ...string) (req *RegDeviceRequest) {
|
||||
}
|
||||
|
||||
req.getSign()
|
||||
req.users = strings.Join(users, ",")
|
||||
req.do = "get_reg_device_by_username"
|
||||
req.act = "info"
|
||||
req.Users = strings.Join(users, ",")
|
||||
req.Do = "get_reg_device_by_username"
|
||||
req.Act = "info"
|
||||
req.initRemoteLoginRequest()
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user