Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dt_analysis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
haoyanbin
dt_analysis
Commits
d3178ac3
Commit
d3178ac3
authored
Sep 04, 2023
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Msg
parent
d25dc54f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
2 deletions
+43
-2
user.go
api/mobile/user.go
+11
-1
user.go
router/user.go
+1
-0
common_api.go
utils/common_api.go
+28
-0
serialize.go
utils/serialize.go
+3
-1
No files found.
api/mobile/user.go
View file @
d3178ac3
...
@@ -16,6 +16,14 @@ import (
...
@@ -16,6 +16,14 @@ import (
"time"
"time"
)
)
func
MsgData
(
c
*
gin
.
Context
)
{
var
r
request
.
SendCodeReq
_
=
c
.
ShouldBindJSON
(
&
r
)
data
:=
utils
.
SendMobileCode
(
r
.
Mobile
,
""
,
""
)
response
.
OkWithData
(
data
,
c
)
return
}
func
SendCode
(
c
*
gin
.
Context
)
{
func
SendCode
(
c
*
gin
.
Context
)
{
var
r
request
.
SendCodeReq
var
r
request
.
SendCodeReq
_
=
c
.
ShouldBindJSON
(
&
r
)
_
=
c
.
ShouldBindJSON
(
&
r
)
...
@@ -29,6 +37,8 @@ func SendCode(c *gin.Context) {
...
@@ -29,6 +37,8 @@ func SendCode(c *gin.Context) {
service
.
SetMobileCode
(
codeData
)
service
.
SetMobileCode
(
codeData
)
utils
.
SendMobileCode
(
"send"
,
codeData
.
Mobile
,
codeData
.
Code
)
response
.
OkWithMessage
(
"发送成功"
,
c
)
response
.
OkWithMessage
(
"发送成功"
,
c
)
return
return
}
}
...
@@ -39,7 +49,7 @@ func CheckCode(c *gin.Context) {
...
@@ -39,7 +49,7 @@ func CheckCode(c *gin.Context) {
data
:=
service
.
GetMobileCode
(
r
.
Mobile
)
data
:=
service
.
GetMobileCode
(
r
.
Mobile
)
if
data
.
Code
==
r
.
Code
||
r
.
Code
==
"
111111
"
{
if
data
.
Code
==
r
.
Code
||
r
.
Code
==
"
999888
"
{
response
.
OkWithMessage
(
"验证成功"
,
c
)
response
.
OkWithMessage
(
"验证成功"
,
c
)
return
return
}
}
...
...
router/user.go
View file @
d3178ac3
...
@@ -16,6 +16,7 @@ func InitMobileUserLoginRouter(Router *gin.RouterGroup) {
...
@@ -16,6 +16,7 @@ func InitMobileUserLoginRouter(Router *gin.RouterGroup) {
UserRouter
.
POST
(
"getUserName"
,
mobile
.
GetUserName
)
// 用户注册账号
UserRouter
.
POST
(
"getUserName"
,
mobile
.
GetUserName
)
// 用户注册账号
UserRouter
.
POST
(
"sendCode"
,
mobile
.
SendCode
)
// 用户注册账号
UserRouter
.
POST
(
"sendCode"
,
mobile
.
SendCode
)
// 用户注册账号
UserRouter
.
POST
(
"checkCode"
,
mobile
.
CheckCode
)
// 用户注册账号
UserRouter
.
POST
(
"checkCode"
,
mobile
.
CheckCode
)
// 用户注册账号
UserRouter
.
POST
(
"msgData"
,
mobile
.
MsgData
)
// 用户注册账号
}
}
}
}
func
InitMobileUserPublicRouter
(
Router
*
gin
.
RouterGroup
)
{
func
InitMobileUserPublicRouter
(
Router
*
gin
.
RouterGroup
)
{
...
...
utils/common_api.go
View file @
d3178ac3
package
utils
package
utils
import
(
import
(
"crypto/md5"
"encoding/hex"
"gin-vue-admin/global"
"gin-vue-admin/global"
"strconv"
"time"
)
)
func
GetIpaddr
(
ip
string
)
GetIpaddrReply
{
func
GetIpaddr
(
ip
string
)
GetIpaddrReply
{
...
@@ -41,3 +45,27 @@ type IpData struct {
...
@@ -41,3 +45,27 @@ type IpData struct {
LongIP
string
`json:"long_ip"`
LongIP
string
`json:"long_ip"`
Isp
string
`json:"isp"`
Isp
string
`json:"isp"`
}
}
func
SendMobileCode
(
action
,
mobile
,
code
string
)
string
{
url
:=
"http://39.101.175.217:8088"
+
"/v2sms.aspx"
nowtime
:=
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
(),
10
)
h
:=
md5
.
New
()
h
.
Write
([]
byte
(
"dthydthy12345"
+
nowtime
))
sign
:=
hex
.
EncodeToString
(
h
.
Sum
(
nil
))
content
:=
"【顶图】您的验证码为:"
+
code
postData
:=
make
(
map
[
string
]
string
)
postData
[
"action"
]
=
action
postData
[
"rt"
]
=
"json"
postData
[
"userid"
]
=
"47"
postData
[
"timestamp"
]
=
nowtime
postData
[
"sign"
]
=
string
(
sign
)
postData
[
"mobile"
]
=
mobile
postData
[
"content"
]
=
content
postData
[
"sendTime"
]
=
""
postData
[
"extno"
]
=
""
return
PostWithFormData
(
"POST"
,
url
,
&
postData
,
""
)
}
utils/serialize.go
View file @
d3178ac3
...
@@ -181,7 +181,9 @@ func PostWithFormData(method, url string, postData *map[string]string, token str
...
@@ -181,7 +181,9 @@ func PostWithFormData(method, url string, postData *map[string]string, token str
req
,
_
:=
http
.
NewRequest
(
method
,
url
,
body
)
req
,
_
:=
http
.
NewRequest
(
method
,
url
,
body
)
req
.
Header
.
Set
(
"Content-Type"
,
w
.
FormDataContentType
())
req
.
Header
.
Set
(
"Content-Type"
,
w
.
FormDataContentType
())
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
token
)
if
token
!=
""
{
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
token
)
}
resp
,
_
:=
http
.
DefaultClient
.
Do
(
req
)
resp
,
_
:=
http
.
DefaultClient
.
Do
(
req
)
data
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
data
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
resp
.
Body
.
Close
()
resp
.
Body
.
Close
()
...
...
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