From 41ac1994a07b5ce9dda065e2428c50de9303407a Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 23 Mar 2020 09:02:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=204.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 +- ruoyi-admin/pom.xml | 2 +- .../system/SysRegisterController.java | 46 ++++++++ .../controller/system/SysUserController.java | 28 +++++ .../src/main/resources/application.yml | 2 +- .../resources/static/i18n/messages.properties | 1 + .../main/resources/static/ruoyi/css/ry-ui.css | 2 +- .../src/main/resources/static/ruoyi/index.js | 4 +- .../main/resources/static/ruoyi/js/ry-ui.js | 1 - .../src/main/resources/static/ruoyi/login.js | 2 +- .../main/resources/static/ruoyi/register.js | 82 ++++++++++++++ .../templates/demo/form/summernote.html | 4 +- .../templates/demo/table/search.html | 16 +-- .../resources/templates/error/unauth.html | 2 +- .../src/main/resources/templates/include.html | 7 +- .../src/main/resources/templates/index.html | 13 +-- .../src/main/resources/templates/login.html | 13 +-- .../src/main/resources/templates/main.html | 73 ++++++++++++- .../templates/monitor/operlog/operlog.html | 3 +- .../main/resources/templates/register.html | 83 ++++++++++++++ .../src/main/resources/templates/skin.html | 2 +- .../templates/system/dict/type/type.html | 5 +- .../templates/system/role/authUser.html | 2 +- .../resources/templates/system/role/role.html | 2 +- .../templates/system/user/authRole.html | 103 ++++++++++++++++++ .../system/user/profile/profile.html | 2 +- .../resources/templates/system/user/user.html | 11 +- ruoyi-common/pom.xml | 2 +- .../com/ruoyi/common/constant/Constants.java | 5 + .../ruoyi/common/constant/ShiroConstants.java | 8 +- .../ruoyi/common/constant/UserConstants.java | 6 + .../common/utils/file/FileUploadUtils.java | 2 +- ruoyi-framework/pom.xml | 2 +- .../framework/aspectj/DataScopeAspect.java | 3 +- .../ruoyi/framework/config/ShiroConfig.java | 2 + .../interceptor/RepeatSubmitInterceptor.java | 2 +- .../manager/factory/AsyncFactory.java | 3 +- .../shiro/service/SysPasswordService.java | 2 +- .../shiro/service/SysRegisterService.java | 80 ++++++++++++++ .../shiro/session/OnlineSessionDAO.java | 4 +- .../framework/web/service/ConfigService.java | 2 +- ruoyi-generator/pom.xml | 2 +- .../main/resources/vm/html/list-tree.html.vm | 8 +- .../src/main/resources/vm/html/list.html.vm | 12 +- ruoyi-quartz/pom.xml | 2 +- .../controller/SysJobLogController.java | 14 ++- .../service/impl/SysJobServiceImpl.java | 5 +- .../com/ruoyi/quartz/util/JobInvokeUtil.java | 2 +- .../resources/templates/monitor/job/job.html | 12 +- .../templates/monitor/job/jobLog.html | 5 +- ruoyi-system/pom.xml | 2 +- .../java/com/ruoyi/system/domain/SysRole.java | 1 + .../java/com/ruoyi/system/domain/SysUser.java | 15 +++ .../system/mapper/SysUserRoleMapper.java | 10 +- .../ruoyi/system/service/ISysUserService.java | 25 +++++ .../service/impl/SysUserServiceImpl.java | 50 +++++++-- .../resources/mapper/system/SysMenuMapper.xml | 7 +- .../resources/mapper/system/SysUserMapper.xml | 14 ++- .../mapper/system/SysUserRoleMapper.xml | 8 +- sql/{ry_20191122.sql => ry_20200323.sql} | 34 +++--- 60 files changed, 745 insertions(+), 121 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java create mode 100644 ruoyi-admin/src/main/resources/static/ruoyi/register.js create mode 100644 ruoyi-admin/src/main/resources/templates/register.html create mode 100644 ruoyi-admin/src/main/resources/templates/system/user/authRole.html create mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java rename sql/{ry_20191122.sql => ry_20200323.sql} (96%) diff --git a/pom.xml b/pom.xml index 1215ce5d..579f5dde 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ com.ruoyi ruoyi - 4.1.0 + 4.2.0 ruoyi http://www.ruoyi.vip 若依管理系统 - 4.1.0 + 4.2.0 UTF-8 UTF-8 1.8 diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index a4d56dbf..7a8f179b 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 4.1.0 + 4.2.0 4.0.0 jar diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java new file mode 100644 index 00000000..a0f0a484 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java @@ -0,0 +1,46 @@ +package com.ruoyi.web.controller.system; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.framework.shiro.service.SysRegisterService; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysConfigService; + +/** + * 注册验证 + * + * @author ruoyi + */ +@Controller +public class SysRegisterController extends BaseController +{ + @Autowired + private SysRegisterService registerService; + + @Autowired + private ISysConfigService configService; + + @GetMapping("/register") + public String register() + { + return "register"; + } + + @PostMapping("/register") + @ResponseBody + public AjaxResult ajaxRegister(SysUser user) + { + if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) + { + return error("当前系统没有开启注册功能!"); + } + String msg = registerService.register(user); + return StringUtils.isEmpty(msg) ? success() : error(msg); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 76fc16b8..14893723 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -22,6 +22,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.shiro.service.SysPasswordService; import com.ruoyi.framework.util.ShiroUtils; import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; @@ -200,6 +201,33 @@ public class SysUserController extends BaseController return error(); } + /** + * 进入授权角色页 + */ + @GetMapping("/authRole/{userId}") + public String authRole(@PathVariable("userId") Long userId, ModelMap mmap) + { + SysUser user = userService.selectUserById(userId); + // 获取用户所属的角色列表 + List userRoles = userService.selectUserRoleByUserId(userId); + mmap.put("user", user); + mmap.put("userRoles", userRoles); + return prefix + "/authRole"; + } + + /** + * 用户授权角色 + */ + @RequiresPermissions("system:user:add") + @Log(title = "用户管理", businessType = BusinessType.GRANT) + @PostMapping("/authRole/insertAuthRole") + @ResponseBody + public AjaxResult insertAuthRole(Long userId, Long[] roleIds) + { + userService.insertUserAuth(userId, roleIds); + return success(); + } + @RequiresPermissions("system:user:remove") @Log(title = "用户管理", businessType = BusinessType.DELETE) @PostMapping("/remove") diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 26361c6f..1936b745 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -3,7 +3,7 @@ ruoyi: # 名称 name: RuoYi # 版本 - version: 4.1.0 + version: 4.2.0 # 版权年份 copyrightYear: 2019 # 实例演示开关 diff --git a/ruoyi-admin/src/main/resources/static/i18n/messages.properties b/ruoyi-admin/src/main/resources/static/i18n/messages.properties index ef2a3e4b..5e03cdf0 100644 --- a/ruoyi-admin/src/main/resources/static/i18n/messages.properties +++ b/ruoyi-admin/src/main/resources/static/i18n/messages.properties @@ -18,6 +18,7 @@ user.password.not.valid=* 5-50个字符 user.email.not.valid=邮箱格式错误 user.mobile.phone.number.not.valid=手机号格式错误 user.login.success=登录成功 +user.register.success=注册成功 user.notfound=请重新登录 user.forcelogout=管理员强制退出,请重新登录 user.unknown.error=未知错误,请重新登录 diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css b/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css index 845cac46..7e3b06c7 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css +++ b/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css @@ -644,7 +644,7 @@ label { margin: 5px 15px 5px 0px; } -.select-list li p, .select-list li label{ +.select-list li p, .select-list li label:not(.radio-box){ float: left; width: 65px; margin: 5px 5px 5px 0px; diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/index.js b/ruoyi-admin/src/main/resources/static/ruoyi/index.js index 2ae799da..6ebd190e 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/index.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/index.js @@ -13,10 +13,10 @@ $(function() { // MetsiMenu $('#side-menu').metisMenu(); - //固定菜单栏 + // 固定菜单栏 $(function() { $('.sidebar-collapse').slimScroll({ - height: '100%', + height: '96%', railOpacity: 0.9, alwaysVisible: false }); diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index ed1376ca..fd7ca161 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -359,7 +359,6 @@ var table = { } else{ $("#" + table.options.id).bootstrapTable('refresh', params); } - data = {}; }, // 导出数据 exportExcel: function(formId) { diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/login.js b/ruoyi-admin/src/main/resources/static/ruoyi/login.js index f633f51d..4acf3381 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/login.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/login.js @@ -26,7 +26,7 @@ function login() { data: { "username": username, "password": password, - "validateCode" : validateCode, + "validateCode": validateCode, "rememberMe": rememberMe }, success: function(r) { diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/register.js b/ruoyi-admin/src/main/resources/static/ruoyi/register.js new file mode 100644 index 00000000..56c7c55a --- /dev/null +++ b/ruoyi-admin/src/main/resources/static/ruoyi/register.js @@ -0,0 +1,82 @@ + +$(function() { + validateRule(); + $('.imgcode').click(function() { + var url = ctx + "captcha/captchaImage?type=" + captchaType + "&s=" + Math.random(); + $(".imgcode").attr("src", url); + }); +}); + +$.validator.setDefaults({ + submitHandler: function() { + register(); + } +}); + +function register() { + $.modal.loading($("#btnSubmit").data("loading")); + var username = $.common.trim($("input[name='username']").val()); + var password = $.common.trim($("input[name='password']").val()); + var validateCode = $("input[name='validateCode']").val(); + $.ajax({ + type: "post", + url: ctx + "register", + data: { + "loginName": username, + "password": password, + "validateCode": validateCode + }, + success: function(r) { + if (r.code == 0) { + layer.alert("恭喜你,您的账号 " + username + " 注册成功!", { + icon: 1, + title: "系统提示" + }, + function(index) { + //关闭弹窗 + layer.close(index); + location.href = ctx + 'login'; + }); + } else { + $.modal.closeLoading(); + $('.imgcode').click(); + $(".code").val(""); + $.modal.msg(r.msg); + } + } + }); +} + +function validateRule() { + var icon = " "; + $("#registerForm").validate({ + rules: { + username: { + required: true, + minlength: 2 + }, + password: { + required: true, + minlength: 5 + }, + confirmPassword: { + required: true, + equalTo: "[name='password']" + } + }, + messages: { + username: { + required: icon + "请输入您的用户名", + minlength: icon + "用户名不能小于2个字符" + }, + password: { + required: icon + "请输入您的密码", + minlength: icon + "密码不能小于5个字符", + }, + confirmPassword: { + required: icon + "请再次输入您的密码", + equalTo: icon + "两次密码输入不一致" + } + } + }) +} diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/summernote.html b/ruoyi-admin/src/main/resources/templates/demo/form/summernote.html index 1222d98c..7bd0724c 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/summernote.html +++ b/ruoyi-admin/src/main/resources/templates/demo/form/summernote.html @@ -17,7 +17,7 @@

