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
4bd29ffb
Commit
4bd29ffb
authored
May 21, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加微信qq登录接口,手机验证接口
parent
23a37a19
Changes
17
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
621 additions
and
19 deletions
+621
-19
pom.xml
ace-auth/ace-auth-server/pom.xml
+6
-0
SwaggerConfig.java
...ub/wxiaoqi/security/auth/configuration/SwaggerConfig.java
+56
-0
AuthController.java
...thub/wxiaoqi/security/auth/controller/AuthController.java
+53
-2
IUserService.java
.../com/github/wxiaoqi/security/auth/feign/IUserService.java
+14
-0
AuthService.java
...com/github/wxiaoqi/security/auth/service/AuthService.java
+4
-0
AppAuthServiceImpl.java
...xiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
+20
-0
AuthServiceImpl.java
...b/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
+19
-0
EmojiFilter.java
.../com/github/wxiaoqi/security/common/util/EmojiFilter.java
+87
-0
SystemConfig.java
...ub/wxiaoqi/security/common/util/process/SystemConfig.java
+4
-0
resultcod.properties
...common/src/main/resources/properties/resultcod.properties
+1
-1
systemconfig.properties
...mon/src/main/resources/properties/systemconfig.properties
+5
-1
AppUserDetailBiz.java
...m/github/wxiaoqi/security/admin/biz/AppUserDetailBiz.java
+19
-1
AppUserLoginBiz.java
...om/github/wxiaoqi/security/admin/biz/AppUserLoginBiz.java
+20
-0
RedisKey.java
.../com/github/wxiaoqi/security/admin/constant/RedisKey.java
+10
-0
AppUserRest.java
...va/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
+77
-0
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+190
-14
JwtAuthenticationRequest.java
...wxiaoqi/security/admin/util/JwtAuthenticationRequest.java
+36
-0
No files found.
ace-auth/ace-auth-server/pom.xml
View file @
4bd29ffb
...
...
@@ -12,6 +12,12 @@
<artifactId>
ace-auth-server
</artifactId>
<dependencies>
<!-- swagger -->
<dependency>
<groupId>
com.spring4all
</groupId>
<artifactId>
swagger-spring-boot-starter
</artifactId>
<version>
1.6.0.RELEASE
</version>
</dependency>
<!--使用undertow 替换 Tomcat-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/configuration/SwaggerConfig.java
0 → 100644
View file @
4bd29ffb
package
com
.
github
.
wxiaoqi
.
security
.
auth
.
configuration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.ParameterBuilder
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.schema.ModelRef
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.Parameter
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @Description : swagger配置配置
* @Author : Mars
* @Date : 2017年9月6日
*/
@Configuration
@EnableSwagger2
public
class
SwaggerConfig
{
/**
* Every Docket bean is picked up by the swagger-mvc framework - allowing for multiple
* swagger groups i.e. same code base multiple swagger resource listings.
*/
@Bean
public
Docket
customDocket
(){
ParameterBuilder
ticketPar
=
new
ParameterBuilder
();
List
<
Parameter
>
pars
=
new
ArrayList
<
Parameter
>();
ticketPar
.
name
(
"Authorization"
).
description
(
"user Authorization"
)
.
modelRef
(
new
ModelRef
(
"string"
)).
parameterType
(
"header"
)
.
required
(
false
).
build
();
//header中的ticket参数非必填,传空也可以
pars
.
add
(
ticketPar
.
build
());
//根据每个方法名也知道当前方法在设置什么参数
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.github.wxiaoqi.security.auth"
))
//.apis(RequestHandlerSelectors.any())
.
build
()
.
globalOperationParameters
(
pars
)
.
apiInfo
(
apiInfo
());
}
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"api swagger document"
)
.
description
(
"前后端联调swagger api 文档"
)
.
version
(
"2.1.5.5"
)
.
build
();
}
}
\ No newline at end of file
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/controller/AuthController.java
View file @
4bd29ffb
...
...
@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.auth.service.AuthService;
import
com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest
;
import
com.github.wxiaoqi.security.common.constant.RequestTypeConstants
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
...
...
@@ -61,8 +62,58 @@ public class AuthController {
return
new
ObjectRestResponse
<>();
}
@RequestMapping
(
value
=
"/sendsms"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
sendsms
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"0"
)
Integer
type
)
throws
Exception
{
public
JSONObject
sendsms
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"0"
)
Integer
type
)
throws
Exception
{
log
.
info
(
username
+
"----require sendsms..."
);
return
authService
.
sendsms
(
username
,
type
);
return
a
ppA
uthService
.
sendsms
(
username
,
type
);
}
@RequestMapping
(
value
=
"/register"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
register
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"mobilecode"
,
defaultValue
=
""
)
String
mobilecode
,
@RequestParam
(
value
=
"password"
,
defaultValue
=
""
)
String
password
)
throws
Exception
{
log
.
info
(
username
+
"----require register..."
);
JSONObject
data
=
appAuthService
.
register
(
username
,
mobilecode
,
password
);
if
(
data
!=
null
&&
data
.
getInteger
(
"status"
)==
ResultCode
.
SUCCESS_CODE
){
JwtAuthenticationRequest
authenticationRequest
=
new
JwtAuthenticationRequest
();
authenticationRequest
.
setUsername
(
username
);
authenticationRequest
.
setPassword
(
password
);
String
token
=
appAuthService
.
login
(
authenticationRequest
);
data
.
put
(
"token"
,
token
);
}
return
data
;
}
@RequestMapping
(
value
=
"/wxregister"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
wxregister
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"mobilecode"
,
defaultValue
=
""
)
String
mobilecode
,
@RequestParam
(
value
=
"password"
,
defaultValue
=
""
)
String
password
,
@RequestParam
(
value
=
"nickname"
,
defaultValue
=
""
)
String
nickname
,
@RequestParam
(
value
=
"headimgurl"
,
defaultValue
=
""
)
String
headimgurl
,
@RequestParam
(
value
=
"openid"
,
defaultValue
=
""
)
String
openid
,
@RequestParam
(
value
=
"password"
,
defaultValue
=
""
)
String
unionid
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"0"
)
Integer
type
,
@RequestParam
(
value
=
"isQQ"
,
defaultValue
=
"0"
)
Integer
isQQ
)
throws
Exception
{
log
.
info
(
username
+
"----require wxregister..."
);
JSONObject
data
=
appAuthService
.
wxregister
(
username
,
mobilecode
,
password
,
nickname
,
headimgurl
,
openid
,
unionid
,
type
,
isQQ
);
if
(
data
!=
null
&&
data
.
getInteger
(
"status"
)==
ResultCode
.
SUCCESS_CODE
){
JwtAuthenticationRequest
authenticationRequest
=
new
JwtAuthenticationRequest
();
authenticationRequest
.
setUsername
(
username
);
authenticationRequest
.
setPassword
(
password
);
String
token
=
appAuthService
.
login
(
authenticationRequest
);
data
.
put
(
"token"
,
token
);
}
return
data
;
}
@RequestMapping
(
value
=
"/checkBindWechat"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
checkBindWechat
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
)
throws
Exception
{
log
.
info
(
username
+
"----require checkBindWechat..."
);
return
appAuthService
.
checkBindWechat
(
username
);
}
@RequestMapping
(
value
=
"/wxlogin"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
wxlogin
(
@RequestParam
(
value
=
"openid"
,
defaultValue
=
""
)
String
openid
,
@RequestParam
(
value
=
"isQQ"
,
defaultValue
=
"0"
)
Integer
isQQ
)
throws
Exception
{
log
.
info
(
openid
+
"----require wxlogin..."
);
return
appAuthService
.
wxlogin
(
openid
,
isQQ
);
}
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/feign/IUserService.java
View file @
4bd29ffb
...
...
@@ -28,4 +28,18 @@ public interface IUserService {
@RequestMapping
(
value
=
"/api/app/user/sendsms"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
sendsms
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"0"
)
Integer
type
);
@RequestMapping
(
value
=
"/api/app/user/register"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
register
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"mobilecode"
,
defaultValue
=
""
)
String
mobilecode
,
@RequestParam
(
value
=
"password"
,
defaultValue
=
""
)
String
password
);
@RequestMapping
(
value
=
"/api/app/user/wxregister"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
wxregister
(
@RequestParam
(
value
=
"username"
)
String
username
,
@RequestParam
(
value
=
"mobilecode"
)
String
mobilecode
,
@RequestParam
(
value
=
"password"
)
String
password
,
@RequestParam
(
value
=
"nickname"
)
String
nickname
,
@RequestParam
(
value
=
"headimgurl"
)
String
headimgurl
,
@RequestParam
(
value
=
"openid"
)
String
openid
,
@RequestParam
(
value
=
"unionid"
)
String
unionid
,
@RequestParam
(
value
=
"type"
)
Integer
type
,
@RequestParam
(
value
=
"isQQ"
)
Integer
isQQ
);
@RequestMapping
(
value
=
"/api/app/checkBindWechat"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
checkBindWechat
(
@RequestParam
(
value
=
"username"
)
String
username
);
@RequestMapping
(
value
=
"/api/app/user/wxlogin"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
wxlogin
(
@RequestParam
(
value
=
"openid"
)
String
openid
,
@RequestParam
(
value
=
"isQQ"
)
Integer
isQQ
);
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/AuthService.java
View file @
4bd29ffb
...
...
@@ -9,4 +9,8 @@ public interface AuthService {
String
refresh
(
String
oldToken
)
throws
Exception
;
void
validate
(
String
token
)
throws
Exception
;
JSONObject
sendsms
(
String
username
,
Integer
type
)
throws
Exception
;
JSONObject
register
(
String
username
,
String
mobilecode
,
String
password
)
throws
Exception
;
JSONObject
wxregister
(
String
username
,
String
mobilecode
,
String
password
,
String
nickname
,
String
headimgurl
,
String
openid
,
String
unionid
,
Integer
type
,
Integer
isQQ
)
throws
Exception
;
JSONObject
checkBindWechat
(
String
username
)
throws
Exception
;
JSONObject
wxlogin
(
String
openid
,
Integer
isQQ
)
throws
Exception
;
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
View file @
4bd29ffb
...
...
@@ -50,4 +50,24 @@ public class AppAuthServiceImpl implements AuthService {
return
userService
.
sendsms
(
username
,
type
);
}
@Override
public
JSONObject
register
(
String
username
,
String
mobilecode
,
String
password
)
throws
Exception
{
return
userService
.
register
(
username
,
mobilecode
,
password
);
}
@Override
public
JSONObject
wxregister
(
String
username
,
String
mobilecode
,
String
password
,
String
nickname
,
String
headimgurl
,
String
openid
,
String
unionid
,
Integer
type
,
Integer
isQQ
)
throws
Exception
{
return
userService
.
wxregister
(
username
,
mobilecode
,
password
,
nickname
,
headimgurl
,
openid
,
unionid
,
type
,
isQQ
);
}
@Override
public
JSONObject
checkBindWechat
(
String
username
)
throws
Exception
{
return
userService
.
checkBindWechat
(
username
);
}
@Override
public
JSONObject
wxlogin
(
String
openid
,
Integer
isQQ
)
throws
Exception
{
return
userService
.
wxlogin
(
openid
,
isQQ
);
}
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
View file @
4bd29ffb
...
...
@@ -48,4 +48,23 @@ public class AuthServiceImpl implements AuthService {
public
JSONObject
sendsms
(
String
username
,
Integer
type
)
throws
Exception
{
return
userService
.
sendsms
(
username
,
type
);
}
@Override
public
JSONObject
register
(
String
username
,
String
mobilecode
,
String
password
)
throws
Exception
{
return
userService
.
register
(
username
,
mobilecode
,
password
);
}
@Override
public
JSONObject
wxregister
(
String
username
,
String
mobilecode
,
String
password
,
String
nickname
,
String
headimgurl
,
String
openid
,
String
unionid
,
Integer
type
,
Integer
isQQ
)
throws
Exception
{
return
userService
.
wxregister
(
username
,
mobilecode
,
password
,
nickname
,
headimgurl
,
openid
,
unionid
,
type
,
isQQ
);
}
@Override
public
JSONObject
checkBindWechat
(
String
username
)
throws
Exception
{
return
userService
.
checkBindWechat
(
username
);
}
@Override
public
JSONObject
wxlogin
(
String
openid
,
Integer
isQQ
)
throws
Exception
{
return
userService
.
wxlogin
(
openid
,
isQQ
);
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/EmojiFilter.java
0 → 100644
View file @
4bd29ffb
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
;
import
org.apache.commons.lang3.StringUtils
;
public
class
EmojiFilter
{
/**
* 检测是否有emoji字符
*
* @param source
* @return 一旦含有就抛出
*/
public
static
boolean
containsEmoji
(
String
source
)
{
if
(
StringUtils
.
isBlank
(
source
))
{
return
false
;
}
int
len
=
source
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
codePoint
=
source
.
charAt
(
i
);
if
(
isEmojiCharacter
(
codePoint
))
{
// do nothing,判断到了这里表明,确认有表情字符
return
true
;
}
}
return
false
;
}
private
static
boolean
isEmojiCharacter
(
char
codePoint
)
{
return
(
codePoint
==
0x0
)
||
(
codePoint
==
0x9
)
||
(
codePoint
==
0xA
)
||
(
codePoint
==
0xD
)
||
((
codePoint
>=
0x20
)
&&
(
codePoint
<=
0xD7FF
))
||
((
codePoint
>=
0xE000
)
&&
(
codePoint
<=
0xFFFD
))
||
((
codePoint
>=
0x10000
)
&&
(
codePoint
<=
0x10FFFF
));
}
/**
* 过滤emoji 或者 其他非文字类型的字符
*
* @param source
* @return
*/
public
static
String
filterEmoji
(
String
source
)
{
if
(!
containsEmoji
(
source
))
{
return
source
;
// 如果不包含,直接返回
}
// 到这里铁定包含
StringBuilder
buf
=
null
;
int
len
=
source
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
codePoint
=
source
.
charAt
(
i
);
if
(
isEmojiCharacter
(
codePoint
))
{
if
(
buf
==
null
)
{
buf
=
new
StringBuilder
(
source
.
length
());
}
buf
.
append
(
codePoint
);
}
else
{
}
}
if
(
buf
==
null
)
{
return
source
;
// 如果没有找到 emoji表情,则返回源字符串
}
else
{
if
(
buf
.
length
()
==
len
)
{
// 这里的意义在于尽可能少的toString,因为会重新生成字符串
buf
=
null
;
return
source
;
}
else
{
return
buf
.
toString
();
}
}
}
// public static void main(String[] args) {
// String ss = "\uf0f0";
// System.out.println(ss);
// System.out.println(filterEmoji("<body>口口213这是一个有各种内容的消息, Hia Hia Hia !!!!
// xxxx@@@...*)!" +
// "(@*$&@(&#!)@*)!&$!)@^%@(!&#. 口口口], "));
// }
}
\ No newline at end of file
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/process/SystemConfig.java
View file @
4bd29ffb
...
...
@@ -13,6 +13,10 @@ public class SystemConfig {
public
static
Integer
REDIS_ITOKEN_TIME
=
Integer
.
valueOf
(
SystemProperty
.
getConfig
(
"REDIS_ITOKEN_TIME"
));
// session有效时间
public
static
Integer
SESSION_TIME
=
Integer
.
valueOf
(
SystemProperty
.
getConfig
(
"SESSION_TIME"
));
// session有效时间
public
static
String
USER_HEADER_URL_DEFAULT
=
SystemProperty
.
getConfig
(
"USER_HEADER_URL_DEFAULT"
);
// session有效时间
public
static
String
USER_NIKENAME_DEFAULT
=
SystemProperty
.
getConfig
(
"USER_NIKENAME_DEFAULT"
);
// 根据key名获取value
public
static
String
getCongif
(
String
key
)
{
return
SystemProperty
.
getConfig
(
key
);
...
...
ace-common/src/main/resources/properties/resultcod.properties
View file @
4bd29ffb
#返回结果代码
#操作成功
SUCCESS_CODE
=
10
00
SUCCESS_CODE
=
2
00
#操作失败
FAILED_CODE
=
1001
#数据已存在
...
...
ace-common/src/main/resources/properties/systemconfig.properties
View file @
4bd29ffb
...
...
@@ -8,3 +8,7 @@ REDIS_ITOKEN_TIME=51840
REDIS_TOKEN_TIME
=
604800
#session有效期
SESSION_TIME
=
3600
#默认头像
USER_HEADER_URL_DEFAULT
=
https://retail.xiaochengxucms.com/images/12/2018/11/fDK7kkrmkMReK50l4r1Le740Kmra8.jpg
#默认昵称
USER_NIKENAME_DEFAULT
=
XX_
\ No newline at end of file
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserDetailBiz.java
View file @
4bd29ffb
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
biz
;
import
com.ace.cache.annotation.Cache
;
import
com.ace.cache.annotation.CacheClear
;
import
com.github.wxiaoqi.security.admin.entity.AppUserDetail
;
import
com.github.wxiaoqi.security.admin.mapper.AppUserDetailMapper
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.List
;
...
...
@@ -20,11 +22,27 @@ import java.util.List;
public
class
AppUserDetailBiz
extends
BaseBiz
<
AppUserDetailMapper
,
AppUserDetail
>
{
@Override
@CacheClear
(
pre
=
"user{1.user
name
}"
)
@CacheClear
(
pre
=
"user{1.user
id
}"
)
public
void
updateSelectiveById
(
AppUserDetail
entity
)
{
super
.
updateSelectiveById
(
entity
);
}
/**
* 根据用户id获取用户信息
* @param userid
* @return
*/
@Cache
(
key
=
"user{1}"
)
public
AppUserDetail
getUserByUserid
(
Integer
userid
){
Example
example
=
new
Example
(
AppUserDetail
.
class
);
example
.
createCriteria
().
andEqualTo
(
"userid"
,
userid
).
andEqualTo
(
"isdel"
,
0
);
List
<
AppUserDetail
>
list
=
mapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()
!=
0
)
{
return
list
.
get
(
0
);
}
return
null
;
}
...
...
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserLoginBiz.java
View file @
4bd29ffb
...
...
@@ -47,6 +47,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
super
.
updateSelectiveById
(
entity
);
}
/**
* 根据用户名获取用户信息
* @param username
...
...
@@ -100,6 +101,25 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
return
null
;
}
/**
* 根据微信号判断是否存在用户
* @param openid
* @return
*/
public
AppUserLogin
getUserByOpenid
(
String
openid
,
Integer
isQQ
)
{
Example
example
=
new
Example
(
AppUserLogin
.
class
);
if
(
isQQ
==
1
){
example
.
createCriteria
().
andEqualTo
(
"openid"
,
openid
).
andEqualTo
(
"isdel"
,
0
);
}
else
{
example
.
createCriteria
().
andEqualTo
(
"wx_openid"
,
openid
).
andEqualTo
(
"isdel"
,
0
);
}
List
<
AppUserLogin
>
userLoginList
=
mapper
.
selectByExample
(
example
);
if
(
userLoginList
!=
null
&&
userLoginList
.
size
()
!=
0
)
{
return
userLoginList
.
get
(
0
);
}
return
null
;
}
/**
* 根据手机号码判断是否已绑定微信
*
...
...
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/constant/RedisKey.java
0 → 100644
View file @
4bd29ffb
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
constant
;
public
class
RedisKey
{
/**
*验证码key前缀
*/
public
static
final
String
CONSTANT_CODE_PREFIX
=
"cache:mobilecode:"
;
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
View file @
4bd29ffb
...
...
@@ -7,6 +7,10 @@ import com.github.wxiaoqi.security.admin.rpc.service.PermissionService;
import
com.github.wxiaoqi.security.api.vo.authority.PermissionInfo
;
import
com.github.wxiaoqi.security.api.vo.user.AppUserInfo
;
import
com.github.wxiaoqi.security.api.vo.user.UserInfo
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.github.wxiaoqi.security.common.util.result.JsonResultUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -53,5 +57,78 @@ public class AppUserRest {
return
appPermissionService
.
sendSMS
(
username
,
type
);
}
/**
* 注册
* @param username
* @param mobilecode
* @param password
* @return
*/
@RequestMapping
(
value
=
"/user/register"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
JSONObject
register
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"mobilecode"
,
defaultValue
=
""
)
String
mobilecode
,
@RequestParam
(
value
=
"password"
,
defaultValue
=
""
)
String
password
){
//默认昵称
String
nickname
=
SystemConfig
.
USER_NIKENAME_DEFAULT
+(
int
)((
Math
.
random
()*
9
+
1
)*
100000
);
return
appPermissionService
.
register
(
username
,
password
,
SystemConfig
.
USER_HEADER_URL_DEFAULT
,
nickname
,
mobilecode
,
null
,
null
,
0
);
}
/**
* 微信注册/微信绑定
* @param username
* @param mobilecode
* @param password
* @param nickname
* @param headimgurl
* @param openid
* @param unionid
* @param type
* @return
*/
@RequestMapping
(
value
=
"/user/wxregister"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
JSONObject
wxregister
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
,
@RequestParam
(
value
=
"mobilecode"
,
defaultValue
=
""
)
String
mobilecode
,
@RequestParam
(
value
=
"password"
,
defaultValue
=
""
)
String
password
,
@RequestParam
(
value
=
"nickname"
,
defaultValue
=
""
)
String
nickname
,
@RequestParam
(
value
=
"headimgurl"
,
defaultValue
=
""
)
String
headimgurl
,
@RequestParam
(
value
=
"openid"
,
defaultValue
=
""
)
String
openid
,
@RequestParam
(
value
=
"password"
,
defaultValue
=
""
)
String
unionid
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"0"
)
Integer
type
,
@RequestParam
(
value
=
"isQQ"
,
defaultValue
=
"0"
)
Integer
isQQ
){
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
.
weCahtRegister
(
username
,
password
,
openid
,
unionid
,
nickname
,
headimgurl
,
type
,
mobilecode
,
isQQ
);
}
/**
* 手机号码检测是否已绑定
*
* @param username
* @return
*/
@RequestMapping
(
value
=
"/user/checkBindWechat"
)
public
@ResponseBody
JSONObject
checkBindWechat
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
)
{
if
(
StringUtils
.
isBlank
(
username
))
{
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
NULL_CODE
,
"参数为空"
);
}
return
appPermissionService
.
checkBindWechat
(
username
);
}
@RequestMapping
(
value
=
"/user/wxlogin"
)
public
@ResponseBody
JSONObject
wxlogin
(
@RequestParam
(
value
=
"openid"
,
defaultValue
=
""
)
String
openid
,
@RequestParam
(
value
=
"isQQ"
,
defaultValue
=
"0"
)
Integer
isQQ
)
{
return
appPermissionService
.
weCahtLogin
(
openid
,
isQQ
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
View file @
4bd29ffb
This diff is collapsed.
Click to expand it.
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/util/JwtAuthenticationRequest.java
0 → 100644
View file @
4bd29ffb
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
util
;
import
java.io.Serializable
;
public
class
JwtAuthenticationRequest
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
8445943548965154778L
;
private
String
username
;
private
String
password
;
public
JwtAuthenticationRequest
(
String
username
,
String
password
)
{
this
.
username
=
username
;
this
.
password
=
password
;
}
public
JwtAuthenticationRequest
()
{
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
}
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