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
b5c2819c
Commit
b5c2819c
authored
May 14, 2019
by
youjj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加开放的营地信息列表
parent
f64ed893
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
949 additions
and
10 deletions
+949
-10
CommonConstants.java
...iaoqi/security/auth/common/constatns/CommonConstants.java
+2
-0
IJWTInfo.java
...ithub/wxiaoqi/security/auth/common/util/jwt/IJWTInfo.java
+6
-0
JWTHelper.java
...thub/wxiaoqi/security/auth/common/util/jwt/JWTHelper.java
+5
-1
JWTInfo.java
...github/wxiaoqi/security/auth/common/util/jwt/JWTInfo.java
+17
-0
ClientInfo.java
...ava/com/github/wxiaoqi/security/auth/bean/ClientInfo.java
+5
-0
AuthController.java
...thub/wxiaoqi/security/auth/controller/AuthController.java
+20
-2
IUserService.java
.../com/github/wxiaoqi/security/auth/feign/IUserService.java
+7
-3
AppAuthServiceImpl.java
...xiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
+43
-0
AuthServiceImpl.java
...b/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
+1
-1
RequestTypeConstants.java
...xiaoqi/security/common/constant/RequestTypeConstants.java
+14
-0
RestCode.java
...com/github/wxiaoqi/security/common/constant/RestCode.java
+37
-0
BaseException.java
...thub/wxiaoqi/security/common/exception/BaseException.java
+7
-0
BaseResponse.java
.../com/github/wxiaoqi/security/common/msg/BaseResponse.java
+11
-0
AccessGatewayFilter.java
...hub/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
+12
-2
AppUserBiz.java
...ava/com/github/wxiaoqi/security/admin/biz/AppUserBiz.java
+23
-0
ElementBiz.java
...ava/com/github/wxiaoqi/security/admin/biz/ElementBiz.java
+6
-0
AppUser.java
...ava/com/github/wxiaoqi/security/admin/entity/AppUser.java
+538
-0
AppUserMapper.java
...m/github/wxiaoqi/security/admin/mapper/AppUserMapper.java
+7
-0
ElementMapper.java
...m/github/wxiaoqi/security/admin/mapper/ElementMapper.java
+3
-0
AppUserRest.java
...va/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
+47
-0
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+62
-0
PermissionService.java
...wxiaoqi/security/admin/rpc/service/PermissionService.java
+0
-1
ElementMapper.xml
...les/ace-admin/src/main/resources/mapper/ElementMapper.xml
+13
-0
AppUserInfo.java
.../com/github/wxiaoqi/security/api/vo/user/AppUserInfo.java
+63
-0
No files found.
ace-auth/ace-auth-common/src/main/java/com/github/wxiaoqi/security/auth/common/constatns/CommonConstants.java
View file @
b5c2819c
...
...
@@ -22,6 +22,8 @@ public class CommonConstants {
public
static
final
String
JWT_KEY_DATA_ALL
=
"dataAll"
;
public
static
final
String
JWT_KEY_DATA_ZONE
=
"dataZone"
;
public
static
final
String
JWT_KEY_DATA_COMMPANY
=
"dataCommpany"
;
public
static
final
String
JWT_KEY_REQUEST_TYPE
=
"requestType"
;
//数据权限相关
public
final
static
Integer
DATA_ALL_TRUE
=
1
;
...
...
ace-auth/ace-auth-common/src/main/java/com/github/wxiaoqi/security/auth/common/util/jwt/IJWTInfo.java
View file @
b5c2819c
...
...
@@ -22,6 +22,12 @@ public interface IJWTInfo {
*/
String
getName
();
/**
* 获取请求类型(app,base,wx)
* @return
*/
String
getRequestType
();
// /**
// * 数据权限 是否拥有所有数据
// * @return
...
...
ace-auth/ace-auth-common/src/main/java/com/github/wxiaoqi/security/auth/common/util/jwt/JWTHelper.java
View file @
b5c2819c
...
...
@@ -47,6 +47,7 @@ public class JWTHelper {
.
setSubject
(
jwtInfo
.
getUniqueName
())
.
claim
(
CommonConstants
.
JWT_KEY_USER_ID
,
jwtInfo
.
getId
())
.
claim
(
CommonConstants
.
JWT_KEY_NAME
,
jwtInfo
.
getName
())
.
claim
(
CommonConstants
.
JWT_KEY_REQUEST_TYPE
,
jwtInfo
.
getRequestType
())
.
setExpiration
(
DateTime
.
now
().
plusSeconds
(
expire
).
toDate
())
.
signWith
(
SignatureAlgorithm
.
RS256
,
rsaKeyHelper
.
getPrivateKey
(
priKey
))
.
compact
();
...
...
@@ -99,6 +100,9 @@ public class JWTHelper {
public
static
IJWTInfo
getInfoFromToken
(
String
token
,
byte
[]
pubKey
)
throws
Exception
{
Jws
<
Claims
>
claimsJws
=
parserToken
(
token
,
pubKey
);
Claims
body
=
claimsJws
.
getBody
();
return
new
JWTInfo
(
body
.
getSubject
(),
StringHelper
.
getObjectValue
(
body
.
get
(
CommonConstants
.
JWT_KEY_USER_ID
)),
StringHelper
.
getObjectValue
(
body
.
get
(
CommonConstants
.
JWT_KEY_NAME
)));
return
new
JWTInfo
(
body
.
getSubject
(),
StringHelper
.
getObjectValue
(
body
.
get
(
CommonConstants
.
JWT_KEY_USER_ID
)),
StringHelper
.
getObjectValue
(
body
.
get
(
CommonConstants
.
JWT_KEY_NAME
)),
StringHelper
.
getObjectValue
(
body
.
get
(
CommonConstants
.
JWT_KEY_REQUEST_TYPE
)));
}
}
ace-auth/ace-auth-common/src/main/java/com/github/wxiaoqi/security/auth/common/util/jwt/JWTInfo.java
View file @
b5c2819c
...
...
@@ -9,6 +9,7 @@ public class JWTInfo implements Serializable,IJWTInfo {
private
String
username
;
private
String
userId
;
private
String
name
;
private
String
requestType
;
// private Integer dataAll;
// private String dataZone;
// private String dataCompany;
...
...
@@ -22,6 +23,13 @@ public class JWTInfo implements Serializable,IJWTInfo {
// this.dataCompany = dataCompany;
}
public
JWTInfo
(
String
username
,
String
userId
,
String
name
,
String
requestType
)
{
this
.
username
=
username
;
this
.
userId
=
userId
;
this
.
name
=
name
;
this
.
requestType
=
requestType
;
}
@Override
public
String
getUniqueName
()
{
return
username
;
...
...
@@ -49,6 +57,15 @@ public class JWTInfo implements Serializable,IJWTInfo {
this
.
name
=
name
;
}
@Override
public
String
getRequestType
()
{
return
requestType
;
}
public
void
setRequestType
(
String
requestType
)
{
this
.
requestType
=
requestType
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
...
...
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/bean/ClientInfo.java
View file @
b5c2819c
...
...
@@ -67,6 +67,11 @@ public class ClientInfo implements IJWTInfo {
return
name
;
}
@Override
public
String
getRequestType
()
{
return
"none"
;
}
// @Override
// public Integer getDataAll() {
// return null;
...
...
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/controller/AuthController.java
View file @
b5c2819c
...
...
@@ -2,9 +2,11 @@ package com.github.wxiaoqi.security.auth.controller;
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
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -21,13 +23,29 @@ public class AuthController {
private
String
tokenHeader
;
@Autowired
@Qualifier
(
"baseAuthService"
)
private
AuthService
authService
;
@Autowired
@Qualifier
(
"appAuthService"
)
private
AuthService
appAuthService
;
@RequestMapping
(
value
=
"token"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
<
String
>
createAuthenticationToken
(
@RequestBody
JwtAuthenticationRequest
authenticationRequest
)
throws
Exception
{
@RequestBody
JwtAuthenticationRequest
authenticationRequest
,
HttpServletRequest
request
)
throws
Exception
{
log
.
info
(
authenticationRequest
.
getUsername
()+
" require logging..."
);
final
String
token
=
authService
.
login
(
authenticationRequest
);
String
requestType
=
request
.
getHeader
(
RequestTypeConstants
.
HEADER_KEY
);
if
(
requestType
==
null
||
requestType
.
trim
().
equals
(
""
))
{
requestType
=
RequestTypeConstants
.
BASE
;
}
final
String
token
;
if
(
RequestTypeConstants
.
APP
.
equals
(
requestType
))
{
token
=
appAuthService
.
login
(
authenticationRequest
);
}
else
{
token
=
authService
.
login
(
authenticationRequest
);
}
return
new
ObjectRestResponse
<
String
>().
data
(
token
);
}
...
...
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/feign/IUserService.java
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
auth
.
feign
;
import
com.github.wxiaoqi.security.api.vo.user.AppUserInfo
;
import
com.github.wxiaoqi.security.api.vo.user.UserInfo
;
import
com.github.wxiaoqi.security.auth.configuration.FeignConfiguration
;
import
com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest
;
...
...
@@ -15,8 +16,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
* @author wanghaobin
* @create 2017-06-21 8:11
*/
@FeignClient
(
value
=
"ace-admin"
,
configuration
=
FeignConfiguration
.
class
)
@FeignClient
(
value
=
"ace-admin"
,
configuration
=
FeignConfiguration
.
class
)
public
interface
IUserService
{
@RequestMapping
(
value
=
"/api/user/validate"
,
method
=
RequestMethod
.
POST
)
public
UserInfo
validate
(
@RequestBody
JwtAuthenticationRequest
authenticationRequest
);
@RequestMapping
(
value
=
"/api/user/validate"
,
method
=
RequestMethod
.
POST
)
public
UserInfo
validate
(
@RequestBody
JwtAuthenticationRequest
authenticationRequest
);
@RequestMapping
(
value
=
"/api/app/user/validate"
,
method
=
RequestMethod
.
POST
)
AppUserInfo
AppValidate
(
@RequestBody
JwtAuthenticationRequest
authenticationRequest
);
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
auth
.
service
.
impl
;
import
com.github.wxiaoqi.security.api.vo.user.AppUserInfo
;
import
com.github.wxiaoqi.security.auth.common.util.jwt.JWTInfo
;
import
com.github.wxiaoqi.security.auth.feign.IUserService
;
import
com.github.wxiaoqi.security.auth.service.AuthService
;
import
com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest
;
import
com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil
;
import
com.github.wxiaoqi.security.common.constant.RequestTypeConstants
;
import
com.github.wxiaoqi.security.common.exception.auth.UserInvalidException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
@Service
(
"appAuthService"
)
public
class
AppAuthServiceImpl
implements
AuthService
{
@Autowired
private
JwtTokenUtil
jwtTokenUtil
;
@Autowired
private
IUserService
userService
;
@Override
public
String
login
(
JwtAuthenticationRequest
authenticationRequest
)
throws
Exception
{
AppUserInfo
info
=
userService
.
AppValidate
(
authenticationRequest
);
if
(!
StringUtils
.
isEmpty
(
info
.
getId
()))
{
return
jwtTokenUtil
.
generateToken
(
new
JWTInfo
(
info
.
getUsername
(),
info
.
getId
()
+
""
,
info
.
getName
(),
RequestTypeConstants
.
APP
));
}
throw
new
UserInvalidException
(
"用户不存在或账户密码错误!"
);
}
@Override
public
String
refresh
(
String
oldToken
)
throws
Exception
{
return
jwtTokenUtil
.
generateToken
(
jwtTokenUtil
.
getInfoFromToken
(
oldToken
));
}
@Override
public
void
validate
(
String
token
)
throws
Exception
{
jwtTokenUtil
.
getInfoFromToken
(
token
);
}
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
View file @
b5c2819c
...
...
@@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
@Service
@Service
(
"baseAuthService"
)
public
class
AuthServiceImpl
implements
AuthService
{
private
JwtTokenUtil
jwtTokenUtil
;
...
...
ace-common/src/main/java/com/github/wxiaoqi/security/common/constant/RequestTypeConstants.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
common
.
constant
;
/**
* 请求类型
*/
public
class
RequestTypeConstants
{
public
static
final
String
HEADER_KEY
=
"RequestType"
;
public
static
final
String
BASE
=
"BASE"
;
public
static
final
String
APP
=
"APP"
;
public
static
final
String
WX
=
"WX"
;
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/constant/RestCode.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
common
.
constant
;
/**
* rest请求返回代码
*/
public
enum
RestCode
{
SUCCESS
(
200
,
"Success"
)
;
private
Integer
status
;
private
String
msg
;
RestCode
()
{
}
RestCode
(
Integer
status
,
String
msg
)
{
this
.
status
=
status
;
this
.
msg
=
msg
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/exception/BaseException.java
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
common
.
exception
;
import
com.github.wxiaoqi.security.common.constant.RestCode
;
/**
* Created by ace on 2017/9/8.
*/
...
...
@@ -37,4 +39,9 @@ public class BaseException extends RuntimeException {
public
BaseException
(
String
message
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
)
{
super
(
message
,
cause
,
enableSuppression
,
writableStackTrace
);
}
public
BaseException
(
RestCode
restCode
)
{
super
(
restCode
.
getMsg
());
this
.
status
=
restCode
.
getStatus
();
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/msg/BaseResponse.java
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
common
.
msg
;
import
com.github.wxiaoqi.security.common.constant.RestCode
;
/**
* Created by ace on 2017/8/23.
*/
...
...
@@ -41,4 +43,13 @@ public class BaseResponse {
return
this
;
}
public
BaseResponse
(
RestCode
restCode
)
{
this
.
status
=
restCode
.
getStatus
();
this
.
message
=
restCode
.
getMsg
();
}
public
static
BaseResponse
success
()
{
return
new
BaseResponse
(
RestCode
.
SUCCESS
);
}
}
ace-gate/src/main/java/com/github/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
View file @
b5c2819c
...
...
@@ -8,6 +8,7 @@ import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import
com.github.wxiaoqi.security.auth.client.jwt.ServiceAuthUtil
;
import
com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil
;
import
com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo
;
import
com.github.wxiaoqi.security.common.constant.RequestTypeConstants
;
import
com.github.wxiaoqi.security.common.context.BaseContextHandler
;
import
com.github.wxiaoqi.security.common.msg.BaseResponse
;
import
com.github.wxiaoqi.security.common.msg.auth.TokenForbiddenResponse
;
...
...
@@ -85,9 +86,9 @@ public class AccessGatewayFilter implements GlobalFilter {
String
requestUri
=
request
.
getPath
().
pathWithinApplication
().
value
();
if
(
requiredAttribute
!=
null
)
{
Iterator
<
URI
>
iterator
=
requiredAttribute
.
iterator
();
while
(
iterator
.
hasNext
()){
while
(
iterator
.
hasNext
())
{
URI
next
=
iterator
.
next
();
if
(
next
.
getPath
().
startsWith
(
GATE_WAY_PREFIX
))
{
if
(
next
.
getPath
().
startsWith
(
GATE_WAY_PREFIX
))
{
requestUri
=
next
.
getPath
().
substring
(
GATE_WAY_PREFIX
.
length
());
}
}
...
...
@@ -107,6 +108,12 @@ public class AccessGatewayFilter implements GlobalFilter {
log
.
error
(
"用户Token过期异常"
,
e
);
return
getVoidMono
(
serverWebExchange
,
new
TokenForbiddenResponse
(
"User Token Forbidden or Expired!"
));
}
// String requestType = user.getRequestType();
//
// if (requestType == null || requestType.trim().equals("")) {
// requestType = RequestTypeConstants.BASE;
// }
List
<
PermissionInfo
>
permissionIfs
=
userService
.
getAllPermissionInfo
();
// 判断资源是否启用权限约束
Stream
<
PermissionInfo
>
stream
=
getPermissionIfs
(
requestUri
,
method
,
permissionIfs
);
...
...
@@ -117,6 +124,8 @@ public class AccessGatewayFilter implements GlobalFilter {
return
getVoidMono
(
serverWebExchange
,
new
TokenForbiddenResponse
(
"User Forbidden!Does not has Permission!"
));
}
}
// 申请客户端密钥头
mutate
.
header
(
serviceAuthConfig
.
getTokenHeader
(),
serviceAuthUtil
.
getClientToken
());
ServerHttpRequest
build
=
mutate
.
build
();
...
...
@@ -193,6 +202,7 @@ public class AccessGatewayFilter implements GlobalFilter {
private
boolean
checkUserPermission
(
PermissionInfo
[]
permissions
,
ServerWebExchange
ctx
,
IJWTInfo
user
)
{
// TODO 增加app用户权限逻辑
List
<
PermissionInfo
>
permissionInfos
=
userService
.
getPermissionByUsername
(
user
.
getUniqueName
());
PermissionInfo
current
=
null
;
for
(
PermissionInfo
info
:
permissions
)
{
...
...
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserBiz.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
biz
;
import
com.ace.cache.annotation.Cache
;
import
com.github.wxiaoqi.security.admin.entity.AppUser
;
import
com.github.wxiaoqi.security.admin.mapper.AppUserMapper
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
org.springframework.stereotype.Service
;
@Service
public
class
AppUserBiz
extends
BaseBiz
<
AppUserMapper
,
AppUser
>
{
/**
* 根据用户名获取用户信息
* @param username
* @return
*/
@Cache
(
key
=
"appUser{1}"
)
public
AppUser
getUserByUsername
(
String
username
){
AppUser
user
=
new
AppUser
();
user
.
setUsername
(
username
);
return
mapper
.
selectOne
(
user
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/ElementBiz.java
View file @
b5c2819c
...
...
@@ -43,4 +43,10 @@ public class ElementBiz extends BaseBiz<ElementMapper,Element> {
public
void
updateSelectiveById
(
Element
entity
)
{
super
.
updateSelectiveById
(
entity
);
}
@Cache
(
key
=
"app:permission:ele:u{1}"
)
public
List
<
Element
>
getAuthorityElementByAppUserId
(
String
userId
)
{
return
mapper
.
selectAuthorityElementByAppUserId
(
userId
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/entity/AppUser.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
entity
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.util.Date
;
@Table
(
name
=
"app_user"
)
public
class
AppUser
{
@Id
@GeneratedValue
(
generator
=
"JDBC"
)
//此处加上注解
private
Integer
id
;
private
String
username
;
private
String
password
;
private
String
name
;
private
String
birthday
;
private
String
address
;
@Column
(
name
=
"mobile_phone"
)
private
String
mobilePhone
;
@Column
(
name
=
"tel_phone"
)
private
String
telPhone
;
private
String
email
;
private
String
sex
;
private
String
type
;
@Column
(
name
=
"status"
)
private
Integer
status
;
@Column
(
name
=
"zone_id"
)
private
Integer
zoneId
;
@Column
(
name
=
"company_id"
)
private
Integer
companyId
;
private
String
description
;
@Column
(
name
=
"crt_time"
)
private
Date
crtTime
;
@Column
(
name
=
"crt_user"
)
private
String
crtUser
;
@Column
(
name
=
"crt_name"
)
private
String
crtName
;
@Column
(
name
=
"crt_host"
)
private
String
crtHost
;
@Column
(
name
=
"upd_time"
)
private
Date
updTime
;
@Column
(
name
=
"upd_user"
)
private
String
updUser
;
@Column
(
name
=
"upd_name"
)
private
String
updName
;
@Column
(
name
=
"upd_host"
)
private
String
updHost
;
@Column
(
name
=
"data_all"
)
private
Integer
dataAll
;
@Column
(
name
=
"data_zone"
)
private
String
dataZone
;
@Column
(
name
=
"data_company"
)
private
String
dataCompany
;
private
String
attr1
;
private
String
attr2
;
private
String
attr3
;
private
String
attr4
;
private
String
attr5
;
private
String
attr6
;
private
String
attr7
;
private
String
attr8
;
/**
* @return id
*/
public
Integer
getId
()
{
return
id
;
}
/**
* @param id
*/
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
/**
* @return username
*/
public
String
getUsername
()
{
return
username
;
}
/**
* @param username
*/
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
/**
* @return password
*/
public
String
getPassword
()
{
return
password
;
}
/**
* @param password
*/
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
/**
* @return name
*/
public
String
getName
()
{
return
name
;
}
/**
* @param name
*/
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
/**
* @return birthday
*/
public
String
getBirthday
()
{
return
birthday
;
}
/**
* @param birthday
*/
public
void
setBirthday
(
String
birthday
)
{
this
.
birthday
=
birthday
;
}
/**
* @return address
*/
public
String
getAddress
()
{
return
address
;
}
/**
* @param address
*/
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
/**
* @return mobile_phone
*/
public
String
getMobilePhone
()
{
return
mobilePhone
;
}
/**
* @param mobilePhone
*/
public
void
setMobilePhone
(
String
mobilePhone
)
{
this
.
mobilePhone
=
mobilePhone
;
}
/**
* @return tel_phone
*/
public
String
getTelPhone
()
{
return
telPhone
;
}
/**
* @param telPhone
*/
public
void
setTelPhone
(
String
telPhone
)
{
this
.
telPhone
=
telPhone
;
}
/**
* @return email
*/
public
String
getEmail
()
{
return
email
;
}
/**
* @param email
*/
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
/**
* @return sex
*/
public
String
getSex
()
{
return
sex
;
}
/**
* @param sex
*/
public
void
setSex
(
String
sex
)
{
this
.
sex
=
sex
;
}
/**
* @return type
*/
public
String
getType
()
{
return
type
;
}
/**
* @param type
*/
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
Integer
getZoneId
()
{
return
zoneId
;
}
public
void
setZoneId
(
Integer
zoneId
)
{
this
.
zoneId
=
zoneId
;
}
public
Integer
getCompanyId
()
{
return
companyId
;
}
public
void
setCompanyId
(
Integer
companyId
)
{
this
.
companyId
=
companyId
;
}
/**
* @return description
*/
public
String
getDescription
()
{
return
description
;
}
/**
* @param description
*/
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
/**
* @return crt_time
*/
public
Date
getCrtTime
()
{
return
crtTime
;
}
/**
* @param crtTime
*/
public
void
setCrtTime
(
Date
crtTime
)
{
this
.
crtTime
=
crtTime
;
}
/**
* @return crt_user
*/
public
String
getCrtUser
()
{
return
crtUser
;
}
/**
* @param crtUser
*/
public
void
setCrtUser
(
String
crtUser
)
{
this
.
crtUser
=
crtUser
;
}
/**
* @return crt_name
*/
public
String
getCrtName
()
{
return
crtName
;
}
/**
* @param crtName
*/
public
void
setCrtName
(
String
crtName
)
{
this
.
crtName
=
crtName
;
}
/**
* @return crt_host
*/
public
String
getCrtHost
()
{
return
crtHost
;
}
/**
* @param crtHost
*/
public
void
setCrtHost
(
String
crtHost
)
{
this
.
crtHost
=
crtHost
;
}
/**
* @return upd_time
*/
public
Date
getUpdTime
()
{
return
updTime
;
}
/**
* @param updTime
*/
public
void
setUpdTime
(
Date
updTime
)
{
this
.
updTime
=
updTime
;
}
/**
* @return upd_user
*/
public
String
getUpdUser
()
{
return
updUser
;
}
/**
* @param updUser
*/
public
void
setUpdUser
(
String
updUser
)
{
this
.
updUser
=
updUser
;
}
/**
* @return upd_name
*/
public
String
getUpdName
()
{
return
updName
;
}
/**
* @param updName
*/
public
void
setUpdName
(
String
updName
)
{
this
.
updName
=
updName
;
}
/**
* @return upd_host
*/
public
String
getUpdHost
()
{
return
updHost
;
}
/**
* @param updHost
*/
public
void
setUpdHost
(
String
updHost
)
{
this
.
updHost
=
updHost
;
}
public
Integer
getDataAll
()
{
return
dataAll
;
}
public
void
setDataAll
(
Integer
dataAll
)
{
this
.
dataAll
=
dataAll
;
}
public
String
getDataZone
()
{
return
dataZone
;
}
public
void
setDataZone
(
String
dataZone
)
{
this
.
dataZone
=
dataZone
;
}
public
String
getDataCompany
()
{
return
dataCompany
;
}
public
void
setDataCompany
(
String
dataCompany
)
{
this
.
dataCompany
=
dataCompany
;
}
/**
* @return attr1
*/
public
String
getAttr1
()
{
return
attr1
;
}
/**
* @param attr1
*/
public
void
setAttr1
(
String
attr1
)
{
this
.
attr1
=
attr1
;
}
/**
* @return attr2
*/
public
String
getAttr2
()
{
return
attr2
;
}
/**
* @param attr2
*/
public
void
setAttr2
(
String
attr2
)
{
this
.
attr2
=
attr2
;
}
/**
* @return attr3
*/
public
String
getAttr3
()
{
return
attr3
;
}
/**
* @param attr3
*/
public
void
setAttr3
(
String
attr3
)
{
this
.
attr3
=
attr3
;
}
/**
* @return attr4
*/
public
String
getAttr4
()
{
return
attr4
;
}
/**
* @param attr4
*/
public
void
setAttr4
(
String
attr4
)
{
this
.
attr4
=
attr4
;
}
/**
* @return attr5
*/
public
String
getAttr5
()
{
return
attr5
;
}
/**
* @param attr5
*/
public
void
setAttr5
(
String
attr5
)
{
this
.
attr5
=
attr5
;
}
/**
* @return attr6
*/
public
String
getAttr6
()
{
return
attr6
;
}
/**
* @param attr6
*/
public
void
setAttr6
(
String
attr6
)
{
this
.
attr6
=
attr6
;
}
/**
* @return attr7
*/
public
String
getAttr7
()
{
return
attr7
;
}
/**
* @param attr7
*/
public
void
setAttr7
(
String
attr7
)
{
this
.
attr7
=
attr7
;
}
/**
* @return attr8
*/
public
String
getAttr8
()
{
return
attr8
;
}
/**
* @param attr8
*/
public
void
setAttr8
(
String
attr8
)
{
this
.
attr8
=
attr8
;
}
}
\ No newline at end of file
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/mapper/AppUserMapper.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
mapper
;
import
com.github.wxiaoqi.security.admin.entity.AppUser
;
import
tk.mybatis.mapper.common.Mapper
;
public
interface
AppUserMapper
extends
Mapper
<
AppUser
>
{
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/mapper/ElementMapper.java
View file @
b5c2819c
...
...
@@ -11,4 +11,7 @@ public interface ElementMapper extends Mapper<Element> {
public
List
<
Element
>
selectAuthorityMenuElementByUserId
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"menuId"
)
String
menuId
);
public
List
<
Element
>
selectAuthorityElementByClientId
(
@Param
(
"clientId"
)
String
clientId
);
public
List
<
Element
>
selectAllElementPermissions
();
// TODO 修改查询SQL
List
<
Element
>
selectAuthorityElementByAppUserId
(
@Param
(
"userId"
)
String
userId
);
}
\ No newline at end of file
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
rpc
;
import
com.ace.cache.annotation.Cache
;
import
com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService
;
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
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Map
;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-21 8:15
*/
@RestController
@RequestMapping
(
"api/app"
)
public
class
AppUserRest
{
@Autowired
private
AppPermissionService
appPermissionService
;
// @Cache(key="permission")
// @RequestMapping(value = "/permissions", method = RequestMethod.GET)
// public @ResponseBody
// List<PermissionInfo> getAllPermission(){
// return permissionService.getAllPermission();
// }
//
@Cache
(
key
=
"app:permission:u{1}"
)
@RequestMapping
(
value
=
"/user/un/{username}/permissions"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
List
<
PermissionInfo
>
getPermissionByUsername
(
@PathVariable
(
"username"
)
String
username
){
return
appPermissionService
.
getPermissionByUsername
(
username
);
}
@RequestMapping
(
value
=
"/user/validate"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
AppUserInfo
validate
(
@RequestBody
Map
<
String
,
String
>
body
){
return
appPermissionService
.
validate
(
body
.
get
(
"username"
),
body
.
get
(
"password"
));
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
rpc
.
service
;
import
com.github.wxiaoqi.security.admin.biz.AppUserBiz
;
import
com.github.wxiaoqi.security.admin.biz.ElementBiz
;
import
com.github.wxiaoqi.security.admin.entity.AppUser
;
import
com.github.wxiaoqi.security.admin.entity.Element
;
import
com.github.wxiaoqi.security.admin.entity.Menu
;
import
com.github.wxiaoqi.security.api.vo.authority.PermissionInfo
;
import
com.github.wxiaoqi.security.api.vo.user.AppUserInfo
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
public
class
AppPermissionService
{
@Autowired
AppUserBiz
appUserBiz
;
@Autowired
ElementBiz
elementBiz
;
private
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
(
12
);
public
AppUserInfo
validate
(
String
username
,
String
password
)
{
AppUserInfo
info
=
new
AppUserInfo
();
AppUser
user
=
appUserBiz
.
getUserByUsername
(
username
);
if
(
encoder
.
matches
(
password
,
user
.
getPassword
()))
{
BeanUtils
.
copyProperties
(
user
,
info
);
info
.
setId
(
user
.
getId
().
toString
());
}
return
info
;
}
public
List
<
PermissionInfo
>
getPermissionByUsername
(
String
username
)
{
AppUser
user
=
appUserBiz
.
getUserByUsername
(
username
);
List
<
PermissionInfo
>
result
=
new
ArrayList
<>();
// List<Element> elements = elementBiz.getAuthorityElementByUserId(user.getId().toString());
List
<
Element
>
elements
=
elementBiz
.
getAuthorityElementByAppUserId
(
user
.
getId
().
toString
());
element2permission
(
result
,
elements
);
return
result
;
}
private
void
element2permission
(
List
<
PermissionInfo
>
result
,
List
<
Element
>
elements
)
{
PermissionInfo
info
;
for
(
Element
element
:
elements
)
{
info
=
new
PermissionInfo
();
info
.
setCode
(
element
.
getCode
());
info
.
setType
(
element
.
getType
());
info
.
setUri
(
element
.
getUri
());
info
.
setMethod
(
element
.
getMethod
());
info
.
setName
(
element
.
getName
());
info
.
setMenu
(
element
.
getMenuId
());
result
.
add
(
info
);
}
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/PermissionService.java
View file @
b5c2819c
...
...
@@ -95,7 +95,6 @@ public class PermissionService {
User
user
=
userBiz
.
getUserByUsername
(
username
);
List
<
Menu
>
menus
=
menuBiz
.
getUserAuthorityMenuByUserId
(
user
.
getId
());
List
<
PermissionInfo
>
result
=
new
ArrayList
<
PermissionInfo
>();
PermissionInfo
info
=
null
;
menu2permission
(
menus
,
result
);
List
<
Element
>
elements
=
elementBiz
.
getAuthorityElementByUserId
(
user
.
getId
()
+
""
);
element2permission
(
result
,
elements
);
...
...
ace-modules/ace-admin/src/main/resources/mapper/ElementMapper.xml
View file @
b5c2819c
...
...
@@ -40,6 +40,19 @@
and ra.resource_type = 'button'
inner join base_menu m
on t.menu_id = m.id
</select>
<select
id=
"selectAuthorityElementByAppUserId"
resultMap=
"BaseResultMap"
>
select distinct t.code,t.type,t.name,t.uri,t.method,m.title as menu_id from base_resource_authority ra
inner join base_element t
on ra.resource_id = t.id
and ra.authority_id in (
select group_id from base_group_member where user_id = #{userId}
union select group_id from base_group_leader where user_id = #{userId}
)
and ra.authority_type = 'group'
and ra.resource_type = 'button'
inner join base_menu m
on t.menu_id = m.id
</select>
<select
id=
"selectAuthorityMenuElementByUserId"
resultMap=
"BaseResultMap"
>
select distinct t.* from base_resource_authority ra
...
...
ace-modules/ace-interface/src/main/java/com/github/wxiaoqi/security/api/vo/user/AppUserInfo.java
0 → 100644
View file @
b5c2819c
package
com
.
github
.
wxiaoqi
.
security
.
api
.
vo
.
user
;
import
java.io.Serializable
;
import
java.util.Date
;
public
class
AppUserInfo
implements
Serializable
{
public
String
id
;
public
String
username
;
public
String
password
;
public
String
name
;
private
String
description
;
public
Date
getUpdTime
()
{
return
updTime
;
}
public
void
setUpdTime
(
Date
updTime
)
{
this
.
updTime
=
updTime
;
}
private
Date
updTime
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
}
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