若依后台管理系统

ruoyi是一个完全响应式,基于Bootstrap3.3.6最新版本开发的扁平化主题,她采用了主流的左右两栏式布局,使用了Html5+CSS3等现代技术,她提供了诸多的强大的可以重新组合的UI组件,并集成了最新的jQuery版本(v2.1.1),当然,也集成了很多功能强大,用途广泛的就jQuery插件,她可以用于所有的Web应用程序,如网站管理后台网站会员中心CMSCRMOA等等,当然,您也可以对她进行深度定制,以做出更强系统。

- 当前版本:v4.1.0 + 当前版本:v4.2.0

免费开源 @@ -56,7 +56,7 @@

你好,若依

H+是一个完全响应式,基于Bootstrap3.3.6最新版本开发的扁平化主题,她采用了主流的左右两栏式布局,使用了Html5+CSS3等现代技术,她提供了诸多的强大的可以重新组合的UI组件,并集成了最新的jQuery版本(v2.1.1),当然,也集成了很多功能强大,用途广泛的就jQuery插件,她可以用于所有的Web应用程序,如网站管理后台网站会员中心CMSCRMOA等等,当然,您也可以对她进行深度定制,以做出更强系统。

- 当前版本:v4.1.0 + 当前版本:v4.2.0

开源免费 diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/search.html b/ruoyi-admin/src/main/resources/templates/demo/table/search.html index efd573de..0ddb6657 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/search.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/search.html @@ -97,19 +97,19 @@

  • -

    商户编号:

    +
  • -

    订单号:

    +
  • -

    日期:

    +
  • -

    状态:

    +
  • -

    供货商通道:

    +
  • -

    来源:

    +
  • -

    运营商:

    +
  • -

    回调时间:

    + - diff --git a/ruoyi-admin/src/main/resources/templates/error/unauth.html b/ruoyi-admin/src/main/resources/templates/error/unauth.html index fd5f03cf..1704707d 100644 --- a/ruoyi-admin/src/main/resources/templates/error/unauth.html +++ b/ruoyi-admin/src/main/resources/templates/error/unauth.html @@ -15,7 +15,7 @@
    对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面 - 返回主页 + 返回主页
