前端调用后台接口
/** 查询角色列表 */
getList() {
this.loading = true;
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(
response => {
this.roleList = response.rows;
this.total = response.total;
this.loading = false;
}
);
}
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list")
public TableDataInfo list(SysRole role)
{
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
}
List<SysRole> list = roleService.selectRoleList(role);
/**
* 根据条件分页查询角色数据
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
@DataScope(deptAlias = "d")
public List<SysRole> selectRoleList(SysRole role)
{
return roleMapper.selectRoleList(role);
}
执行sql:
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope,
r.status, r.del_flag, r.create_time, r.remark
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
left join sys_dept d on u.dept_id = d.dept_id
where r.del_flag = '0'
<if test="roleName != null and roleName != ''">
AND r.role_name like concat('%', #{roleName}, '%')
</if>
<if test="status != null and status != ''">
AND r.status = #{status}
</if>
<if test="roleKey != null and roleKey != ''">
AND r.role_key like concat('%', #{roleKey}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
</if>
<!-- 数据范围过滤 -->
${dataScope}
查询菜单树结构
[
{
"id": 1,
"label": "系统管理",
"children": [
{
"id": 100,
"label": "用户管理",
"children": [
{
"id": 1001,
"label": "用户查询"
},
{
"id": 1002,
"label": "用户新增"
},
{
"id": 1003,
"label": "用户修改"
},
{
"id": 1004,
"label": "用户删除"
},
{
"id": 1005,
"label": "用户导出"
},
{
"id": 1006,
"label": "用户导入"
},
{
"id": 1007,
"label": "重置密码"
}
]
},
{
"id": 101,
"label": "角色管理",
"children": [
{
"id": 1008,
"label": "角色查询"
},
{
"id": 1009,
"label": "角色新增"
},
{
"id": 1010,
"label": "角色修改"
},
{
"id": 1011,
"label": "角色删除"
},
{
"id": 1012,
"label": "角色导出"
}
]
},
{
"id": 102,
"label": "菜单管理",
"children": [
{
"id": 1013,
"label": "菜单查询"
},
{
"id": 1014,
"label": "菜单新增"
},
{
"id": 1015,
"label": "菜单修改"
},
{
"id": 1016,
"label": "菜单删除"
}
]
},
{
"id": 103,
"label": "部门管理",
"children": [
{
"id": 1017,
"label": "部门查询"
},
{
"id": 1018,
"label": "部门新增"
},
{
"id": 1019,
"label": "部门修改"
},
{
"id": 1020,
"label": "部门删除"
}
]
},
{
"id": 104,
"label": "岗位管理",
"children": [
{
"id": 1021,
"label": "岗位查询"
},
{
"id": 1022,
"label": "岗位新增"
},
{
"id": 1023,
"label": "岗位修改"
},
{
"id": 1024,
"label": "岗位删除"
},
{
"id": 1025,
"label": "岗位导出"
}
]
},
{
"id": 105,
"label": "字典管理",
"children": [
{
"id": 1026,
"label": "字典查询"
},
{
"id": 1027,
"label": "字典新增"
},
{
"id": 1028,
"label": "字典修改"
},
{
"id": 1029,
"label": "字典删除"
},
{
"id": 1030,
"label": "字典导出"
}
]
},
{
"id": 106,
"label": "参数设置",
"children": [
{
"id": 1031,
"label": "参数查询"
},
{
"id": 1032,
"label": "参数新增"
},
{
"id": 1033,
"label": "参数修改"
},
{
"id": 1034,
"label": "参数删除"
},
{
"id": 1035,
"label": "参数导出"
}
]
},
{
"id": 107,
"label": "通知公告",
"children": [
{
"id": 1036,
"label": "公告查询"
},
{
"id": 1037,
"label": "公告新增"
},
{
"id": 1038,
"label": "公告修改"
},
{
"id": 1039,
"label": "公告删除"
}
]
},
{
"id": 108,
"label": "日志管理",
"children": [
{
"id": 500,
"label": "操作日志",
"children": [
{
"id": 1040,
"label": "操作查询"
},
{
"id": 1041,
"label": "操作删除"
},
{
"id": 1042,
"label": "日志导出"
}
]
},
{
"id": 501,
"label": "登录日志",
"children": [
{
"id": 1043,
"label": "登录查询"
},
{
"id": 1044,
"label": "登录删除"
},
{
"id": 1045,
"label": "日志导出"
}
]
}
]
}
]
},
{
"id": 2,
"label": "系统监控",
"children": [
{
"id": 109,
"label": "在线用户",
"children": [
{
"id": 1046,
"label": "在线查询"
},
{
"id": 1047,
"label": "批量强退"
},
{
"id": 1048,
"label": "单条强退"
}
]
},
{
"id": 110,
"label": "定时任务",
"children": [
{
"id": 1049,
"label": "任务查询"
},
{
"id": 1050,
"label": "任务新增"
},
{
"id": 1051,
"label": "任务修改"
},
{
"id": 1052,
"label": "任务删除"
},
{
"id": 1053,
"label": "状态修改"
},
{
"id": 1054,
"label": "任务导出"
}
]
},
{
"id": 111,
"label": "数据监控"
},
{
"id": 112,
"label": "服务监控"
}
]
},
{
"id": 3,
"label": "系统工具",
"children": [
{
"id": 113,
"label": "表单构建"
},
{
"id": 114,
"label": "代码生成",
"children": [
{
"id": 1055,
"label": "生成查询"
},
{
"id": 1056,
"label": "生成修改"
},
{
"id": 1058,
"label": "导入代码"
},
{
"id": 1057,
"label": "生成删除"
},
{
"id": 1059,
"label": "预览代码"
},
{
"id": 1060,
"label": "生成代码"
}
]
},
{
"id": 115,
"label": "系统接口"
}
]
},
{
"id": 4,
"label": "若依官网"
}
]
查询部门树结构
[
{
"id": 100,
"label": "若依科技",
"children": [
{
"id": 101,
"label": "深圳总公司",
"children": [
{
"id": 103,
"label": "研发部门"
},
{
"id": 104,
"label": "市场部门"
},
{
"id": 105,
"label": "测试部门"
},
{
"id": 106,
"label": "财务部门"
},
{
"id": 107,
"label": "运维部门"
}
]
},
{
"id": 102,
"label": "长沙分公司",
"children": [
{
"id": 108,
"label": "市场部门"
},
{
"id": 109,
"label": "财务部门"
}
]
}
]
}
]
获取字典
this.getDicts("sys_normal_disable").then(response => {
this.statusOptions = response.data;
console.log("getDicts: ", JSON.stringify(response.data))
});
/**
* 根据字典类型查询字典数据信息
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/dictType/{dictType}")
public AjaxResult dictType(@PathVariable String dictType)
{
return AjaxResult.success(dictDataService.selectDictDataByType(dictType));
}
[
{
"searchValue": null,
"createBy": "admin",
"createTime": "2018-03-16 03:33:00",
"updateBy": null,
"updateTime": null,
"remark": "正常状态",
"dataScope": null,
"dictCode": 6,
"dictSort": 1,
"dictLabel": "正常",
"dictValue": "0",
"dictType": "sys_normal_disable",
"cssClass": "",
"listClass": "primary",
"isDefault": "Y",
"status": "0",
"default": true
},
{
"searchValue": null,
"createBy": "admin",
"createTime": "2018-03-16 03:33:00",
"updateBy": null,
"updateTime": null,
"remark": "停用状态",
"dataScope": null,
"dictCode": 7,
"dictSort": 2,
"dictLabel": "停用",
"dictValue": "1",
"dictType": "sys_normal_disable",
"cssClass": "",
"listClass": "danger",
"isDefault": "N",
"status": "0",
"default": false
}
]
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@Override
public List<SysDictData> selectDictDataByType(String dictType)
{
return dictDataMapper.selectDictDataByType(dictType);
}
执行sql:
select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark
from sys_dict_data
where status = '0' and dict_type = #{dictType} order by dict_sort asc