Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
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
haoban3.0
haoban-manage3.0
Commits
0b265281
Commit
0b265281
authored
Jul 11, 2024
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企微托管
parent
04bf3326
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletions
+30
-1
SendCodeController.java
.../gic/haoban/manage/web/controller/SendCodeController.java
+30
-1
No files found.
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/SendCodeController.java
View file @
0b265281
...
...
@@ -3,6 +3,8 @@ package com.gic.haoban.manage.web.controller;
import
com.alibaba.fastjson.JSON
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.commons.util.DateUtil
;
import
com.gic.commons.util.GlobalVar
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.common.utils.CheckSmsCodeUtil
;
import
com.gic.haoban.common.utils.GooglePhoneNumberUtil
;
...
...
@@ -11,6 +13,7 @@ import com.gic.haoban.manage.api.response.SendSmsResponse;
import
com.gic.haoban.manage.api.service.ValidationCodeApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.task.allocation.util.MemCachedInstance
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Date
;
@RestController
public
class
SendCodeController
extends
WebBaseController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
SendCodeController
.
class
);
...
...
@@ -27,6 +32,8 @@ public class SendCodeController extends WebBaseController {
private
ValidationCodeApiService
validationCodeService
;
@Autowired
private
ClerkService
clerkService
;
static
MemCachedInstance
memCachedInstance
=
MemCachedInstance
.
getInstance
(
GlobalVar
.
getMemCachedIp
(),
GlobalVar
.
getMemCachedPort
());
/**
* 验证码发送
...
...
@@ -61,7 +68,10 @@ public class SendCodeController extends WebBaseController {
}
else
{
RedisUtil
.
setCache
(
cacheKey
,
true
,
60L
);
}
if
(
this
.
getVcodeTimes
(
phoneNumber
)
<=
0
)
{
logger
.
info
(
"验证 达到上线"
);
return
this
.
fail
(
"验证码发送达到上限"
)
;
}
String
smsCode
=
""
;
if
(
CheckSmsCodeUtil
.
getCacheSmsCode
(
nationcode
+
"-"
+
phoneNumber
,
type
)
!=
null
)
{
smsCode
=
(
String
)
CheckSmsCodeUtil
.
getCacheSmsCode
(
nationcode
+
"-"
+
phoneNumber
,
type
);
...
...
@@ -111,4 +121,23 @@ public class SendCodeController extends WebBaseController {
}
}
public
static
int
getVcodeTimes
(
String
phoneNumber
)
{
String
key
=
phoneNumber
+
DateUtil
.
dateToStr
(
new
Date
(),
DateUtil
.
FORMAT_DATE_8
);
int
times
=
10
;
Object
res
=
memCachedInstance
.
getValue
(
key
);
logger
.
info
(
"好办验证码次数={}"
,
res
);
if
(
null
==
res
)
{
memCachedInstance
.
setValue
(
key
,
10
,
24
*
60
*
60
*
1000
);
}
else
{
times
=
Integer
.
parseInt
(
String
.
valueOf
(
res
));
}
if
(
times
>
0
)
{
memCachedInstance
.
setValue
(
key
,
(
times
-
1
),
24
*
60
*
60
*
1000
);
}
return
times
;
}
}
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