Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
Project
Project
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
liqin
chnmuseum-party
Commits
85ff986c
Commit
85ff986c
authored
Mar 24, 2021
by
wzp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
互动和日志修改
parent
6cbe2dd4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
234 additions
and
71 deletions
+234
-71
MyShiroRealm.java
...cn/wisenergy/chnmuseum/party/auth/realm/MyShiroRealm.java
+22
-16
ChinaMobileRestApiController.java
...um/party/web/controller/ChinaMobileRestApiController.java
+193
-43
LoginController.java
...nergy/chnmuseum/party/web/controller/LoginController.java
+11
-7
RoleController.java
...energy/chnmuseum/party/web/controller/RoleController.java
+1
-1
SysLogController.java
...ergy/chnmuseum/party/web/controller/SysLogController.java
+1
-3
TInteractionController.java
...hnmuseum/party/web/controller/TInteractionController.java
+6
-1
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/auth/realm/MyShiroRealm.java
View file @
85ff986c
...
...
@@ -6,6 +6,7 @@ import cn.wisenergy.chnmuseum.party.model.*;
import
cn.wisenergy.chnmuseum.party.service.PermissionService
;
import
cn.wisenergy.chnmuseum.party.service.RolePermissionService
;
import
cn.wisenergy.chnmuseum.party.service.RoleService
;
import
cn.wisenergy.chnmuseum.party.service.TUserService
;
import
cn.wisenergy.chnmuseum.party.service.impl.EmployeeRoleServiceImpl
;
import
cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -58,6 +59,9 @@ public class MyShiroRealm extends AuthorizingRealm {
@Resource
private
StringRedisTemplate
stringRedisTemplate
;
@Resource
private
TUserService
userService
;
/**
* 必须重写此方法,不然Shiro会报错
*/
...
...
@@ -89,9 +93,9 @@ public class MyShiroRealm extends AuthorizingRealm {
// 通过username从数据库中查找
// 实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法
String
employee
Id
=
JwtTokenUtil
.
getEmployeeId
(
credentials
);
Employee
employee
=
this
.
employeeService
.
selectByEmpId
(
employee
Id
);
if
(
employee
==
null
)
{
String
user
Id
=
JwtTokenUtil
.
getEmployeeId
(
credentials
);
TUser
user
=
userService
.
getById
(
user
Id
);
if
(
user
==
null
)
{
throw
new
AuthenticationException
(
"User does not exist!"
);
}
...
...
@@ -99,7 +103,7 @@ public class MyShiroRealm extends AuthorizingRealm {
throw
new
AuthenticationException
(
"token invalid"
);
}
return
new
SimpleAuthenticationInfo
(
new
Employee
(
employee
.
getId
(),
credentials
),
credentials
,
getName
());
return
new
SimpleAuthenticationInfo
(
new
TUser
(
user
.
getId
(),
credentials
),
credentials
,
getName
());
}
/**
...
...
@@ -108,27 +112,29 @@ public class MyShiroRealm extends AuthorizingRealm {
@Override
protected
AuthorizationInfo
doGetAuthorizationInfo
(
PrincipalCollection
principals
)
{
System
.
out
.
println
(
"权限认证方法:MyShiroRealm.doGetAuthorizationInfo()"
);
Employee
employee
=
(
Employee
)
principals
.
getPrimaryPrincipal
();
Boolean
hasToken
=
stringRedisTemplate
.
hasKey
(
SHIRO_JWT_TOKEN
+
employee
.
getJwtToken
());
TUser
user
=
(
TUser
)
principals
.
getPrimaryPrincipal
();
Boolean
hasToken
=
stringRedisTemplate
.
hasKey
(
SHIRO_JWT_TOKEN
+
user
.
getJwtToken
());
if
(
hasToken
==
null
||
!
hasToken
)
{
throw
new
AuthenticationException
(
"token invalid!"
);
}
String
employeeId
=
JwtTokenUtil
.
getEmployeeId
(
employee
.
getJwtToken
());
String
userId
=
JwtTokenUtil
.
getEmployeeId
(
user
.
getJwtToken
());
SimpleAuthorizationInfo
info
=
new
SimpleAuthorizationInfo
();
// 根据用户ID查询角色(role),放入到Authorization里。
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"employee_id"
,
employeeId
);
List
<
EmployeeRole
>
employeeRoleList
=
this
.
employeeRoleService
.
listByMap
(
map
);
List
<
Role
>
list
=
roleService
.
selectRoleByUserId
(
userId
);
// // 根据用户ID查询角色(role),放入到Authorization里。
// Map<String, Object> map = new HashMap<>();
// map.put("user_id", userId);
// List<EmployeeRole> employeeRoleList = this.employeeRoleService.listByMap(map);
List
<
String
>
ridList
=
new
LinkedList
<>();
for
(
EmployeeRole
employeeRole
:
employeeRoleList
)
{
ridList
.
add
(
employeeRole
.
getRoleId
());
}
List
<
Role
>
roleList
=
this
.
roleService
.
listByIds
(
ridList
);
//
for (EmployeeRole employeeRole : employeeRoleList) {
//
ridList.add(employeeRole.getRoleId());
//
}
//
List<Role> roleList = this.roleService.listByIds(ridList);
Set
<
String
>
roleSet
=
new
HashSet
<>();
for
(
Role
role
:
roleL
ist
)
{
for
(
Role
role
:
l
ist
)
{
roleSet
.
add
(
role
.
getAlias
());
ridList
.
add
(
role
.
getId
());
}
info
.
setRoles
(
roleSet
);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/ChinaMobileRestApiController.java
View file @
85ff986c
This diff is collapsed.
Click to expand it.
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/LoginController.java
View file @
85ff986c
...
...
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -120,6 +121,8 @@ public class LoginController {
TUser
user
;
if
(
StringUtils
.
isNoneBlank
(
username
))
{
try
{
//访问一次,计数一次
ValueOperations
<
String
,
String
>
opsForValue
=
stringRedisTemplate
.
opsForValue
();
if
(
"LOCK"
.
equals
(
opsForValue
.
get
(
SHIRO_IS_LOCK
+
username
)))
{
...
...
@@ -129,8 +132,6 @@ public class LoginController {
}
user
=
userService
.
selectByUsername
(
username
);
List
<
Role
>
roles
=
roleService
.
selectRoleByUserId
(
user
.
getId
());
user
.
setRoleList
(
roles
);
if
(
user
==
null
)
{
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"message"
,
"用户名或密码不正确!"
);
...
...
@@ -141,11 +142,13 @@ public class LoginController {
throw
new
DisabledAccountException
(
"此帐号已禁用,请联系管理员!"
);
}
// if (!user.getAllowLogin()) {
// throw new DisabledAccountException("您无权访问,请联系管理员!");
// }
if
(
user
.
getPermanent
()!=
null
&&!
user
.
getPermanent
())
{
if
(
user
.
getEffectiveDate
().
isAfter
(
LocalDate
.
now
())||
user
.
getExiredDate
().
isBefore
(
LocalDate
.
now
()))
{
throw
new
DisabledAccountException
(
"此帐号已失效,请联系管理员!"
);
}
}
try
{
byte
[]
salt
=
user
.
getPasswordSalt
();
String
s1
=
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
));
if
(!
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
)).
equals
(
new
String
(
user
.
getPasswordHash
())))
{
...
...
@@ -160,7 +163,8 @@ public class LoginController {
}
throw
new
IncorrectCredentialsException
(
"用户名或密码不正确!"
);
}
List
<
Role
>
roles
=
roleService
.
selectRoleByUserId
(
user
.
getId
());
user
.
setRoleList
(
roles
);
//获取当前用户角色拥有菜单
List
<
Menu
>
userMenuPerms
=
new
ArrayList
<>();
if
(
roles
.
size
()
>
0
)
{
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/RoleController.java
View file @
85ff986c
...
...
@@ -651,7 +651,7 @@ public class RoleController extends BaseController {
ew
.
eq
(
"is_deleted"
,
0
);
ew
.
eq
(
"status"
,
1
);
ew
.
orderByAsc
(
"sortorder"
);
ew
.
orderByDesc
(
"
upd
ate_time"
);
ew
.
orderByDesc
(
"
cre
ate_time"
);
return
ResponseEntity
.
ok
(
this
.
roleService
.
list
(
ew
));
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"查询角色列表出错!"
,
e
);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/SysLogController.java
View file @
85ff986c
...
...
@@ -31,8 +31,6 @@ import javax.annotation.Resource;
import
javax.servlet.http.HttpServletRequest
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
@RestController
...
...
@@ -127,7 +125,7 @@ public class SysLogController extends BaseController {
/**
* 插入机顶盒日志表
*/
@ApiOperation
(
value
=
"插入
系统日志"
,
notes
=
"插入系统日志
"
)
@ApiOperation
(
value
=
"插入
机顶盒日志表"
,
notes
=
"插入机顶盒日志表
"
)
@PostMapping
(
value
=
"/insertRunLog"
)
public
Boolean
insertRunLog
(
RunLog
runLog
)
{
boolean
b
=
runLogService
.
insertRunLog
(
runLog
);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TInteractionController.java
View file @
85ff986c
...
...
@@ -124,9 +124,14 @@ public class TInteractionController extends BaseController {
@PostMapping
(
"/getList"
)
@RequiresPermissions
(
"/interaction/getList"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"orgId"
,
value
=
"机构id"
,
paramType
=
"query"
,
dataType
=
"String"
)
})
@ApiOperation
(
value
=
"获取看板互动列表"
,
notes
=
"获取看板互动列表"
)
public
Map
<
String
,
Object
>
getTInteractionPageList
(
String
orgId
)
{
List
<
TInteraction
>
list
=
tInteractionService
.
list
(
new
UpdateWrapper
<
TInteraction
>().
eq
(
"organ_id"
,
orgId
));
Page
<
TInteraction
>
list
=
tInteractionService
.
page
(
getPage
(),
new
UpdateWrapper
<
TInteraction
>().
eq
(
"organ_id"
,
orgId
));
return
getResult
(
list
);
}
...
...
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