shiro cookie优化,员工授权等其他
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.cwhelp.admin.business.controller;
|
||||
|
||||
import com.cwhelp.admin.business.validator.BssDeptValid;
|
||||
import com.cwhelp.common.constant.AdminConst;
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.common.utils.EntityBeanUtil;
|
||||
import com.cwhelp.common.utils.ResultVoUtil;
|
||||
@@ -51,7 +52,7 @@ public class BssDeptController {
|
||||
.withMatcher("name", match -> match.contains());
|
||||
|
||||
User user = ShiroUtil.getSubject();
|
||||
if (1 != user.getBssPlatform().getId()) {
|
||||
if (AdminConst.ADMIN_PLATFORM_ID != user.getBssPlatform().getId()) {
|
||||
matcher.withMatcher("bssPlatform.id",match -> match.contains());
|
||||
BssPlatform bssPlatform = new BssPlatform();
|
||||
bssPlatform.setId(user.getBssPlatform().getId());
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.cwhelp.admin.business.controller;
|
||||
|
||||
|
||||
import com.cwhelp.admin.business.validator.BssEmployeeValid;
|
||||
import com.cwhelp.common.constant.AdminConst;
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.common.utils.EntityBeanUtil;
|
||||
import com.cwhelp.common.utils.ResultVoUtil;
|
||||
@@ -53,7 +54,7 @@ public class BssEmployeeController {
|
||||
|
||||
User user = ShiroUtil.getSubject();
|
||||
List<BssDept> bssDepts = null;
|
||||
if (1 != user.getBssPlatform().getId()) {
|
||||
if (AdminConst.ADMIN_PLATFORM_ID != user.getBssPlatform().getId()) {
|
||||
bssDepts = bssDeptService.findBssDeptByBssPlatformAndId(user.getBssPlatform());
|
||||
}
|
||||
Page<BssEmployee> list = bssEmployeeService.getPageList(bssDepts,bssEmployee);
|
||||
@@ -99,7 +100,7 @@ public class BssEmployeeController {
|
||||
*/
|
||||
private List<BssDept> getBssDepts(User user, BssPlatform bssPlatform) {
|
||||
List<BssDept> bssDepts = null;
|
||||
if (1 != user.getBssPlatform().getId()) {
|
||||
if (AdminConst.ADMIN_PLATFORM_ID != user.getBssPlatform().getId()) {
|
||||
bssDepts = bssDeptService.findBssDeptByBssPlatformAndId(bssPlatform);
|
||||
} else {
|
||||
bssDepts = bssDeptService.findAll();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cwhelp.admin.business.controller;
|
||||
|
||||
import com.cwhelp.admin.business.validator.BssPlatformValid;
|
||||
import com.cwhelp.common.constant.AdminConst;
|
||||
import com.cwhelp.common.enums.ResultEnum;
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.common.utils.EntityBeanUtil;
|
||||
@@ -52,7 +53,7 @@ public class BssPlatformController {
|
||||
.withMatcher("email", match -> match.contains());
|
||||
User user = ShiroUtil.getSubject();
|
||||
// 判定当前用户的 所属平台 1为系统平台
|
||||
if (1 != user.getBssPlatform().getId()) {
|
||||
if (AdminConst.ADMIN_PLATFORM_ID != user.getBssPlatform().getId()) {
|
||||
matcher.withMatcher("id",match -> match.contains());
|
||||
bssPlatform.setId(user.getBssPlatform().getId());
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ public class LoginController implements ErrorController {
|
||||
|
||||
// 1.获取Subject主体对象
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
|
||||
// 2.封装用户数据
|
||||
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.cwhelp.admin.system.controller;
|
||||
|
||||
import com.cwhelp.admin.system.validator.RoleValid;
|
||||
import com.cwhelp.common.constant.AdminConst;
|
||||
import com.cwhelp.common.constant.RoleConst;
|
||||
import com.cwhelp.common.enums.ResultEnum;
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.common.exception.ResultException;
|
||||
@@ -14,17 +15,22 @@ import com.cwhelp.component.actionLog.action.StatusAction;
|
||||
import com.cwhelp.component.actionLog.annotation.ActionLog;
|
||||
import com.cwhelp.component.actionLog.annotation.EntityParam;
|
||||
import com.cwhelp.component.shiro.ShiroUtil;
|
||||
import com.cwhelp.modules.business.domain.BssEmployee;
|
||||
import com.cwhelp.modules.system.domain.Menu;
|
||||
import com.cwhelp.modules.system.domain.Role;
|
||||
import com.cwhelp.modules.system.domain.User;
|
||||
import com.cwhelp.modules.system.service.MenuService;
|
||||
import com.cwhelp.modules.system.service.RoleService;
|
||||
import com.cwhelp.modules.system.service.UserService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -45,6 +51,8 @@ public class RoleController {
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
/**
|
||||
* 列表页面
|
||||
*/
|
||||
@@ -66,6 +74,33 @@ public class RoleController {
|
||||
return "/system/role/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到角色分配页面
|
||||
*/
|
||||
@GetMapping("/rolePage")
|
||||
@RequiresPermissions("system:user:role")
|
||||
public String toRole(@RequestParam(value = "ids") BssEmployee bssEmployee, Model model) {
|
||||
User user = userService.getByName(bssEmployee.getPhoneNum());
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
throw new ResultException(ResultEnum.USER_NOE_EXIST);
|
||||
}
|
||||
// 获取指定用户角色列表
|
||||
Set<Role> authRoles = user.getRoles();
|
||||
Sort sort = new Sort(Sort.Direction.ASC, "createDate");
|
||||
List<Role> list = null;
|
||||
//如果当前用户是超级用户
|
||||
if (user.getId() == AdminConst.ADMIN_ID) {
|
||||
list = roleService.getListBySortOk(sort);
|
||||
} else {
|
||||
list = roleService.getListByType(sort, RoleConst.ROLE_ORDINARY_TYPE);
|
||||
}
|
||||
|
||||
model.addAttribute("id", user.getId());
|
||||
model.addAttribute("list", list);
|
||||
model.addAttribute("authRoles", authRoles);
|
||||
return "/system/user/role";
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到添加页面
|
||||
*/
|
||||
|
||||
@@ -155,6 +155,11 @@ public class UserController {
|
||||
throw new ResultException(ResultEnum.USER_EXIST);
|
||||
}
|
||||
|
||||
// 判断手机号码是否重复
|
||||
if (userService.repeatByPhone(user)) {
|
||||
throw new ResultException(ResultEnum.USER_PHONE_EXIST);
|
||||
}
|
||||
|
||||
// 复制保留无需修改的数据
|
||||
if (user.getId() != null) {
|
||||
// 不允许操作超级管理员数据
|
||||
|
||||
@@ -38,13 +38,14 @@
|
||||
<div class="pull-right screen-btn-group">
|
||||
<button class="layui-btn open-popup" data-title="添加员工" th:attr="data-url=@{/bss/employee/add}" data-size="auto">
|
||||
<i class="fa fa-plus"></i> 添加</button>
|
||||
<button class="layui-btn open-popup-param" data-type="radio" data-title="角色分配" th:attr="data-url=@{/system/role/rolePage}" data-size="480,400">
|
||||
<i class="fa fa-user-secret"></i> 授权</button>
|
||||
<div class="btn-group">
|
||||
<button class="layui-btn">操作<span class="caret"></span></button>
|
||||
<dl class="layui-nav-child layui-anim layui-anim-upbit">
|
||||
<dd><a class="ajax-status" th:href="@{/bss/employee/status/ok}">启用</a></dd>
|
||||
<dd><a class="ajax-status" th:href="@{/bss/employee/status/freezed}">冻结</a></dd>
|
||||
<dd><a class="ajax-status" th:href="@{/bss/employee/status/delete}">删除</a></dd>
|
||||
<dd><a class="ajax-status" th:href="@{/bss/employee/role}">授权</a></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -88,7 +89,6 @@
|
||||
<a class="open-popup" data-title="编辑员工" th:attr="data-url=@{'/bss/employee/edit/'+${item.id}}" data-size="auto" href="#">编辑</a>
|
||||
<a class="open-popup" data-title="详细信息" th:attr="data-url=@{'/bss/employee/detail/'+${item.id}}" data-size="800,600" href="#">详细</a>
|
||||
<a class="ajax-get" data-msg="您是否确认删除" th:href="@{/bss/employee/status/delete(ids=${item.id})}">删除</a>
|
||||
<a class="open-popup" th:href="@{/bss/employee/role}">授权</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<img class="layui-side-user-avatar open-popup" th:attr="data-url=@{/userInfo}" data-size="680,464"
|
||||
th:src="@{'/system/user/picture?p='+${user.picture}}" alt="头像">
|
||||
<div>
|
||||
<p class="layui-side-user-name" th:text="${user.nickname}">TIMO</p>
|
||||
<p class="layui-side-user-name" th:text="${user.nickname}"></p>
|
||||
<p class="layui-side-user-designation">在线</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
<input class="layui-input" type="text" name="title" placeholder="请输入角色名称" th:value="${role?.title}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">类型</label>
|
||||
<div class="layui-input-block">
|
||||
<select class="layui-select" name="type" mo:dict="ROLE_TYPE" mo-selected="${role?.type}" mo-empty="" lay-type="type"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
<th width='100px'>角色编号名称</th>
|
||||
<td>[[${role.title}]]([[${role.name}]])</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>角色类型</th>
|
||||
<td th:text="${#dicts.keyValue('ROLE_TYPE', role.type)}" colspan="3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>创建用户</th>
|
||||
<td th:text="${role.createBy?.nickname}"></td>
|
||||
|
||||
Reference in New Issue
Block a user