From 961fe9a5f159fcd8518d069d0f3a47d38cfb5658 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 20 Aug 2021 21:25:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8F=AF?= =?UTF-8?q?=E6=8B=96=E5=8A=A8=E5=BC=B9=E7=AA=97=E5=AE=BD=E9=AB=98=E6=8C=87?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/directive/dialog/dragHeight.js | 34 +++++++++++++++++++++ ruoyi-ui/src/directive/dialog/dragWidth.js | 30 ++++++++++++++++++ ruoyi-ui/src/directive/index.js | 5 ++- sql/quartz.sql | 6 ++-- 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 ruoyi-ui/src/directive/dialog/dragHeight.js create mode 100644 ruoyi-ui/src/directive/dialog/dragWidth.js diff --git a/ruoyi-ui/src/directive/dialog/dragHeight.js b/ruoyi-ui/src/directive/dialog/dragHeight.js new file mode 100644 index 00000000..db5e1dbc --- /dev/null +++ b/ruoyi-ui/src/directive/dialog/dragHeight.js @@ -0,0 +1,34 @@ +/** +* v-dialogDragWidth 可拖动弹窗高度(右下角) +* Copyright (c) 2019 ruoyi +*/ + +export default { + bind(el) { + const dragDom = el.querySelector('.el-dialog'); + const lineEl = document.createElement('div'); + lineEl.style = 'width: 6px; background: inherit; height: 10px; position: absolute; right: 0; bottom: 0; margin: auto; z-index: 1; cursor: nwse-resize;'; + lineEl.addEventListener('mousedown', + function(e) { + // 鼠标按下,计算当前元素距离可视区的距离 + const disX = e.clientX - el.offsetLeft; + const disY = e.clientY - el.offsetTop; + // 当前宽度 高度 + const curWidth = dragDom.offsetWidth; + const curHeight = dragDom.offsetHeight; + document.onmousemove = function(e) { + e.preventDefault(); // 移动时禁用默认事件 + // 通过事件委托,计算移动的距离 + const xl = e.clientX - disX; + const yl = e.clientY - disY + dragDom.style.width = `${curWidth + xl}px`; + dragDom.style.height = `${curHeight + yl}px`; + }; + document.onmouseup = function(e) { + document.onmousemove = null; + document.onmouseup = null; + }; + }, false); + dragDom.appendChild(lineEl); + } +} \ No newline at end of file diff --git a/ruoyi-ui/src/directive/dialog/dragWidth.js b/ruoyi-ui/src/directive/dialog/dragWidth.js new file mode 100644 index 00000000..e3b5f3f8 --- /dev/null +++ b/ruoyi-ui/src/directive/dialog/dragWidth.js @@ -0,0 +1,30 @@ +/** +* v-dialogDragWidth 可拖动弹窗宽度(右侧边) +* Copyright (c) 2019 ruoyi +*/ + +export default { + bind(el) { + const dragDom = el.querySelector('.el-dialog'); + const lineEl = document.createElement('div'); + lineEl.style = 'width: 5px; background: inherit; height: 80%; position: absolute; right: 0; top: 0; bottom: 0; margin: auto; z-index: 1; cursor: w-resize;'; + lineEl.addEventListener('mousedown', + function (e) { + // 鼠标按下,计算当前元素距离可视区的距离 + const disX = e.clientX - el.offsetLeft; + // 当前宽度 + const curWidth = dragDom.offsetWidth; + document.onmousemove = function (e) { + e.preventDefault(); // 移动时禁用默认事件 + // 通过事件委托,计算移动的距离 + const l = e.clientX - disX; + dragDom.style.width = `${curWidth + l}px`; + }; + document.onmouseup = function (e) { + document.onmousemove = null; + document.onmouseup = null; + }; + }, false); + dragDom.appendChild(lineEl); + } +} \ No newline at end of file diff --git a/ruoyi-ui/src/directive/index.js b/ruoyi-ui/src/directive/index.js index 550109b4..5801640a 100644 --- a/ruoyi-ui/src/directive/index.js +++ b/ruoyi-ui/src/directive/index.js @@ -1,17 +1,20 @@ import hasRole from './permission/hasRole' import hasPermi from './permission/hasPermi' import dialogDrag from './dialog/drag' +import dialogDragWidth from './dialog/dragWidth' +import dialogDragHeight from './dialog/dragHeight' const install = function(Vue) { Vue.directive('hasRole', hasRole) Vue.directive('hasPermi', hasPermi) Vue.directive('dialogDrag', dialogDrag) + Vue.directive('dialogDragWidth', dialogDragWidth) + Vue.directive('dialogDragHeight', dialogDragHeight) } if (window.Vue) { window['hasRole'] = hasRole window['hasPermi'] = hasPermi - window['dialogDrag'] = dialogDrag Vue.use(install); // eslint-disable-line } diff --git a/sql/quartz.sql b/sql/quartz.sql index 58106e12..5f99bfb5 100644 --- a/sql/quartz.sql +++ b/sql/quartz.sql @@ -56,7 +56,7 @@ create table QRTZ_TRIGGERS ( -- ---------------------------- create table QRTZ_SIMPLE_TRIGGERS ( sched_name varchar(120) not null comment '调度名称', - trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_ name的外键', + trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键', trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', repeat_count bigint(7) not null comment '重复的次数统计', repeat_interval bigint(12) not null comment '重复的间隔时间', @@ -134,7 +134,7 @@ create table QRTZ_FIRED_TRIGGERS ( -- ---------------------------- create table QRTZ_SCHEDULER_STATE ( sched_name varchar(120) not null comment '调度名称', - instance_name varchar(200) not null comment '之前配置文件中org.quartz.scheduler.instanceId配置的名字,就会写入该字段', + instance_name varchar(200) not null comment '实例名称', last_checkin_time bigint(13) not null comment '上次检查时间', checkin_interval bigint(13) not null comment '检查间隔时间', primary key (sched_name, instance_name) @@ -154,7 +154,7 @@ create table QRTZ_LOCKS ( -- ---------------------------- create table QRTZ_SIMPROP_TRIGGERS ( sched_name varchar(120) not null comment '调度名称', - trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_ name的外键', + trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键', trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', str_prop_1 varchar(512) null comment 'String类型的trigger的第一个参数', str_prop_2 varchar(512) null comment 'String类型的trigger的第二个参数', From 3f8fd0a0f8edd90dce0349cf4c9c975905f1ab2d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 24 Aug 2021 11:19:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=AF=B9=E6=A3=80=E6=9F=A5=E5=BC=82=E5=B8=B8=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/job/service/SysJobServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/service/SysJobServiceImpl.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/service/SysJobServiceImpl.java index 4699b3dd..3ac34626 100644 --- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/service/SysJobServiceImpl.java +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/service/SysJobServiceImpl.java @@ -74,7 +74,7 @@ public class SysJobServiceImpl implements ISysJobService * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int pauseJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); @@ -94,7 +94,7 @@ public class SysJobServiceImpl implements ISysJobService * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int resumeJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); @@ -114,7 +114,7 @@ public class SysJobServiceImpl implements ISysJobService * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int deleteJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); @@ -134,7 +134,7 @@ public class SysJobServiceImpl implements ISysJobService * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public void deleteJobByIds(Long[] jobIds) throws SchedulerException { for (Long jobId : jobIds) @@ -150,7 +150,7 @@ public class SysJobServiceImpl implements ISysJobService * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int changeStatus(SysJob job) throws SchedulerException { int rows = 0; @@ -172,7 +172,7 @@ public class SysJobServiceImpl implements ISysJobService * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public void run(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); @@ -190,7 +190,7 @@ public class SysJobServiceImpl implements ISysJobService * @param job 调度信息 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int insertJob(SysJob job) throws SchedulerException, TaskException { job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); @@ -208,7 +208,7 @@ public class SysJobServiceImpl implements ISysJobService * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int updateJob(SysJob job) throws SchedulerException, TaskException { SysJob properties = selectJobById(job.getJobId()); From 67df97d5a7094ae512addd075768ee31b875eaac Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 24 Aug 2021 16:24:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E7=94=A8=E6=88=B7=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/SysDeptController.java | 1 + .../system/controller/SysRoleController.java | 1 + .../system/controller/SysUserController.java | 1 + .../ruoyi/system/service/ISysDeptService.java | 7 ++++++ .../ruoyi/system/service/ISysRoleService.java | 7 ++++++ .../ruoyi/system/service/ISysUserService.java | 7 ++++++ .../service/impl/SysDeptServiceImpl.java | 23 +++++++++++++++++++ .../service/impl/SysRoleServiceImpl.java | 22 ++++++++++++++++++ .../service/impl/SysUserServiceImpl.java | 21 +++++++++++++++++ .../resources/mapper/system/SysDeptMapper.xml | 7 ++++-- .../resources/mapper/system/SysRoleMapper.xml | 3 +++ .../resources/mapper/system/SysUserMapper.xml | 3 +++ 12 files changed, 101 insertions(+), 2 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java index 45a277b7..8b6a564f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java @@ -75,6 +75,7 @@ public class SysDeptController extends BaseController @GetMapping(value = "/{deptId}") public AjaxResult getInfo(@PathVariable Long deptId) { + deptService.checkDeptDataScope(deptId); return AjaxResult.success(deptService.selectDeptById(deptId)); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java index 83017241..3c75107c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java @@ -69,6 +69,7 @@ public class SysRoleController extends BaseController @GetMapping(value = "/{roleId}") public AjaxResult getInfo(@PathVariable Long roleId) { + roleService.checkRoleDataScope(roleId); return AjaxResult.success(roleService.selectRoleById(roleId)); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index ce736109..753b5ab7 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -172,6 +172,7 @@ public class SysUserController extends BaseController @GetMapping(value = { "/", "/{userId}" }) public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { + userService.checkUserDataScope(userId); AjaxResult ajax = AjaxResult.success(); List roles = roleService.selectRoleAll(); ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index ee644106..ebdfbe4b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -84,6 +84,13 @@ public interface ISysDeptService */ public String checkDeptNameUnique(SysDept dept); + /** + * 校验部门是否有数据权限 + * + * @param deptId 部门id + */ + public void checkDeptDataScope(Long deptId); + /** * 新增保存部门信息 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java index 2b5a83f2..610420de 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -82,6 +82,13 @@ public interface ISysRoleService */ public void checkRoleAllowed(SysRole role); + /** + * 校验角色是否有数据权限 + * + * @param roleId 角色id + */ + public void checkRoleDataScope(Long roleId); + /** * 通过角色ID查询角色使用数量 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index fcb7c830..f8962681 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -97,6 +97,13 @@ public interface ISysUserService */ public void checkUserAllowed(SysUser user); + /** + * 校验用户是否有数据权限 + * + * @param userId 用户id + */ + public void checkUserDataScope(Long userId); + /** * 新增用户信息 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 6d89724a..4a726f2e 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -9,10 +9,13 @@ import org.springframework.stereotype.Service; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.core.utils.SecurityUtils; +import com.ruoyi.common.core.utils.SpringUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.system.api.domain.SysDept; import com.ruoyi.system.api.domain.SysRole; +import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.domain.vo.TreeSelect; import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysRoleMapper; @@ -171,6 +174,26 @@ public class SysDeptServiceImpl implements ISysDeptService return UserConstants.UNIQUE; } + /** + * 校验部门是否有数据权限 + * + * @param deptId 部门id + */ + @Override + public void checkDeptDataScope(Long deptId) + { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) + { + SysDept dept = new SysDept(); + dept.setDeptId(deptId); + List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + if (StringUtils.isEmpty(depts)) + { + throw new ServiceException("没有权限访问部门数据!"); + } + } + } + /** * 新增保存部门信息 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 16fcb085..840b3d0b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -10,10 +10,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.core.utils.SecurityUtils; import com.ruoyi.common.core.utils.SpringUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.system.api.domain.SysRole; +import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.domain.SysRoleDept; import com.ruoyi.system.domain.SysRoleMenu; import com.ruoyi.system.domain.SysUserRole; @@ -187,6 +189,26 @@ public class SysRoleServiceImpl implements ISysRoleService } } + /** + * 校验角色是否有数据权限 + * + * @param roleId 角色id + */ + @Override + public void checkRoleDataScope(Long roleId) + { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) + { + SysRole role = new SysRole(); + role.setRoleId(roleId); + List roles = SpringUtils.getAopProxy(this).selectRoleList(role); + if (StringUtils.isEmpty(roles)) + { + throw new ServiceException("没有权限访问角色数据!"); + } + } + } + /** * 通过角色ID查询角色使用数量 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 06860e0b..b83d6859 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.SecurityUtils; +import com.ruoyi.common.core.utils.SpringUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.system.api.domain.SysRole; @@ -227,6 +228,26 @@ public class SysUserServiceImpl implements ISysUserService } } + /** + * 校验用户是否有数据权限 + * + * @param userId 用户id + */ + @Override + public void checkUserDataScope(Long userId) + { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) + { + SysUser user = new SysUser(); + user.setUserId(userId); + List users = SpringUtils.getAopProxy(this).selectUserList(user); + if (StringUtils.isEmpty(users)) + { + throw new ServiceException("没有权限访问用户数据!"); + } + } + } + /** * 新增保存用户信息 * diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index e3930a98..3f40fb1b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -30,6 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select count(1) from sys_dept - where del_flag = '0' and parent_id = #{deptId} + where del_flag = '0' and parent_id = #{deptId} limit 1 - select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index 7e3ab1ec..c26cfe5a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -33,6 +33,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"