@@ -39,10 +41,9 @@ - - + + - diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/ruoyi-admin/src/main/resources/templates/index.html index 64b70b6f..fb2280a9 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/ruoyi-admin/src/main/resources/templates/index.html @@ -5,9 +5,8 @@ 若依系统首页 - + + @@ -15,7 +14,7 @@ - +
@@ -187,7 +186,7 @@
-
+

登录:

你若不离不弃,我必生死相依

- +
@@ -81,7 +78,7 @@ - + diff --git a/ruoyi-admin/src/main/resources/templates/main.html b/ruoyi-admin/src/main/resources/templates/main.html index e38e6389..48b83408 100644 --- a/ruoyi-admin/src/main/resources/templates/main.html +++ b/ruoyi-admin/src/main/resources/templates/main.html @@ -96,13 +96,78 @@
+
+
+
+ v4.2.02020.03.23 +
+
+
+
+
    +
  1. 用户管理添加分配角色页面
  2. +
  3. 定时任务添加调度日志按钮
  4. +
  5. 新增是否开启用户注册功能
  6. +
  7. 新增页面滚动显示返回顶部按钮
  8. +
  9. 用户&角色&任务添加更多操作按钮
  10. +
  11. iframe框架页会话过期弹出超时提示
  12. +
  13. 移动端登录不显示左侧菜单
  14. +
  15. 侧边栏添加一套深蓝色主题
  16. +
  17. 首页logo固定,不随菜单滚动
  18. +
  19. 支持mode配置history(表示去掉地址栏的#)
  20. +
  21. 任务分组字典翻译(调度日志详细)
  22. +
  23. 字典管理添加缓存读取
  24. +
  25. 字典数据列表标签显示样式
  26. +
  27. 参数管理支持缓存操作
  28. +
  29. 日期控件清空结束时间设置开始默认值为2099-12-31
  30. +
  31. 表格树添加获取数据后响应回调处理
  32. +
  33. 批量替换表前缀调整
  34. +
  35. 支持表格导入模板的弹窗表单加入其它输入控件
  36. +
  37. 表单重置刷新表格树
  38. +
  39. 新增支持导出数据字段排序
  40. +
  41. 新增表格参数(是否单选checkbox)
  42. +
  43. druid未授权不允许访问
  44. +
  45. 表格树父节点兼容0,'0','',null
  46. +
  47. 表单必填的项添加星号
  48. +
  49. 修复select2不显示校验错误信息
  50. +
  51. 添加自定义HTML过滤器
  52. +
  53. 修复多数据源下开关关闭出现异常问题
  54. +
  55. 修复翻页记住选择项数据问题
  56. +
  57. 用户邮箱长度限制20
  58. +
  59. 修改错误页面返回主页出现嵌套问题
  60. +
  61. 表格浮动提示单双引号转义
  62. +
  63. 支持配置四级菜单
  64. +
  65. 升级shiro到最新版1.4.2 阻止rememberMe漏洞攻击
  66. +
  67. 升级summernote到最新版本v0.8.12
  68. +
  69. 导入Excel根据dateFormat属性格式处理
  70. +
  71. 修复War部署无法正常shutdown,ehcache内存泄漏
  72. +
  73. 修复代码生成短字段无法识别问题
  74. +
  75. 修复serviceImpl模版,修改方法判断日期错误
  76. +
  77. 代码生成模板增加导出功能日志记录
  78. +
  79. 代码生成唯一编号调整为tableId
  80. +
  81. 代码生成查询时忽略大小写
  82. +
  83. 代码生成支持翻页记住选中
  84. +
  85. 代码生成表注释未填写也允许导入
  86. +
  87. Global全局配置类修改为注解,防止多环境配置下读取问题
  88. +
  89. 修复多表格情况下,firstLoad只对第一个表格生效
  90. +
  91. 处理Maven打包出现警告问题
  92. +
  93. 默认主题样式,防止网速慢情况下出现空白
  94. +
  95. 修复文件上传多级目录识别问题
  96. +
  97. 锚链接解码url,防止中文导致页面不能加载问题
  98. +
  99. 修复右键Tab页刷新事件重复请求问题
  100. +
  101. 角色禁用&菜单隐藏不查询权限
  102. +
  103. 其他细节优化
  104. +
+
+
+
v4.1.02019.10.22
-
+
  1. 支持多表格实例操作
  2. @@ -142,7 +207,7 @@
-
+
@@ -203,8 +268,8 @@
  • 其他细节优化
  • -
    -
    +
    +
    diff --git a/ruoyi-admin/src/main/resources/templates/monitor/operlog/operlog.html b/ruoyi-admin/src/main/resources/templates/monitor/operlog/operlog.html index 32585a5f..c1f7e013 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/operlog/operlog.html +++ b/ruoyi-admin/src/main/resources/templates/monitor/operlog/operlog.html @@ -155,8 +155,9 @@ } function resetPre() { - $.form.reset(); + $("#operlog-form")[0].reset(); $("#businessTypes").selectpicker('refresh'); + $.table.search('operlog-form', 'bootstrap-table'); } diff --git a/ruoyi-admin/src/main/resources/templates/register.html b/ruoyi-admin/src/main/resources/templates/register.html new file mode 100644 index 00000000..fca06b98 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/register.html @@ -0,0 +1,83 @@ + + + + + + 注册若依系统 + + + + + + + + + + + + + + +
    +
    +
    + +
    +
    + +

    注册:

    +

    你若不离不弃,我必生死相依

    + + + +
    +
    + +
    +
    + + + +
    +
    +
    + + 使用条款 +
    + + +
    +
    + +
    + + + + + + + + + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/skin.html b/ruoyi-admin/src/main/resources/templates/skin.html index deb19f02..ce775376 100644 --- a/ruoyi-admin/src/main/resources/templates/skin.html +++ b/ruoyi-admin/src/main/resources/templates/skin.html @@ -140,7 +140,7 @@ - + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html b/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html index 4accf3b5..2d3ba719 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html +++ b/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html @@ -27,7 +27,7 @@ 手机号码:

    [[${user.phonenumber}]]

    -
  • +
  • 所属部门:

    [[${user.dept?.deptName}]] / [[${#strings.defaultString(postGroup,'无岗位')}]]

  • diff --git a/ruoyi-admin/src/main/resources/templates/system/user/user.html b/ruoyi-admin/src/main/resources/templates/system/user/user.html index b58ca59f..2c31d51f 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/user.html +++ b/ruoyi-admin/src/main/resources/templates/system/user/user.html @@ -166,7 +166,10 @@ var actions = []; actions.push('编辑 '); actions.push('删除 '); - actions.push('重置'); + var more = []; + more.push("重置密码 "); + more.push("分配角色"); + actions.push('更多操作'); return actions.join(''); } }] @@ -219,6 +222,12 @@ $.modal.open("重置密码", url, '800', '300'); } + /* 用户管理-分配角色 */ + function authRole(userId) { + var url = prefix + '/authRole/' + userId; + $.modal.openTab("用户分配角色", url); + } + /* 用户状态显示 */ function statusTools(row) { if (row.status == 1) { diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 4ad87e34..1b5aac0e 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 4.1.0 + 4.2.0 4.0.0 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index f7627fb2..10b87411 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -31,6 +31,11 @@ public class Constants * 注销 */ public static final String LOGOUT = "Logout"; + + /** + * 注册 + */ + public static final String REGISTER = "Register"; /** * 登录失败 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java index c5027c24..638d29b1 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java @@ -20,22 +20,22 @@ public interface ShiroConstants /** * 消息key */ - public static String MESSAGE = "message"; + public static final String MESSAGE = "message"; /** * 错误key */ - public static String ERROR = "errorMsg"; + public static final String ERROR = "errorMsg"; /** * 编码格式 */ - public static String ENCODING = "UTF-8"; + public static final String ENCODING = "UTF-8"; /** * 当前在线会话 */ - public String ONLINE_SESSION = "online_session"; + public static final String ONLINE_SESSION = "online_session"; /** * 验证码key diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java index a51ba3bf..d768aa62 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java @@ -89,6 +89,12 @@ public class UserConstants public static final int PASSWORD_MIN_LENGTH = 5; public static final int PASSWORD_MAX_LENGTH = 20; + /** + * 用户类型 + */ + public static final String SYSTEM_USER_TYPE = "00"; + public static final String REGISTER_USER_TYPE = "01"; + /** * 手机号码格式限制 */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index 1503e155..2aab832a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -91,7 +91,7 @@ public class FileUploadUtils * * @param baseDir 相对应用的基目录 * @param file 上传的文件 - * @param extension 上传文件类型 + * @param allowedExtension 上传文件类型 * @return 返回上传成功的文件名 * @throws FileSizeLimitExceededException 如果超出最大大小 * @throws FileNameLengthLimitExceededException 文件名太长 diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index 95c415d6..3e24d788 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 4.1.0 + 4.2.0 4.0.0 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index 9fa9b0af..fea0f4c2 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -92,7 +92,8 @@ public class DataScopeAspect * * @param joinPoint 切点 * @param user 用户 - * @param alias 别名 + * @param deptAlias 部门别名 + * @param userAlias 用户别名 */ public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) { diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java index 508ba4f3..25eef613 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java @@ -254,6 +254,8 @@ public class ShiroConfig filterChainDefinitionMap.put("/logout", "logout"); // 不需要拦截的访问 filterChainDefinitionMap.put("/login", "anon,captchaValidate"); + // 注册相关 + filterChainDefinitionMap.put("/register", "anon,captchaValidate"); // 系统权限列表 // filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll()); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java index a84e8ac7..35076b59 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -47,7 +47,7 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter /** * 验证是否重复提交由子类实现具体的防重复提交的规则 * - * @param httpServletRequest + * @param request * @return * @throws Exception */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java index 719c380e..cd2d6811 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java @@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.utils.AddressUtils; import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.framework.shiro.session.OnlineSession; import com.ruoyi.framework.util.LogUtils; @@ -119,7 +120,7 @@ public class AsyncFactory logininfor.setOs(os); logininfor.setMsg(message); // 日志状态 - if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status)) + if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) { logininfor.setStatus(Constants.SUCCESS); } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java index 3ff8f92a..b9b8fadb 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java @@ -80,7 +80,7 @@ public class SysPasswordService public String encryptPassword(String username, String password, String salt) { - return new Md5Hash(username + password + salt).toHex().toString(); + return new Md5Hash(username + password + salt).toHex(); } public void unlock(String loginName){ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java new file mode 100644 index 00000000..97dfd102 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java @@ -0,0 +1,80 @@ +package com.ruoyi.framework.shiro.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysUserService; + +/** + * 注册校验方法 + * + * @author ruoyi + */ +@Component +public class SysRegisterService +{ + @Autowired + private ISysUserService userService; + + @Autowired + private SysPasswordService passwordService; + + /** + * 注册 + */ + public String register(SysUser user) + { + String msg = "", username = user.getLoginName(), password = user.getPassword(); + + if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA))) + { + msg = "验证码错误"; + } + else if (StringUtils.isEmpty(username)) + { + msg = "用户名不能为空"; + } + else if (StringUtils.isEmpty(password)) + { + msg = "用户密码不能为空"; + } + else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH + || password.length() > UserConstants.PASSWORD_MAX_LENGTH) + { + msg = "密码长度必须在5到20个字符之间"; + } + else if (username.length() < UserConstants.USERNAME_MIN_LENGTH + || username.length() > UserConstants.USERNAME_MAX_LENGTH) + { + msg = "账户长度必须在2到20个字符之间"; + } + else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(username))) + { + msg = "保存用户'" + username + "'失败,注册账号已存在"; + } + else + { + user.setSalt(ShiroUtils.randomSalt()); + user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); + boolean regFlag = userService.registerUser(user); + if (!regFlag) + { + msg = "注册失败,请联系系统管理人员"; + } + else + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success"))); + } + } + return msg; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java index 40ff3127..526a54e7 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java @@ -80,12 +80,12 @@ public class OnlineSessionDAO extends EnterpriseCacheSessionDAO boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L; // session 数据变更了 同步 - if (isGuest == false && onlineSession.isAttributeChanged()) + if (!isGuest == false && onlineSession.isAttributeChanged()) { needSync = true; } - if (needSync == false) + if (!needSync) { return; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java index 5ee1b3d8..3b2d0566 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java @@ -18,7 +18,7 @@ public class ConfigService /** * 根据键名查询参数配置信息 * - * @param configName 参数名称 + * @param configKey 参数键名 * @return 参数键值 */ public String getKey(String configKey) diff --git a/ruoyi-generator/pom.xml b/ruoyi-generator/pom.xml index 2c82b1fc..eab5b48c 100644 --- a/ruoyi-generator/pom.xml +++ b/ruoyi-generator/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 4.1.0 + 4.2.0 4.0.0 diff --git a/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm b/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm index 764b868f..71181201 100644 --- a/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/list-tree.html.vm @@ -115,8 +115,8 @@ #if($column.pk) #elseif($column.list && "" != $dictType) { - field : '${javaField}', - title : '${comment}', + field: '${javaField}', + title: '${comment}', align: 'left', formatter: function(value, row, index) { return $.table.selectDictLabel(${javaField}Datas, value); @@ -124,8 +124,8 @@ }, #elseif($column.list && "" != $javaField) { - field : '${javaField}', - title : '${comment}', + field: '${javaField}', + title: '${comment}', align: 'left' }, #end diff --git a/ruoyi-generator/src/main/resources/vm/html/list.html.vm b/ruoyi-generator/src/main/resources/vm/html/list.html.vm index 2d251424..6528a929 100644 --- a/ruoyi-generator/src/main/resources/vm/html/list.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/list.html.vm @@ -111,22 +111,22 @@ #end #if($column.pk) { - field : '${javaField}', - title : '${comment}', + field: '${javaField}', + title: '${comment}', visible: false }, #elseif($column.list && "" != $dictType) { - field : '${javaField}', - title : '${comment}', + field: '${javaField}', + title: '${comment}', formatter: function(value, row, index) { return $.table.selectDictLabel(${javaField}Datas, value); } }, #elseif($column.list && "" != $javaField) { - field : '${javaField}', - title : '${comment}' + field: '${javaField}', + title: '${comment}' }, #end #end diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml index 2185d13f..e5cbf40c 100644 --- a/ruoyi-quartz/pom.xml +++ b/ruoyi-quartz/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 4.1.0 + 4.2.0 4.0.0 diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java index 2c3d8e27..e6d950a9 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java @@ -9,15 +9,19 @@ 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.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJob; import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.service.ISysJobLogService; +import com.ruoyi.quartz.service.ISysJobService; /** * 调度日志操作处理 @@ -30,13 +34,21 @@ public class SysJobLogController extends BaseController { private String prefix = "monitor/job"; + @Autowired + private ISysJobService jobService; + @Autowired private ISysJobLogService jobLogService; @RequiresPermissions("monitor:job:view") @GetMapping() - public String jobLog() + public String jobLog(@RequestParam(value = "jobId", required = false) Long jobId, ModelMap mmap) { + if (StringUtils.isNotNull(jobId)) + { + SysJob job = jobService.selectJobById(jobId); + mmap.put("job", job); + } return prefix + "/jobLog"; } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java index 92acf4d4..3e41606c 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java @@ -34,15 +34,16 @@ public class SysJobServiceImpl implements ISysJobService /** * 项目启动时,初始化定时器 - * 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) + 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) */ @PostConstruct public void init() throws SchedulerException, TaskException { + scheduler.clear(); List jobList = jobMapper.selectJobAll(); for (SysJob job : jobList) { - updateSchedulerJob(job, job.getJobGroup()); + ScheduleUtils.createScheduleJob(scheduler, job); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java index 5519c672..573aa614 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java @@ -65,7 +65,7 @@ public class JobInvokeUtil /** * 校验是否为为class包名 * - * @param str 名称 + * @param invokeTarget 名称 * @return true是 false否 */ public static boolean isValidClassName(String invokeTarget) diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/job.html b/ruoyi-quartz/src/main/resources/templates/monitor/job/job.html index b87076b0..6ace6192 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/job.html +++ b/ruoyi-quartz/src/main/resources/templates/monitor/job/job.html @@ -47,7 +47,7 @@ 导出 - + 日志
    @@ -129,6 +129,7 @@ var more = []; more.push(" 执行一次 "); more.push("任务详细 "); + more.push("调度日志"); actions.push('更多操作'); return actions.join(''); } @@ -168,9 +169,12 @@ } /* 调度日志查询 */ - function jobLog(id) { - var url = ctx + 'monitor/jobLog'; - $.modal.openTab("调度日志", url); + function jobLog(jobId) { + var url = ctx + 'monitor/jobLog'; + if ($.common.isNotEmpty(jobId)) { + url += '?jobId=' + jobId; + } + $.modal.openTab("调度日志", url); } diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/jobLog.html b/ruoyi-quartz/src/main/resources/templates/monitor/job/jobLog.html index b0774471..ee9d8ebe 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/jobLog.html +++ b/ruoyi-quartz/src/main/resources/templates/monitor/job/jobLog.html @@ -12,12 +12,13 @@
    • - 任务名称: + 任务名称:
    • 任务分组:
    • diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 47e579df..492a903a 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 4.1.0 + 4.2.0 4.0.0 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java index bb3f549e..5aa98e13 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java @@ -177,6 +177,7 @@ public class SysRole extends BaseEntity this.deptIds = deptIds; } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("roleId", getRoleId()) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java index 43994ef3..5d4332b3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java @@ -42,6 +42,9 @@ public class SysUser extends BaseEntity @Excel(name = "用户名称") private String userName; + /** 用户类型 */ + private String userType; + /** 用户邮箱 */ @Excel(name = "用户邮箱") private String email; @@ -176,6 +179,16 @@ public class SysUser extends BaseEntity this.userName = userName; } + public String getUserType() + { + return userType; + } + + public void setUserType(String userType) + { + this.userType = userType; + } + @Email(message = "邮箱格式不正确") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") public String getEmail() @@ -330,6 +343,7 @@ public class SysUser extends BaseEntity .append("deptId", getDeptId()) .append("loginName", getLoginName()) .append("userName", getUserName()) + .append("userType", getUserType()) .append("email", getEmail()) .append("phonenumber", getPhonenumber()) .append("sex", getSex()) @@ -346,6 +360,7 @@ public class SysUser extends BaseEntity .append("updateTime", getUpdateTime()) .append("remark", getRemark()) .append("dept", getDept()) + .append("roles", getRoles()) .toString(); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java index 0e2dd826..17fa5c82 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -11,6 +11,14 @@ import com.ruoyi.system.domain.SysUserRole; */ public interface SysUserRoleMapper { + /** + * 通过用户ID查询用户和角色关联 + * + * @param userId 用户ID + * @return 用户和角色关联列表 + */ + public List selectUserRoleByUserId(Long userId); + /** * 通过用户ID删除用户和角色关联 * @@ -42,7 +50,7 @@ public interface SysUserRoleMapper * @return 结果 */ public int batchUserRole(List userRoleList); - + /** * 删除用户和角色关联信息 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 8ab240a1..51c018d7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.domain.SysUserRole; /** * 用户 业务层 @@ -66,6 +67,14 @@ public interface ISysUserService */ public SysUser selectUserById(Long userId); + /** + * 通过用户ID查询用户和角色关联 + * + * @param userId 用户ID + * @return 用户和角色关联列表 + */ + public List selectUserRoleByUserId(Long userId); + /** * 通过用户ID删除用户 * @@ -91,6 +100,14 @@ public interface ISysUserService */ public int insertUser(SysUser user); + /** + * 注册用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public boolean registerUser(SysUser user); + /** * 保存用户信息 * @@ -107,6 +124,14 @@ public interface ISysUserService */ public int updateUserInfo(SysUser user); + /** + * 用户授权角色 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + public void insertUserAuth(Long userId, Long[] roleIds); + /** * 修改用户密码信息 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 29ade157..6c11cc00 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -139,6 +139,17 @@ public class SysUserServiceImpl implements ISysUserService return userMapper.selectUserById(userId); } + /** + * 通过用户ID查询用户和角色关联 + * + * @param userId 用户ID + * @return 用户和角色关联列表 + */ + public List selectUserRoleByUserId(Long userId) + { + return userRoleMapper.selectUserRoleByUserId(userId); + } + /** * 通过用户ID删除用户 * @@ -187,10 +198,22 @@ public class SysUserServiceImpl implements ISysUserService // 新增用户岗位关联 insertUserPost(user); // 新增用户与角色管理 - insertUserRole(user); + insertUserRole(user.getUserId(), user.getRoleIds()); return rows; } + /** + * 注册用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public boolean registerUser(SysUser user) + { + user.setUserType(UserConstants.REGISTER_USER_TYPE); + return userMapper.insertUser(user) > 0; + } + /** * 修改保存用户信息 * @@ -205,7 +228,7 @@ public class SysUserServiceImpl implements ISysUserService // 删除用户与角色关联 userRoleMapper.deleteUserRoleByUserId(userId); // 新增用户与角色管理 - insertUserRole(user); + insertUserRole(user.getUserId(), user.getRoleIds()); // 删除用户与岗位关联 userPostMapper.deleteUserPostByUserId(userId); // 新增用户与岗位管理 @@ -225,6 +248,18 @@ public class SysUserServiceImpl implements ISysUserService return userMapper.updateUser(user); } + /** + * 用户授权角色 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + public void insertUserAuth(Long userId, Long[] roleIds) + { + userRoleMapper.deleteUserRoleByUserId(userId); + insertUserRole(userId, roleIds); + } + /** * 修改用户密码 * @@ -242,17 +277,16 @@ public class SysUserServiceImpl implements ISysUserService * * @param user 用户对象 */ - public void insertUserRole(SysUser user) + public void insertUserRole(Long userId, Long[] roleIds) { - Long[] roles = user.getRoleIds(); - if (StringUtils.isNotNull(roles)) + if (StringUtils.isNotNull(roleIds)) { // 新增用户与角色管理 List list = new ArrayList(); - for (Long roleId : roles) + for (Long roleId : roleIds) { SysUserRole ur = new SysUserRole(); - ur.setUserId(user.getUserId()); + ur.setUserId(userId); ur.setRoleId(roleId); list.add(ur); } @@ -307,7 +341,7 @@ public class SysUserServiceImpl implements ISysUserService } /** - * 校验用户名称是否唯一 + * 校验手机号码是否唯一 * * @param user 用户信息 * @return diff --git a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml index 47f9b837..9a06fde1 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -65,7 +65,8 @@ from sys_menu m left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_user_role ur on rm.role_id = ur.role_id - where ur.user_id = #{userId} + left join sys_role r on r.role_id = ur.role_id + where m.visible = '0' and r.status = '0' and ur.user_id = #{userId} - select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u + select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u left join sys_dept d on u.dept_id = d.dept_id where u.del_flag = '0' @@ -83,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from sys_user where user_id = #{userId} + update sys_user set del_flag = '2' where user_id = #{userId} @@ -166,6 +167,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" dept_id = #{deptId}, login_name = #{loginName}, user_name = #{userName}, + user_type = #{userType}, email = #{email}, phonenumber = #{phonenumber}, sex = #{sex}, @@ -188,6 +190,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" dept_id, login_name, user_name, + user_type, email, avatar, phonenumber, @@ -203,6 +206,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{deptId}, #{loginName}, #{userName}, + #{userType}, #{email}, #{avatar}, #{phonenumber}, diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml index 95e07adb..b091ba75 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml @@ -8,13 +8,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + - delete from sys_user_role where user_id=#{userId} + delete from sys_user_role where user_id = #{userId} diff --git a/sql/ry_20191122.sql b/sql/ry_20200323.sql similarity index 96% rename from sql/ry_20191122.sql rename to sql/ry_20200323.sql index 4ce80d68..d61ef392 100644 --- a/sql/ry_20191122.sql +++ b/sql/ry_20200323.sql @@ -43,8 +43,8 @@ create table sys_user ( user_id bigint(20) not null auto_increment comment '用户ID', dept_id bigint(20) default null comment '部门ID', login_name varchar(30) not null comment '登录账号', - user_name varchar(30) not null comment '用户昵称', - user_type varchar(2) default '00' comment '用户类型(00系统用户)', + user_name varchar(30) default '' comment '用户昵称', + user_type varchar(2) default '00' comment '用户类型(00系统用户 01注册用户)', email varchar(50) default '' comment '用户邮箱', phonenumber varchar(11) default '' comment '手机号码', sex char(1) default '0' comment '用户性别(0男 1女 2未知)', @@ -497,17 +497,18 @@ insert into sys_dict_data values(14, 1, '通知', '1', 'sys_notice_ty insert into sys_dict_data values(15, 2, '公告', '2', 'sys_notice_type', '', 'success', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '公告'); insert into sys_dict_data values(16, 1, '正常', '0', 'sys_notice_status', '', 'primary', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态'); insert into sys_dict_data values(17, 2, '关闭', '1', 'sys_notice_status', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '关闭状态'); -insert into sys_dict_data values(18, 1, '新增', '1', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '新增操作'); -insert into sys_dict_data values(19, 2, '修改', '2', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '修改操作'); -insert into sys_dict_data values(20, 3, '删除', '3', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '删除操作'); -insert into sys_dict_data values(21, 4, '授权', '4', 'sys_oper_type', '', 'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '授权操作'); -insert into sys_dict_data values(22, 5, '导出', '5', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '导出操作'); -insert into sys_dict_data values(23, 6, '导入', '6', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '导入操作'); -insert into sys_dict_data values(24, 7, '强退', '7', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '强退操作'); -insert into sys_dict_data values(25, 8, '生成代码', '8', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '生成操作'); -insert into sys_dict_data values(26, 9, '清空数据', '9', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '清空操作'); -insert into sys_dict_data values(27, 1, '成功', '0', 'sys_common_status', '', 'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态'); -insert into sys_dict_data values(28, 2, '失败', '1', 'sys_common_status', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态'); +insert into sys_dict_data values(18, 99, '其他', '0', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '其他操作'); +insert into sys_dict_data values(19, 1, '新增', '1', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '新增操作'); +insert into sys_dict_data values(20, 2, '修改', '2', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '修改操作'); +insert into sys_dict_data values(21, 3, '删除', '3', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '删除操作'); +insert into sys_dict_data values(22, 4, '授权', '4', 'sys_oper_type', '', 'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '授权操作'); +insert into sys_dict_data values(23, 5, '导出', '5', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '导出操作'); +insert into sys_dict_data values(24, 6, '导入', '6', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '导入操作'); +insert into sys_dict_data values(25, 7, '强退', '7', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '强退操作'); +insert into sys_dict_data values(26, 8, '生成代码', '8', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '生成操作'); +insert into sys_dict_data values(27, 9, '清空数据', '9', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '清空操作'); +insert into sys_dict_data values(28, 1, '成功', '0', 'sys_common_status', '', 'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态'); +insert into sys_dict_data values(29, 2, '失败', '1', 'sys_common_status', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态'); -- ---------------------------- @@ -528,9 +529,10 @@ create table sys_config ( primary key (config_id) ) engine=innodb auto_increment=100 comment = '参数配置表'; -insert into sys_config values(1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' ); -insert into sys_config values(2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '初始化密码 123456' ); -insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '深黑主题theme-dark,浅色主题theme-light,深蓝主题theme-blue' ); +insert into sys_config values(1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow'); +insert into sys_config values(2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '初始化密码 123456'); +insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '深黑主题theme-dark,浅色主题theme-light,深蓝主题theme-blue'); +insert into sys_config values(4, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '是否开启注册用户功能'); -- ----------------------------