Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
c4813872
Commit
c4813872
authored
Jul 02, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
950599c5
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
182 additions
and
26 deletions
+182
-26
AuthController.java
...thub/wxiaoqi/security/auth/controller/AuthController.java
+6
-2
IUserService.java
.../com/github/wxiaoqi/security/auth/feign/IUserService.java
+6
-6
AuthService.java
...com/github/wxiaoqi/security/auth/service/AuthService.java
+4
-4
AppAuthServiceImpl.java
...xiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
+2
-2
AuthServiceImpl.java
...b/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
+2
-2
AppUserRest.java
...va/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
+11
-2
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+84
-6
ThirdFeign.java
...in/java/com/xxfc/platform/universal/feign/ThirdFeign.java
+3
-0
SmsController.java
...com/xxfc/platform/universal/controller/SmsController.java
+7
-0
SmsService.java
.../java/com/xxfc/platform/universal/service/SmsService.java
+57
-2
No files found.
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/controller/AuthController.java
View file @
c4813872
...
...
@@ -174,6 +174,7 @@ public class AuthController {
*/
@PostMapping
(
value
=
"/applet/uid/login"
)
public
JSONObject
appletLoginByUserId
(
@RequestParam
(
"userId"
)
Integer
userId
)
throws
Exception
{
log
.
info
(
userId
+
"----require appletLoginByUserId..."
);
JSONObject
data
=
appAuthService
.
appletLoginByUserId
(
userId
);
if
(
data
!=
null
&&
data
.
getInteger
(
"status"
)==
ResultCode
.
SUCCESS_CODE
){
JSONObject
result
=
data
.
getJSONObject
(
"data"
);
...
...
@@ -188,8 +189,11 @@ public class AuthController {
}
@PostMapping
(
value
=
"/applet/registry"
)
public
JSONObject
registryWithApplet
(
@RequestParam
(
"username"
)
String
phone
,
@RequestParam
(
"password"
)
String
pwd
,
@RequestParam
(
"mobilecode"
)
String
code
)
throws
Exception
{
JSONObject
data
=
appAuthService
.
appletRegistry
(
phone
,
pwd
,
code
);
public
JSONObject
registryWithApplet
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"nickname"
,
defaultValue
=
""
)
String
nickname
,
@RequestParam
(
value
=
"headimgurl"
,
defaultValue
=
""
)
String
headimgurl
)
throws
Exception
{
JSONObject
data
=
appAuthService
.
appletRegistry
(
username
,
nickname
,
headimgurl
);
if
(
data
!=
null
&&
data
.
getInteger
(
"status"
)==
ResultCode
.
SUCCESS_CODE
){
JSONObject
result
=
data
.
getJSONObject
(
"data"
);
if
(
result
==
null
){
...
...
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/feign/IUserService.java
View file @
c4813872
...
...
@@ -54,16 +54,16 @@ public interface IUserService {
* @param userid
* @return
*/
@
PostMapping
(
"/api/app/applet/uid/login"
)
JSONObject
appletLogin
(
@RequestParam
(
value
=
"userid"
)
Integer
userid
);
@
RequestMapping
(
value
=
"/api/app/applet/uid/login"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
appletLogin
(
@RequestParam
(
value
=
"userid"
)
Integer
userid
);
/**
* 小程序注册
* @param
phon
e
* @param
pwd
* @param
code
* @param
usernam
e
* @param
nickname
* @param
headimgurl
* @return
*/
@PostMapping
(
"/api/app/applet/registry"
)
JSONObject
appletRegistry
(
@RequestParam
(
value
=
"phone"
)
String
phone
,
@RequestParam
(
"pwd"
)
String
pwd
,
@RequestParam
(
"code"
)
String
code
);
public
JSONObject
appletRegistry
(
@RequestParam
(
value
=
"username"
)
String
username
,
@RequestParam
(
value
=
"nickname"
)
String
nickname
,
@RequestParam
(
value
=
"headimgurl"
)
String
headimgurl
);
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/AuthService.java
View file @
c4813872
...
...
@@ -27,10 +27,10 @@ public interface AuthService {
/**
* 通过小程序注册
* @param
phon
e
* @param
pwd
* @param
cod
e
* @param
usernam
e
* @param
headimgurl
* @param
nicknam
e
* @return
*/
JSONObject
appletRegistry
(
String
phone
,
String
pwd
,
String
cod
e
);
JSONObject
appletRegistry
(
String
username
,
String
headimgurl
,
String
nicknam
e
);
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
View file @
c4813872
...
...
@@ -92,8 +92,8 @@ public class AppAuthServiceImpl implements AuthService {
}
@Override
public
JSONObject
appletRegistry
(
String
phone
,
String
pwd
,
String
cod
e
)
{
return
userService
.
appletRegistry
(
phone
,
pwd
,
cod
e
);
public
JSONObject
appletRegistry
(
String
username
,
String
headimgurl
,
String
nicknam
e
)
{
return
userService
.
appletRegistry
(
username
,
headimgurl
,
nicknam
e
);
}
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
View file @
c4813872
...
...
@@ -90,7 +90,7 @@ public class AuthServiceImpl implements AuthService {
}
@Override
public
JSONObject
appletRegistry
(
String
phone
,
String
pwd
,
String
cod
e
)
{
return
userService
.
appletRegistry
(
phone
,
pwd
,
cod
e
);
public
JSONObject
appletRegistry
(
String
username
,
String
headimgurl
,
String
nicknam
e
)
{
return
userService
.
appletRegistry
(
username
,
headimgurl
,
nicknam
e
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
View file @
c4813872
...
...
@@ -183,8 +183,17 @@ public class AppUserRest {
@PostMapping
(
"/applet/registry"
)
public
JSONObject
appletRegistry
(
@RequestParam
(
value
=
"phone"
)
String
phone
,
@RequestParam
(
"pwd"
)
String
pwd
,
@RequestParam
(
"code"
)
String
code
){
return
appPermissionService
.
appletRegistry
(
phone
,
pwd
,
code
);
public
JSONObject
appletRegistry
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"nickname"
,
defaultValue
=
""
)
String
nickname
,
@RequestParam
(
value
=
"headimgurl"
,
defaultValue
=
""
)
String
headimgurl
){
if
(
StringUtils
.
isBlank
(
headimgurl
)){
headimgurl
=
SystemConfig
.
USER_HEADER_URL_DEFAULT
;
}
if
(
StringUtils
.
isBlank
(
nickname
)){
nickname
=
SystemConfig
.
USER_NIKENAME_DEFAULT
+(
int
)((
Math
.
random
()*
9
+
1
)*
100000
);
}
return
appPermissionService
.
appletRegistry
(
username
,
headimgurl
,
nickname
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
View file @
c4813872
...
...
@@ -245,7 +245,6 @@ public class AppPermissionService {
data
.
put
(
"imToken"
,
access_token
);
data
.
put
(
"imUserId"
,
imUserId
);
}
if
(
data
!=
null
)
{
return
JsonResultUtil
.
createSuccessResultWithObj
(
data
);
}
else
{
...
...
@@ -672,22 +671,101 @@ public class AppPermissionService {
/**
*通过小程序注册
* 小程序注册用户
*
* @param username
* @param password
* @param mobilecode
* @param headimgurl
* @param nickname
*/
@Transactional
public
JSONObject
applyRegister
(
String
username
,
String
password
,
String
headimgurl
,
String
nickname
)
{
// 判断参数
if
(
StringUtils
.
isBlank
(
username
)
||
StringUtils
.
isBlank
(
password
))
{
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
NULL_CODE
,
"参数为空"
);
}
// 是否已存在
AppUserLogin
user
=
appUserLoginBiz
.
checkeUserLogin
(
username
);
if
(
null
!=
user
)
{
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
EXIST_CODE
,
"用户已存在"
);
}
// 新增用户登录信息
try
{
Long
now
=
System
.
currentTimeMillis
()
/
1000
;
AppUserLogin
appUserLogin
=
new
AppUserLogin
();
appUserLogin
.
setUsername
(
username
);
appUserLogin
.
setPassword
(
password
);
appUserLogin
.
setIsdel
(
0
);
appUserLogin
.
setStatus
(
0
);
appUserLogin
.
setCreatetime
(
now
);
appUserLogin
.
setUpdatetime
(
now
);
appUserLoginBiz
.
insertSelective
(
appUserLogin
);
Integer
userid
=
appUserLogin
.
getId
();
log
.
error
(
"注册:新增登陆用户信息: "
+
userid
);
// 新增用户详情
AppUserDetail
rsUserDetail
=
new
AppUserDetail
();
rsUserDetail
.
setUserid
(
userid
);
rsUserDetail
.
setNickname
(
nickname
);
rsUserDetail
.
setHeadimgurl
(
headimgurl
);
// 默认路径,待写
rsUserDetail
.
setCreatetime
(
now
);
rsUserDetail
.
setUpdatetime
(
now
);
rsUserDetail
.
setIsdel
(
0
);
appUserDetailBiz
.
insertSelective
(
rsUserDetail
);
log
.
error
(
"注册:新增用户详情: "
+
userid
);
//自动登录获取优惠卷
authCoupn
(
userid
);
//发送短信通知用户
thirdFeign
.
sendCode
(
username
,
password
,
SystemConfig
.
TEMPLATECODE
);
// 登录结果要做做统一处理
JSONObject
data
=
autoLogin
(
userid
,
username
,
headimgurl
,
nickname
);
// 到im注册,获取返回结果
Map
<
String
,
Object
>
map
=
registerIm
(
username
,
appUserLogin
.
getPassword
(),
nickname
);
if
(
map
!=
null
){
Integer
imUserId
=
Integer
.
parseInt
(
map
.
get
(
"userId"
).
toString
());
String
access_token
=
map
.
get
(
"access_token"
).
toString
();
String
imPassword
=
map
.
get
(
"password"
).
toString
();
if
(
imUserId
!=
null
&&
imUserId
>
0
&&
StringUtils
.
isNotBlank
(
imPassword
)){
AppUserLogin
userLogin
=
new
AppUserLogin
();
userLogin
.
setId
(
userid
);
userLogin
.
setImPassword
(
imPassword
);
userLogin
.
setImUserid
(
imUserId
);
userLogin
.
setUsername
(
username
);
appUserLoginBiz
.
updateSelectiveById
(
userLogin
);
log
.
info
(
username
+
"----userLogin updateSelectiveById---username====="
+
username
+
"----imPassword===="
+
imPassword
);
}
data
.
put
(
"imToken"
,
access_token
);
data
.
put
(
"imUserId"
,
imUserId
);
}
if
(
data
!=
null
)
{
return
JsonResultUtil
.
createSuccessResultWithObj
(
data
);
}
else
{
return
JsonResultUtil
.
createDefaultFail
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
EXCEPTION_CODE
,
"出现异常"
);
}
}
/**
*通过小程序注册
* @param username
* @return
*/
public
JSONObject
appletRegistry
(
String
username
,
String
password
,
String
mobilecode
){
public
JSONObject
appletRegistry
(
String
username
,
String
headimgurl
,
String
nickname
){
try
{
// 是否已存在
AppUserLogin
user
=
appUserLoginBiz
.
checkeUserLogin
(
username
);
JSONObject
data
=
new
JSONObject
();
if
(
null
==
user
)
{
data
=
register
(
username
,
password
,
SystemConfig
.
USER_HEADER_URL_DEFAULT
,
SystemConfig
.
USER_NIKENAME_DEFAULT
+(
int
)((
Math
.
random
()*
9
+
1
)*
100000
),
mobilecode
,
null
,
null
,
0
);
String
password
=
"12345678"
;
data
=
applyRegister
(
username
,
password
,
headimgurl
,
nickname
);
}
else
{
data
=
login
(
username
,
null
,
mobilecode
,
2
);
data
=
appletLoginByUserId
(
user
.
getId
()
);
}
return
data
;
}
catch
(
Exception
e
)
{
...
...
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/feign/ThirdFeign.java
View file @
c4813872
...
...
@@ -27,6 +27,9 @@ import java.util.Map;
public
interface
ThirdFeign
{
@RequestMapping
(
value
=
"/sms/app/unauth/send"
,
method
=
RequestMethod
.
GET
)
public
JSONObject
send
(
@RequestParam
(
value
=
"phone"
)
String
phone
);
@RequestMapping
(
value
=
"/sms/app/unauth/sendCode"
,
method
=
RequestMethod
.
GET
)
//发送短信模板消息
public
JSONObject
sendCode
(
@RequestParam
(
"phone"
)
String
phone
,
@RequestParam
(
"code"
)
String
code
,
@RequestParam
(
"templateCode"
)
String
templateCode
);
@RequestMapping
(
value
=
"/file/app/unauth/uploadFiles"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
uploadFiles
(
@RequestParam
(
value
=
"files"
)
MultipartFile
[]
files
);
@RequestMapping
(
value
=
"/pay/app/wx"
,
method
=
RequestMethod
.
POST
)
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/SmsController.java
View file @
c4813872
...
...
@@ -33,5 +33,12 @@ public class SmsController {
public
JSONObject
sendSms
(
@RequestParam
(
"phone"
)
String
phone
)
throws
Exception
{
return
smsService
.
smsCode
(
phone
);
}
@RequestMapping
(
value
=
"/app/unauth/sendCode"
,
method
=
RequestMethod
.
GET
)
public
JSONObject
sendCode
(
@RequestParam
(
"phone"
)
String
phone
,
@RequestParam
(
"code"
)
String
code
,
@RequestParam
(
"templateCode"
)
String
templateCode
)
throws
Exception
{
return
smsService
.
smsByCode
(
phone
,
code
,
templateCode
);
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/SmsService.java
View file @
c4813872
...
...
@@ -57,6 +57,18 @@ public class SmsService {
}
}
public
JSONObject
smsByCode
(
String
mobile
,
String
pwd
,
String
templateCode
){
try
{
if
(
StringUtils
.
isNotBlank
(
mobile
)){
mobile
=
mobile
.
replace
(
" "
,
""
);
}
sendSmsByStr
(
mobile
,
pwd
,
templateCode
);
return
JsonResultUtil
.
createSuccessResult
();
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
return
JsonResultUtil
.
createDefaultFail
();
}
}
public
String
sendSms
(
String
mobile
,
String
code
)
throws
ClientException
{
//可自助调整超时时间
...
...
@@ -100,6 +112,49 @@ public class SmsService {
return
null
;
}
public
boolean
sendSmsByStr
(
String
mobile
,
String
str
,
String
templateCode
)
throws
ClientException
{
//可自助调整超时时间
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"10000"
);
//初始化acsClient,暂不支持region化
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
accessKeyId
,
accessKeySecret
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
product
,
domain
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest
request
=
new
SendSmsRequest
();
//必填:待发送手机号
request
.
setPhoneNumbers
(
mobile
);
//必填:短信签名-可在短信控制台中找到
request
.
setSignName
(
SignName
);
//必填:短信模板-可在短信控制台中找到
request
.
setTemplateCode
(
templateCode
);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request
.
setTemplateParam
(
TemplateParam
.
replace
(
"str"
,
str
));
//\"name\":\"Tom\",
//选填-上行短信扩展码(无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
//request.setOutId("yourOutId");
//hint 此处可能会抛出异常,注意catch
SendSmsResponse
sendSmsResponse
=
acsClient
.
getAcsResponse
(
request
);
log
.
info
(
"短信接口返回的数据----------------mobile======"
+
mobile
+
"----str===="
+
str
);
log
.
info
(
"Code="
+
sendSmsResponse
.
getCode
());
log
.
info
(
"Message="
+
sendSmsResponse
.
getMessage
());
log
.
info
(
"RequestId="
+
sendSmsResponse
.
getRequestId
());
log
.
info
(
"BizId="
+
sendSmsResponse
.
getBizId
());
if
(
sendSmsResponse
.
getCode
()
!=
null
&&
sendSmsResponse
.
getCode
().
equals
(
"OK"
))
{
//请求成功
return
true
;
}
return
false
;
}
/* public static QuerySendDetailsResponse querySendDetails(String bizId) throws ClientException {
...
...
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