Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
civil-bigdata
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
civil
civil-bigdata
Commits
a16e91b7
Commit
a16e91b7
authored
Nov 22, 2021
by
韦华德
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
0667281d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
68 deletions
+78
-68
single-server/src/main/java/com/zq/single/config/WebMvcConfig.java
+2
-2
single-server/src/main/java/com/zq/single/config/interceptor/ApiInterceptor.java
+2
-1
single-server/src/main/java/com/zq/single/controller/AuthController.java
+16
-12
single-server/src/main/java/com/zq/single/controller/SysUserController.java
+45
-17
single-server/src/main/java/com/zq/single/entity/UserToken.java
+0
-35
single-server/src/main/java/com/zq/single/vo/UserInfoVo.java
+8
-0
single-server/src/main/resources/application.yml
+5
-1
No files found.
single-server/src/main/java/com/zq/single/config/WebMvcConfig.java
View file @
a16e91b7
...
...
@@ -9,14 +9,14 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@RequiredArgsConstructor
@Configuration
public
class
WebMvcConfig
implements
WebMvcConfigurer
{
private
final
ApiInterceptor
apiInterceptor
;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
apiInterceptor
)
.
addPathPatterns
(
"/single/**"
)
.
excludePathPatterns
(
"/xxxx/**"
);
// .excludePathPatterns("/xxxx/**")
;
}
}
single-server/src/main/java/com/zq/single/config/interceptor/ApiInterceptor.java
View file @
a16e91b7
...
...
@@ -6,6 +6,7 @@ import com.zq.common.config.redis.RedisUtils;
import
com.zq.common.config.security.SecurityProperties
;
import
com.zq.common.context.ContextUtils
;
import
com.zq.common.vo.ApiTokenVo
;
import
com.zq.single.vo.UserInfoVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
...
...
@@ -28,7 +29,7 @@ public class ApiInterceptor implements HandlerInterceptor {
log
.
debug
(
"{}请求URI: {}"
,
ip
,
request
.
getRequestURL
());
String
token
=
request
.
getHeader
(
properties
.
getHeader
());
ApiTokenVo
tokenVo
=
redisUtils
.
getObj
(
BaseCacheKeys
.
appTokenKey
(
token
),
ApiToken
Vo
.
class
);
UserInfoVo
tokenVo
=
redisUtils
.
getObj
(
BaseCacheKeys
.
appTokenKey
(
token
),
UserInfo
Vo
.
class
);
ContextUtils
.
setUserContext
(
tokenVo
);
return
true
;
...
...
single-server/src/main/java/com/zq/single/controller/AuthController.java
View file @
a16e91b7
...
...
@@ -13,13 +13,14 @@ import com.zq.common.vo.ResultVo;
import
com.zq.single.entity.CasSystem
;
import
com.zq.single.entity.CasUserInfo
;
import
com.zq.single.entity.SysUser
;
import
com.zq.single.entity.UserToken
;
import
com.zq.single.service.ICasSystemService
;
import
com.zq.single.service.ICasUserInfoService
;
import
com.zq.single.service.ISysUserService
;
import
com.zq.single.vo.UserInfoVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -56,7 +57,7 @@ public class AuthController {
@RequestMapping
(
"/login"
)
@AnonymousAccess
public
void
login
(
@RequestBody
SysUser
sysUser
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
ResultVo
login
(
@RequestBody
SysUser
sysUser
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
LambdaQueryWrapper
<
SysUser
>
sysUserLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sysUserLambdaQueryWrapper
.
eq
(
SysUser:
:
getUsername
,
sysUser
.
getUsername
());
List
<
SysUser
>
users
=
iSysUserService
.
list
(
sysUserLambdaQueryWrapper
);
...
...
@@ -76,9 +77,9 @@ public class AuthController {
LambdaQueryWrapper
<
CasUserInfo
>
casUserInfoLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
casUserInfoLambdaQueryWrapper
.
eq
(
CasUserInfo:
:
getUserId
,
thisUser
.
getUserId
());
List
<
CasUserInfo
>
infoList
=
iCasUserInfoService
.
list
(
casUserInfoLambdaQueryWrapper
);
User
Token
userToken
=
new
UserToken
();
User
InfoVo
userToken
=
new
UserInfoVo
();
userToken
.
setUserId
(
thisUser
.
getUserId
());
userToken
.
setUser
N
ame
(
thisUser
.
getUsername
());
userToken
.
setUser
n
ame
(
thisUser
.
getUsername
());
List
<
Map
<
String
,
String
>>
sonInfoList
=
new
ArrayList
<>();
for
(
CasUserInfo
casUserInfo
:
infoList
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
...
@@ -89,24 +90,27 @@ public class AuthController {
}
userToken
.
setSonInfoList
(
sonInfoList
);
ApiTokenVo
tokenVo
=
ApiTokenVo
.
builder
()
/*
ApiTokenVo tokenVo = ApiTokenVo.builder()
.userId(thisUser.getUserId())
.
build
();
String
token
=
ApiTokenUtils
.
createToken
(
tokenVo
,
BaseCacheKeys
.
APP_TOKEN_EXPIRE_MINUTES
);
.build();*/
String
token
=
ApiTokenUtils
.
createToken
(
userToken
,
BaseCacheKeys
.
APP_TOKEN_EXPIRE_MINUTES
);
response
.
setHeader
(
properties
.
getHeader
(),
token
);
redisUtils
.
setObj
(
BaseCacheKeys
.
appTokenKey
(
token
),
tokenVo
,
BaseCacheKeys
.
APP_TOKEN_EXPIRE_MINUTES
);
String
redirectUrl
=
"http://192.168.11.103:8080/#/login?"
+
properties
.
getHeader
()
+
"="
+
token
+
"&JSESSIONID="
+
request
.
getSession
().
getId
();
redisUtils
.
setObj
(
BaseCacheKeys
.
appTokenKey
(
token
),
userToken
,
BaseCacheKeys
.
APP_TOKEN_EXPIRE_MINUTES
);
/*
String redirectUrl = "http://192.168.11.103:8080/#/login?" + properties.getHeader() + "=" + token + "&JSESSIONID=" + request.getSession().getId();
// response.sendRedirect("" + "/#/verifyLogin?" + properties.getHeader() + "=" + token + "&JSESSIONID=" + request.getSession().getId());
response
.
sendRedirect
(
"http://192.168.11.103:8080/#/manage?"
+
properties
.
getHeader
()
+
"="
+
token
+
"&JSESSIONID="
+
request
.
getSession
().
getId
());
response.sendRedirect("http://192.168.11.103:8080/#/manage?" + properties.getHeader() + "=" + token + "&JSESSIONID=" + request.getSession().getId());
*/
return
ResultVo
.
success
();
}
@ApiOperation
(
"获取用户信息"
)
@GetMapping
(
value
=
"/info"
)
public
ResultVo
<
Object
>
getUserInfo
(
HttpServletRequest
request
)
{
String
token
=
request
.
getHeader
(
properties
.
getHeader
());
if
(
StringUtils
.
isNotBlank
(
token
))
{
token
=
token
.
replace
(
properties
.
getTokenStartWith
(),
""
);
}
Object
obj
=
redisUtils
.
getObj
(
BaseCacheKeys
.
appTokenKey
(
token
));
return
ResultVo
.
success
(
obj
);
}
...
...
single-server/src/main/java/com/zq/single/controller/SysUserController.java
View file @
a16e91b7
...
...
@@ -4,17 +4,30 @@ package com.zq.single.controller;
import
cn.hutool.core.util.IdcardUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.zq.common.annotation.AnonymousAccess
;
import
com.zq.common.config.redis.BaseCacheKeys
;
import
com.zq.common.config.redis.RedisUtils
;
import
com.zq.common.config.security.ApiTokenUtils
;
import
com.zq.common.config.security.SecurityProperties
;
import
com.zq.common.context.ContextUtils
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.single.entity.CasUserInfo
;
import
com.zq.single.entity.SysUser
;
import
com.zq.single.service.ISysUserService
;
import
com.zq.single.vo.CasUserInfoVo
;
import
com.zq.single.vo.UserInfoVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>
...
...
@@ -26,10 +39,13 @@ import java.util.List;
*/
@Api
(
value
=
"SysUserController"
,
tags
=
"账号管理"
)
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/single/user"
)
public
class
SysUserController
{
@Autowired
private
ISysUserService
sysUserService
;
private
final
RedisUtils
redisUtils
;
private
final
SecurityProperties
properties
;
@ApiOperation
(
"注册查用户名是否已存在"
)
@AnonymousAccess
...
...
@@ -52,7 +68,6 @@ public class SysUserController {
}
@ApiOperation
(
"更改用户信息"
)
@AnonymousAccess
@PostMapping
(
"/update"
)
public
ResultVo
update
(
@RequestBody
SysUser
sysUser
)
{
/* String password= MD5PasswordEncoderUtil.encode(sysUser.getPassword().trim());
...
...
@@ -63,16 +78,17 @@ public class SysUserController {
}
@ApiOperation
(
"删除用户信息"
)
@AnonymousAccess
@PostMapping
(
"/delete/{userId}"
)
public
ResultVo
delete
(
@PathVariable
(
"userId"
)
Long
userId
)
{
Boolean
isSuccess
=
sysUserService
.
removeById
(
userId
);
SysUser
sysUser
=
new
SysUser
();
sysUser
.
setUserId
(
userId
);
sysUser
.
setEnabled
(
0L
);
Boolean
isSuccess
=
sysUserService
.
updateById
(
sysUser
);
AssertUtils
.
isTrue
(
isSuccess
,
"服务器繁忙请稍后再试"
);
return
ResultVo
.
success
();
}
@ApiOperation
(
"用户详情"
)
@AnonymousAccess
@GetMapping
(
"/detail/{userName}"
)
public
ResultVo
detail
(
@PathVariable
(
"userName"
)
String
userName
)
{
LambdaQueryWrapper
<
SysUser
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
...
...
@@ -84,31 +100,29 @@ public class SysUserController {
@ApiOperation
(
"登录管理系统"
)
@AnonymousAccess
@PostMapping
(
"/login"
)
public
ResultVo
login
(
@RequestBody
SysUser
sysUser
)
{
public
ResultVo
login
(
@RequestBody
SysUser
sysUser
,
HttpServletResponse
response
)
{
LambdaQueryWrapper
<
SysUser
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
List
<
SysUser
>
list
=
sysUserService
.
list
(
lambdaQueryWrapper
.
eq
(
SysUser:
:
getUsername
,
sysUser
.
getUsername
()));
AssertUtils
.
isTrue
(
list
.
size
()
>
0
,
"用户名或密码错误"
);
String
password
=
list
.
get
(
0
).
getPassword
().
trim
();
SysUser
thisUser
=
list
.
get
(
0
);
String
password
=
thisUser
.
getPassword
().
trim
();
AssertUtils
.
isTrue
(
password
.
equals
(
sysUser
.
getPassword
()),
"用户名或密码错误"
);
UserInfoVo
userToken
=
new
UserInfoVo
();
userToken
.
setUserId
(
thisUser
.
getUserId
());
userToken
.
setUsername
(
thisUser
.
getUsername
());
String
token
=
ApiTokenUtils
.
createToken
(
userToken
,
BaseCacheKeys
.
APP_TOKEN_EXPIRE_MINUTES
);
response
.
setHeader
(
properties
.
getHeader
(),
token
);
String
s
=
BaseCacheKeys
.
appTokenKey
(
token
);
redisUtils
.
setObj
(
BaseCacheKeys
.
appTokenKey
(
token
),
userToken
,
BaseCacheKeys
.
APP_TOKEN_EXPIRE_MINUTES
);
return
ResultVo
.
success
();
}
@ApiOperation
(
"sfz"
)
@AnonymousAccess
@GetMapping
(
"/sfz/{sfz}"
)
public
void
sfz
(
@PathVariable
(
"sfz"
)
String
sfz
)
{
System
.
out
.
println
(
IdcardUtil
.
isValidCard18
(
sfz
));
System
.
out
.
println
(
IdcardUtil
.
getGenderByIdCard
(
sfz
));
System
.
out
.
println
(
IdcardUtil
.
getProvinceByIdCard
(
sfz
));
}
@ApiOperation
(
"单点登录用户绑定业务系统用户"
)
@AnonymousAccess
@PostMapping
(
"/blind"
)
public
ResultVo
blind
(
@RequestBody
CasUserInfoVo
vo
)
{
int
blind
=
sysUserService
.
blind
(
vo
);
...
...
@@ -116,5 +130,19 @@ public class SysUserController {
return
ResultVo
.
success
();
}
@ApiOperation
(
"单点登录用户管理列表"
)
@PostMapping
(
"/manageList"
)
public
ResultVo
manageList
(
@RequestBody
SysUser
sysUser
)
{
SysUser
thisUser
=
sysUserService
.
getById
(
sysUser
.
getUserId
());
if
(!
thisUser
.
getIsAdmin
()){
return
ResultVo
.
fail
(
"不是管理员"
);
}
LambdaQueryWrapper
<
SysUser
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
List
<
SysUser
>
userList
=
sysUserService
.
list
(
lambdaQueryWrapper
.
eq
(
SysUser:
:
getEnabled
,
1L
));
// AssertUtils.isTrue(blind > 0, "服务器繁忙请稍后再试");
return
ResultVo
.
success
(
userList
);
}
}
single-server/src/main/java/com/zq/single/entity/UserToken.java
deleted
100644 → 0
View file @
0667281d
package
com
.
zq
.
single
.
entity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
public
class
UserToken
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 用户ID
*/
private
Long
userId
;
/**
* 用户中文名
*/
private
String
userName
;
private
List
<
Map
<
String
,
String
>>
sonInfoList
;
}
single-server/src/main/java/com/zq/single/vo/UserInfoVo.java
View file @
a16e91b7
package
com
.
zq
.
single
.
vo
;
import
com.zq.common.vo.ApiTokenVo
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author wilmiam
* @since 2021/11/22 11:46
*/
@Data
public
class
UserInfoVo
extends
ApiTokenVo
{
private
Boolean
isAdmin
;
private
List
<
Map
<
String
,
String
>>
sonInfoList
;
}
single-server/src/main/resources/application.yml
View file @
a16e91b7
...
...
@@ -31,7 +31,7 @@ spring:
datasource
:
master
:
type
:
com.alibaba.druid.pool.DruidDataSource
url
:
jdbc:mysql://47.107.148.253:3306/
mz_big_data
?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
url
:
jdbc:mysql://47.107.148.253:3306/
cloud
?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username
:
root
password
:
Dk2019!23456
driver-class-name
:
com.mysql.cj.jdbc.Driver
...
...
@@ -63,10 +63,14 @@ spring:
# mybatis plus 配置
mybatis-plus
:
configuration
:
#打印sql,生产环境可已去掉
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
global-config
:
db-config
:
select-strategy
:
not_empty
update-strategy
:
not_empty
mapper-locations
:
classpath:/mapper/**.xml
#jwt
jwt
:
...
...
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