Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
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
base_platform_enterprise
gic-platform-auth
Commits
4f832ea2
Commit
4f832ea2
authored
Nov 21, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
dfe8edb3
10b7b262
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
AuthCodeController.java
.../java/com/gic/auth/web/controller/AuthCodeController.java
+33
-4
No files found.
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/AuthCodeController.java
View file @
4f832ea2
...
...
@@ -2,9 +2,16 @@ package com.gic.auth.web.controller;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.AuthCodeDTO
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.service.AuthCodeApiService
;
import
com.gic.auth.service.UserApiService
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.service.EnterpriseApiService
;
import
com.gic.enterprise.utils.CreateRandomUtils
;
import
com.gic.enterprise.utils.UserDetailUtils
;
import
com.gic.marketing.process.api.service.sms.SmsSendApiService
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -20,12 +27,20 @@ public class AuthCodeController {
@Autowired
private
AuthCodeApiService
authCodeApiService
;
@Autowired
private
EnterpriseApiService
enterpriseApiService
;
@Autowired
private
UserApiService
userApiService
;
@Autowired
private
SmsSendApiService
smsSendApiService
;
@RequestMapping
(
"send-auth-code"
)
public
RestResponse
sendAuthCode
(
Integer
eid
){
if
(
eid
==
null
){
return
RestResponse
.
failure
(
ErrorCode
.
NOTEXISTS
.
getCode
(),
"商户不存在"
);
}
Integer
enterpriseId
=
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
();
//todo 调用发送验证码模块获取验证码
String
code
=
"12345"
;
String
code
=
CreateRandomUtils
.
getStringRandom
(
4
);
AuthCodeDTO
authCodeDTO
=
new
AuthCodeDTO
();
authCodeDTO
.
setAuthCode
(
code
);
authCodeDTO
.
setEnterpriseId
(
enterpriseId
);
...
...
@@ -34,8 +49,22 @@ public class AuthCodeController {
calendar
.
setTime
(
new
Date
());
calendar
.
add
(
Calendar
.
MINUTE
,
5
);
authCodeDTO
.
setExpirationTime
(
calendar
.
getTime
());
ServiceResponse
<
Integer
>
serviceResponse
=
this
.
authCodeApiService
.
saveAuth
(
authCodeDTO
);
return
RestResponse
.
success
(
serviceResponse
.
getResult
());
//发送手机验证码
ServiceResponse
<
EnterpriseDTO
>
enterprise
=
this
.
enterpriseApiService
.
getEnterpriseById
(
eid
);
if
(
enterprise
.
isSuccess
()
&&
enterprise
.
getResult
()
!=
null
){
String
enterpriseName
=
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseName
();
ServiceResponse
<
UserDTO
>
user
=
this
.
userApiService
.
getUserByEnterpriseId
(
eid
);
String
[]
smsArr
=
new
String
[]
{
enterprise
.
getResult
().
getEnterpriseName
(),
enterpriseName
,
code
,
enterpriseName
};
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
"GICUnionEnterprise"
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseId
(),
user
.
getResult
().
getPhoneAreaCode
(),
user
.
getResult
().
getPhoneNumber
(),
smsArr
);
if
(
smsSendResult
.
isSuccess
()){
ServiceResponse
<
Integer
>
serviceResponse
=
this
.
authCodeApiService
.
saveAuth
(
authCodeDTO
);
return
RestResponse
.
success
(
serviceResponse
.
getResult
());
}
else
{
return
RestResponse
.
failure
(
smsSendResult
.
getCode
(),
smsSendResult
.
getMessage
());
}
}
return
RestResponse
.
failure
(
ErrorCode
.
NOTEXISTS
.
getCode
(),
"商户不存在"
);
}
@RequestMapping
(
"expire-auth-code"
)
...
...
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