新增角色管理查询
This commit is contained in:
parent
7a47fba882
commit
0b1793d57d
|
|
@ -58,22 +58,23 @@ insert into sys_user values('2', '8', 'ry', '若依', 'ry@163.com', '152
|
|||
-- ----------------------------
|
||||
drop table if exists sys_role;
|
||||
create table sys_role (
|
||||
role_id int(10) not null auto_increment comment '角色ID',
|
||||
role_name varchar(30) not null comment '角色名',
|
||||
role_key varchar(100) not null comment '角色权限字符串',
|
||||
status int(1) default 0 comment '角色状态:0正常,1禁用',
|
||||
create_time varchar(30) default null comment '创建时间',
|
||||
update_time varchar(30) default null comment '更新时间',
|
||||
update_by varchar(30) default null comment '更新者',
|
||||
remark varchar(500) default '' comment '备注',
|
||||
role_id int(10) not null auto_increment comment '角色ID',
|
||||
role_name varchar(30) not null comment '角色名',
|
||||
role_key varchar(100) not null comment '角色权限字符串',
|
||||
role_sort int(10) not null comment '显示顺序',
|
||||
status int(1) default 0 comment '角色状态:0正常,1禁用',
|
||||
create_time timestamp default current_timestamp comment '创建时间',
|
||||
update_time timestamp default current_timestamp comment '更新时间',
|
||||
update_by varchar(30) default null comment '更新者',
|
||||
remark varchar(500) default '' comment '备注',
|
||||
primary key (role_id)
|
||||
) engine=innodb auto_increment=100 default charset=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- 初始化-角色信息表数据
|
||||
-- ----------------------------
|
||||
insert into sys_role values('1', '管理员', 'admin', 0, '2018-03-01', '', 'system', '管理员');
|
||||
insert into sys_role values('2', '普通角色', 'common', 0, '2018-03-01', '', 'system', '普通角色');
|
||||
insert into sys_role values('1', '管理员', 'admin', 1, 0, '2018-03-01', '2018-03-01', 'system', '管理员');
|
||||
insert into sys_role values('2', '普通角色', 'common', 2, 0, '2018-03-01', '2018-03-01', 'system', '普通角色');
|
||||
|
||||
|
||||
|
||||
|
|
@ -113,19 +114,25 @@ insert into sys_menu values('7', '操作日志', '2', '1', '/monitor/operlog',
|
|||
insert into sys_menu values('8', '登录日志', '2', '2', '/monitor/logininfor', 'C', '0', 'monitor:logininfor:view', '#', '2018-03-01', '', 'admin', '登录日志菜单');
|
||||
insert into sys_menu values('9', '在线用户', '2', '3', '/monitor/online', 'C', '0', 'monitor:online:view', '#', '2018-03-01', '', 'admin', '在线用户菜单');
|
||||
insert into sys_menu values('10', '数据监控', '2', '4', '/monitor/data', 'C', '0', 'monitor:data:view', '#', '2018-03-01', '', 'admin', '数据监控菜单');
|
||||
-- 用户管理按钮
|
||||
insert into sys_menu values('11', '用户新增', '6', '1', '/system/user/add', 'F', '0', 'system:user:add', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('12', '用户修改', '6', '2', '/system/user/edit', 'F', '0', 'system:user:edit', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('13', '用户删除', '6', '3', '/system/user/remove', 'F', '0', 'system:user:remove', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('14', '用户保存', '6', '4', '/system/user/save', 'F', '0', 'system:user:save', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('15', '批量删除', '6', '4', '/system/user/batchRemove', 'F', '0', 'system:user:batchRemove', '#', '2018-03-01', '', 'admin', '');
|
||||
-- 部门管理按钮
|
||||
insert into sys_menu values('11', '部门新增', '6', '1', '/system/dept/add', 'F', '0', 'system:dept:add', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('12', '部门修改', '6', '2', '/system/dept/edit', 'F', '0', 'system:dept:edit', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('13', '部门删除', '6', '3', '/system/dept/remove', 'F', '0', 'system:dept:remove', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('14', '部门保存', '6', '4', '/system/dept/save', 'F', '0', 'system:dept:save', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('16', '部门新增', '6', '1', '/system/dept/add', 'F', '0', 'system:dept:add', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('17', '部门修改', '6', '2', '/system/dept/edit', 'F', '0', 'system:dept:edit', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('18', '部门删除', '6', '3', '/system/dept/remove', 'F', '0', 'system:dept:remove', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('19', '部门保存', '6', '4', '/system/dept/save', 'F', '0', 'system:dept:save', '#', '2018-03-01', '', 'admin', '');
|
||||
-- 操作日志按钮
|
||||
insert into sys_menu values('15', '批量删除', '7', '1', '/monitor/operlog/batchRemove', 'F', '0', 'monitor:operlog:batchRemove', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('16', '详细信息', '7', '2', '/monitor/operlog/detail', 'F', '0', 'monitor:operlog:detail', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('20', '批量删除', '7', '1', '/monitor/operlog/batchRemove', 'F', '0', 'monitor:operlog:batchRemove', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('21', '详细信息', '7', '2', '/monitor/operlog/detail', 'F', '0', 'monitor:operlog:detail', '#', '2018-03-01', '', 'admin', '');
|
||||
-- 登录日志按钮
|
||||
insert into sys_menu values('17', '批量删除', '8', '1', '/monitor/logininfor/batchRemove', 'F', '0', 'monitor:logininfor:batchRemove', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('22', '批量删除', '8', '1', '/monitor/logininfor/batchRemove', 'F', '0', 'monitor:logininfor:batchRemove', '#', '2018-03-01', '', 'admin', '');
|
||||
-- 在线用户按钮
|
||||
insert into sys_menu values('18', '批量强退', '9', '1', '/monitor/online/batchForceLogout', 'F', '0', 'monitor:online:batchForceLogout', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('19', '单条强退', '9', '2', '/monitor/online/forceLogout', 'F', '0', 'monitor:online:forceLogout', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('23', '批量强退', '9', '1', '/monitor/online/batchForceLogout', 'F', '0', 'monitor:online:batchForceLogout', '#', '2018-03-01', '', 'admin', '');
|
||||
insert into sys_menu values('24', '单条强退', '9', '2', '/monitor/online/forceLogout', 'F', '0', 'monitor:online:forceLogout', '#', '2018-03-01', '', 'admin', '');
|
||||
|
||||
-- ----------------------------
|
||||
-- 5、用户和角色关联表 用户N-1角色
|
||||
|
|
@ -168,15 +175,21 @@ insert into sys_role_menu values ('1', '7');
|
|||
insert into sys_role_menu values ('1', '8');
|
||||
insert into sys_role_menu values ('1', '9');
|
||||
insert into sys_role_menu values ('1', '10');
|
||||
insert into sys_role_menu values ('1', '11');
|
||||
insert into sys_role_menu values ('1', '12');
|
||||
insert into sys_role_menu values ('1', '13');
|
||||
insert into sys_role_menu values ('1', '14');
|
||||
insert into sys_role_menu values ('1', '15');
|
||||
--insert into sys_role_menu values ('1', '11');
|
||||
--insert into sys_role_menu values ('1', '12');
|
||||
--insert into sys_role_menu values ('1', '13');
|
||||
--insert into sys_role_menu values ('1', '14');
|
||||
--insert into sys_role_menu values ('1', '15');
|
||||
insert into sys_role_menu values ('1', '16');
|
||||
insert into sys_role_menu values ('1', '17');
|
||||
insert into sys_role_menu values ('1', '18');
|
||||
insert into sys_role_menu values ('1', '19');
|
||||
insert into sys_role_menu values ('1', '20');
|
||||
insert into sys_role_menu values ('1', '21');
|
||||
insert into sys_role_menu values ('1', '22');
|
||||
insert into sys_role_menu values ('1', '23');
|
||||
insert into sys_role_menu values ('1', '24');
|
||||
insert into sys_role_menu values ('1', '25');
|
||||
-- ----------------------------
|
||||
-- 7、操作日志记录
|
||||
-- ----------------------------
|
||||
|
|
@ -26,7 +26,7 @@ public class CommonConstant
|
|||
/**
|
||||
* 注销
|
||||
*/
|
||||
public static final String Logout = "Logout";
|
||||
public static final String LOGOUT = "Logout";
|
||||
|
||||
/**
|
||||
* 登录失败
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class SystemLogUtils
|
|||
|
||||
sys_user_logger.info(s.toString(), args);
|
||||
|
||||
if (CommonConstant.LOGIN_SUCCESS.equals(status) || CommonConstant.Logout.equals(status))
|
||||
if (CommonConstant.LOGIN_SUCCESS.equals(status) || CommonConstant.LOGOUT.equals(status))
|
||||
{
|
||||
saveOpLog(username, msg, CommonConstant.SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
|
|||
{
|
||||
String loginName = ShiroUtils.getLoginName();
|
||||
// 记录用户退出日志
|
||||
SystemLogUtils.log(loginName, CommonConstant.Logout, MessageUtils.message("user.logout.success"));
|
||||
SystemLogUtils.log(loginName, CommonConstant.LOGOUT, MessageUtils.message("user.logout.success"));
|
||||
// 退出登录
|
||||
subject.logout();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class LogininforDaoImpl extends DynamicObjectBaseDao implements ILogininf
|
|||
* @param ids 需要删除的数据
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int batchDeleteLogininfor(Long[] ids)
|
||||
{
|
||||
int rows = 0;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public class LogininforServiceImpl implements ILogininforService
|
|||
* @param pageUtilEntity 分页参数
|
||||
* @return 登录记录集合
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo pageInfoQueryLogininfor(PageUtilEntity pageUtilEntity)
|
||||
{
|
||||
return logininforDao.pageInfoQuery(pageUtilEntity);
|
||||
|
|
@ -47,6 +48,7 @@ public class LogininforServiceImpl implements ILogininforService
|
|||
* @param ids 需要删除的数据
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int batchDeleteLogininfor(Long[] ids)
|
||||
{
|
||||
return logininforDao.batchDeleteLogininfor(ids);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class OperLogDaoImpl extends DynamicObjectBaseDao implements IOperLogDao
|
|||
* @param pageUtilEntity 分页参数
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity)
|
||||
{
|
||||
return this.findForList("SystemOperLogMapper.pageInfoQueryOperLog", pageUtilEntity);
|
||||
|
|
@ -42,6 +43,7 @@ public class OperLogDaoImpl extends DynamicObjectBaseDao implements IOperLogDao
|
|||
* @param ids 需要删除的数据
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int batchDeleteOperLog(Long[] ids)
|
||||
{
|
||||
int rows = 0;
|
||||
|
|
@ -62,6 +64,7 @@ public class OperLogDaoImpl extends DynamicObjectBaseDao implements IOperLogDao
|
|||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
@Override
|
||||
public OperLog selectOperLogById(Long operId)
|
||||
{
|
||||
return this.findForObject("SystemOperLogMapper.selectOperLogById", operId);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public class OperLogServiceImpl implements IOperLogService
|
|||
* @param pageUtilEntity 分页参数
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo pageInfoQueryOperLog(PageUtilEntity pageUtilEntity)
|
||||
{
|
||||
return operLogDao.pageInfoQuery(pageUtilEntity);
|
||||
|
|
@ -46,6 +47,7 @@ public class OperLogServiceImpl implements IOperLogService
|
|||
* @param ids 需要删除的数据
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int batchDeleteOperLog(Long[] ids)
|
||||
{
|
||||
return operLogDao.batchDeleteOperLog(ids);
|
||||
|
|
@ -57,6 +59,7 @@ public class OperLogServiceImpl implements IOperLogService
|
|||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
@Override
|
||||
public OperLog selectOperLogById(Long operId)
|
||||
{
|
||||
return operLogDao.selectOperLogById(operId);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
|
|||
*
|
||||
* @param dept 部门对象
|
||||
*/
|
||||
@Override
|
||||
public int insertDept(Dept dept)
|
||||
{
|
||||
return this.save("SystemDeptMapper.insertDept", dept);
|
||||
|
|
@ -28,6 +29,7 @@ public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
|
|||
*
|
||||
* @return 所有部门信息
|
||||
*/
|
||||
@Override
|
||||
public List<Dept> selectDeptAll()
|
||||
{
|
||||
List<Dept> deptList = null;
|
||||
|
|
@ -48,6 +50,7 @@ public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
|
|||
* @param parentId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int selectDeptCount(Dept dept)
|
||||
{
|
||||
return this.count("SystemDeptMapper.selectDeptCount", dept);
|
||||
|
|
@ -59,6 +62,7 @@ public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
|
|||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int checkDeptExistUser(Long deptId)
|
||||
{
|
||||
return this.count("SystemDeptMapper.checkDeptExistUser", deptId);
|
||||
|
|
@ -70,6 +74,7 @@ public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
|
|||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId)
|
||||
{
|
||||
return this.delete("SystemDeptMapper.deleteDeptById", deptId);
|
||||
|
|
@ -81,6 +86,7 @@ public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
|
|||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveDept(Dept dept)
|
||||
{
|
||||
return this.save("SystemDeptMapper.saveDept", dept);
|
||||
|
|
@ -92,6 +98,7 @@ public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
|
|||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Override
|
||||
public Dept selectDeptById(Long deptId)
|
||||
{
|
||||
return this.findForObject("SystemDeptMapper.selectDeptById", deptId);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
*
|
||||
* @param dept 部门对象
|
||||
*/
|
||||
@Override
|
||||
public int insertDept(Dept dept)
|
||||
{
|
||||
return deptDao.insertDept(dept);
|
||||
|
|
@ -37,6 +38,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
*
|
||||
* @return 所有部门信息
|
||||
*/
|
||||
@Override
|
||||
public List<Dept> selectDeptAll()
|
||||
{
|
||||
return deptDao.selectDeptAll();
|
||||
|
|
@ -47,6 +49,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
*
|
||||
* @return 所有部门信息
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> selectDeptTree()
|
||||
{
|
||||
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
|
||||
|
|
@ -69,6 +72,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
* @param parentId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int selectDeptCount(Long parentId)
|
||||
{
|
||||
Dept dept = new Dept();
|
||||
|
|
@ -82,6 +86,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
* @param deptId 部门ID
|
||||
* @return 结果 true 存在 false 不存在
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptExistUser(Long deptId)
|
||||
{
|
||||
int result = deptDao.checkDeptExistUser(deptId);
|
||||
|
|
@ -94,6 +99,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId)
|
||||
{
|
||||
return deptDao.deleteDeptById(deptId);
|
||||
|
|
@ -105,6 +111,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveDept(Dept dept)
|
||||
{
|
||||
return deptDao.saveDept(dept);
|
||||
|
|
@ -116,6 +123,7 @@ public class DeptServiceImpl implements IDeptService
|
|||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Override
|
||||
public Dept selectDeptById(Long deptId)
|
||||
{
|
||||
return deptDao.selectDeptById(deptId);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
package com.ruoyi.project.system.role.controller;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.JSON;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
import com.ruoyi.project.system.role.service.IRoleService;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/system/role")
|
||||
public class RoleController extends BaseController
|
||||
{
|
||||
|
||||
private String prefix = "system/role";
|
||||
|
||||
@Autowired
|
||||
private IRoleService roleService;
|
||||
|
||||
@RequiresPermissions("system:role:view")
|
||||
@GetMapping()
|
||||
public String user()
|
||||
{
|
||||
return prefix + "/role";
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:role:view")
|
||||
@GetMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list()
|
||||
{
|
||||
TableDataInfo rows = roleService.pageInfoQuery(getPageUtilEntity());
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Log(title = "系统管理", action = "角色管理-删除角色")
|
||||
@RequestMapping("/remove/{roleId}")
|
||||
@ResponseBody
|
||||
public JSON remove(@PathVariable("roleId") Long roleId)
|
||||
{
|
||||
Role role = roleService.selectRoleById(roleId);
|
||||
if (role == null)
|
||||
{
|
||||
return JSON.error("角色不存在");
|
||||
}
|
||||
if (roleService.deleteRoleById(roleId) > 0)
|
||||
{
|
||||
return JSON.ok();
|
||||
}
|
||||
return JSON.error();
|
||||
}
|
||||
|
||||
@Log(title = "系统管理", action = "角色管理-批量删除")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
public JSON batchRemove(@RequestParam("ids[]") Long[] ids)
|
||||
{
|
||||
int rows = roleService.batchDeleteRole(ids);
|
||||
if (rows > 0)
|
||||
{
|
||||
return JSON.ok();
|
||||
}
|
||||
return JSON.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择菜单树
|
||||
*/
|
||||
@GetMapping("/selectMenuTree")
|
||||
public String selectMenuTree()
|
||||
{
|
||||
return prefix + "/tree";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package com.ruoyi.project.system.role.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.framework.web.page.PageUtilEntity;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
|
||||
/**
|
||||
|
|
@ -12,6 +14,14 @@ import com.ruoyi.project.system.role.domain.Role;
|
|||
public interface IRoleDao
|
||||
{
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户对象
|
||||
*
|
||||
* @param pageUtilEntity 分页对象
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
|
|
@ -27,4 +37,28 @@ public interface IRoleDao
|
|||
*/
|
||||
public List<Role> selectRolesAll();
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public Role selectRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量角色用户信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchDeleteRole(Long[] ids);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.ruoyi.project.system.role.dao;
|
|||
import java.util.List;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.ruoyi.framework.web.dao.DynamicObjectBaseDao;
|
||||
import com.ruoyi.framework.web.page.PageUtilEntity;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
|
||||
/**
|
||||
|
|
@ -14,6 +16,17 @@ import com.ruoyi.project.system.role.domain.Role;
|
|||
public class RoleDaoImpl extends DynamicObjectBaseDao implements IRoleDao
|
||||
{
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户对象
|
||||
*
|
||||
* @param pageUtilEntity 分页对象
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity)
|
||||
{
|
||||
return this.findForList("SystemRoleMapper.pageInfoQuery", pageUtilEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
|
|
@ -56,4 +69,37 @@ public class RoleDaoImpl extends DynamicObjectBaseDao implements IRoleDao
|
|||
return roleList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public Role selectRoleById(Long roleId)
|
||||
{
|
||||
return this.findForObject("SystemRoleMapper.selectRoleById", roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleById(Long roleId)
|
||||
{
|
||||
return this.delete("SystemRoleMapper.deleteRoleById", roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量角色用户信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchDeleteRole(Long[] ids)
|
||||
{
|
||||
return this.delete("SystemRoleMapper.batchDeleteRole", ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.project.system.role.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -16,12 +17,14 @@ public class Role
|
|||
private String roleName;
|
||||
/** 角色权限 */
|
||||
private String roleKey;
|
||||
/** 角色排序 */
|
||||
private String roleSort;
|
||||
/** 角色状态:0正常,1禁用 */
|
||||
private String status;
|
||||
private int status;
|
||||
/** 创建时间 */
|
||||
private String createTime;
|
||||
private Date createTime;
|
||||
/** 更新时间 */
|
||||
private String updateTime;
|
||||
private Date updateTime;
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
/** 备注 */
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ package com.ruoyi.project.system.role.service;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ruoyi.framework.web.page.PageUtilEntity;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
|
||||
/**
|
||||
|
|
@ -12,6 +15,14 @@ import com.ruoyi.project.system.role.domain.Role;
|
|||
public interface IRoleService
|
||||
{
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色对象
|
||||
*
|
||||
* @param pageUtilEntity 分页对象
|
||||
* @return 角色信息集合信息
|
||||
*/
|
||||
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
|
|
@ -35,4 +46,28 @@ public interface IRoleService
|
|||
*/
|
||||
public List<Role> selectRoleAll();
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public Role selectRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量角色用户信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchDeleteRole(Long[] ids);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import java.util.Set;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.page.PageUtilEntity;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.role.dao.IRoleDao;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
|
||||
|
|
@ -22,6 +24,17 @@ public class RoleServiceImpl implements IRoleService
|
|||
@Autowired
|
||||
private IRoleDao roleDao;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色对象
|
||||
*
|
||||
* @param pageUtilEntity 分页对象
|
||||
* @return 角色信息集合信息
|
||||
*/
|
||||
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity)
|
||||
{
|
||||
return roleDao.pageInfoQuery(pageUtilEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
|
|
@ -49,6 +62,7 @@ public class RoleServiceImpl implements IRoleService
|
|||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public List<Role> selectRolesByUserId(Long userId)
|
||||
{
|
||||
List<Role> userRoles = roleDao.selectRolesByUserId(userId);
|
||||
|
|
@ -72,9 +86,43 @@ public class RoleServiceImpl implements IRoleService
|
|||
*
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public List<Role> selectRoleAll()
|
||||
{
|
||||
return roleDao.selectRolesAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public Role selectRoleById(Long roleId)
|
||||
{
|
||||
return roleDao.selectRoleById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleById(Long roleId)
|
||||
{
|
||||
return roleDao.deleteRoleById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量角色用户信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchDeleteRole(Long[] ids)
|
||||
{
|
||||
return roleDao.batchDeleteRole(ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class UserController extends BaseController
|
|||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "系统管理", action = "用户管理-修改用户")
|
||||
@GetMapping("/edit/{userId}")
|
||||
public String edit(@PathVariable("userId") Long userId, Model model)
|
||||
|
|
@ -73,6 +74,7 @@ public class UserController extends BaseController
|
|||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:add")
|
||||
@Log(title = "系统管理", action = "用户管理-新增用户")
|
||||
@GetMapping("/add")
|
||||
public String add(Model model)
|
||||
|
|
@ -82,6 +84,7 @@ public class UserController extends BaseController
|
|||
return prefix + "/add";
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:remove")
|
||||
@Log(title = "系统管理", action = "用户管理-删除用户")
|
||||
@RequestMapping("/remove/{userId}")
|
||||
@ResponseBody
|
||||
|
|
@ -99,6 +102,7 @@ public class UserController extends BaseController
|
|||
return JSON.error();
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:batchRemove")
|
||||
@Log(title = "系统管理", action = "用户管理-批量删除")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
|
|
@ -115,8 +119,8 @@ public class UserController extends BaseController
|
|||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequiresPermissions("system:user:save")
|
||||
@Log(title = "系统管理", action = "部门管理-保存部门")
|
||||
@RequiresPermissions("system:dept:save")
|
||||
@PostMapping("/save")
|
||||
@ResponseBody
|
||||
public JSON save(User user)
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
|
|||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int batchDeleteUser(Long[] ids)
|
||||
{
|
||||
return this.delete("SystemUserMapper.batchDeleteUser", ids);
|
||||
|
|
@ -95,6 +96,7 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
|
|||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUser(User user)
|
||||
{
|
||||
return this.update("SystemUserMapper.updateUser", user);
|
||||
|
|
@ -106,6 +108,7 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
|
|||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertUser(User user)
|
||||
{
|
||||
return this.save("SystemUserMapper.insertUser", user);
|
||||
|
|
@ -123,6 +126,7 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
|
|||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int batchUserRole(List<UserRole> userRoleList)
|
||||
{
|
||||
return this.batchSave("SystemUserRoleMapper.batchUserRole", userRoleList);
|
||||
|
|
@ -134,6 +138,7 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
|
|||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int checkNameUnique(String loginName)
|
||||
{
|
||||
return this.count("SystemUserMapper.checkNameUnique", loginName);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public class UserServiceImpl implements IUserService
|
|||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public User selectUserById(Long userId)
|
||||
{
|
||||
return userDao.selectUserById(userId);
|
||||
|
|
@ -68,6 +69,7 @@ public class UserServiceImpl implements IUserService
|
|||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUserById(Long userId)
|
||||
{
|
||||
return userDao.deleteUserById(userId);
|
||||
|
|
@ -79,6 +81,7 @@ public class UserServiceImpl implements IUserService
|
|||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int batchDeleteUser(Long[] ids)
|
||||
{
|
||||
return userDao.batchDeleteUser(ids);
|
||||
|
|
@ -90,6 +93,7 @@ public class UserServiceImpl implements IUserService
|
|||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveUser(User user)
|
||||
{
|
||||
Long userId = user.getUserId();
|
||||
|
|
@ -136,6 +140,7 @@ public class UserServiceImpl implements IUserService
|
|||
* @param userName 用户名
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkNameUnique(String loginName)
|
||||
{
|
||||
int count = userDao.checkNameUnique(loginName);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<id property="roleId" column="role_id" />
|
||||
<result property="roleName" column="role_name" />
|
||||
<result property="roleKey" column="role_key" />
|
||||
<result property="roleSort" column="role_sort" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
|
|
@ -15,6 +16,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<select id="pageInfoQuery" parameterType="PageUtilEntity" resultMap="RoleResult">
|
||||
select * from sys_role
|
||||
<where>
|
||||
<if test="searchValue != null and searchValue != ''">
|
||||
AND role_name = #{searchValue}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectRolesByUserId" parameterType="Long" resultMap="RoleResult">
|
||||
SELECT r.role_id, r.role_name, r.role_key
|
||||
FROM sys_user u
|
||||
|
|
@ -27,4 +37,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SELECT * FROM sys_role
|
||||
</select>
|
||||
|
||||
<select id="selectRoleById" parameterType="Long" resultMap="RoleResult">
|
||||
select *
|
||||
from sys_role u
|
||||
where u.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteRoleById" parameterType="Long">
|
||||
delete from sys_role where role_id = #{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="batchDeleteRole" parameterType="String">
|
||||
delete from sys_role where role_id in
|
||||
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
var prefix = "/system/role"
|
||||
|
||||
$(function() {
|
||||
var columns = [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'roleId',
|
||||
title: '角色编号'
|
||||
},
|
||||
{
|
||||
field: 'roleName',
|
||||
title: '角色名称'
|
||||
},
|
||||
{
|
||||
field: 'roleKey',
|
||||
title: '权限字符'
|
||||
},
|
||||
{
|
||||
field: 'roleSort',
|
||||
title: '显示顺序'
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
if (value == 0) {
|
||||
return '<span class="label label-success">正常</span>';
|
||||
} else if (value == 1) {
|
||||
return '<span class="label label-primary">禁用</span>';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var msg = '<a class="btn btn-warning btn-sm" href="#" title="删除" onclick="remove(\'' + row.roleId + '\')"><i class="fa fa-remove"></i></a> ';
|
||||
return msg;
|
||||
}
|
||||
}];
|
||||
var url = prefix + "/list";
|
||||
initTable(columns, url);
|
||||
});
|
||||
|
||||
// 单条删除
|
||||
function remove(id) {
|
||||
layer.confirm("确定要删除选中角色吗?",{icon: 3, title:'提示'},function(index){
|
||||
_ajax(prefix + "/remove/" + id, "", "post");
|
||||
})
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
function batchRemove() {
|
||||
var rows = getIdSelections("roleId");
|
||||
if (rows.length == 0) {
|
||||
layer.msg("请选择要删除的数据");
|
||||
return;
|
||||
}
|
||||
layer.confirm("确认要删除选中的" + rows.length + "条数据吗?",{icon: 3, title:'提示'},function(index){
|
||||
_ajax(prefix + '/batchRemove', { "ids": rows }, "post");
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="gray-bg">
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="btn-group hidden-xs" id="tableToolbar" role="group">
|
||||
<button type="button" class="btn btn-outline btn-default" th:onclick="'javascript:batchRemove()'">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
<table class="bootstrap-table" data-mobile-responsive="true"
|
||||
data-sort-name="role_sort" data-sort-order="asc">
|
||||
</table>
|
||||
</div>
|
||||
<div th:include="include :: footer"></div>
|
||||
<script type="text/javascript" src="/ruoyi/system/role/role.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue