diff --git a/pom.xml b/pom.xml index aa15b270..b765389e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,8 +5,8 @@ com.ruoyi RuoYi - 1.1.1 - war + 1.1.2 + jar RuoYi 若依管理系统 @@ -43,12 +43,14 @@ org.springframework.boot spring-boot-starter + diff --git a/sql/ry_20180505.sql b/sql/ry_20180506.sql similarity index 99% rename from sql/ry_20180505.sql rename to sql/ry_20180506.sql index fe0cc6f6..e185a483 100644 --- a/sql/ry_20180505.sql +++ b/sql/ry_20180506.sql @@ -25,10 +25,10 @@ insert into sys_dept values(100, 0, '若依集团', 0, '马云', '15011112221 insert into sys_dept values(101, 100, '研发部门', 1, '马研', '15011112222', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); insert into sys_dept values(102, 100, '市场部门', 2, '马市', '15011112223', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); insert into sys_dept values(103, 100, '测试部门', 3, '马测', '15011112224', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); -insert into sys_dept values(104, 100, '财务部门', 4, '马财', '15011112225', 'ry@qq.com', 1, 'admin', '2018-03-01', 'ry', '2018-03-01'); -insert into sys_dept values(105, 100, '运维部门', 5, '马运', '15011112226', 'ry@qq.com', 1, 'admin', '2018-03-01', 'ry', '2018-03-01'); +insert into sys_dept values(104, 100, '财务部门', 4, '马财', '15011112225', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); +insert into sys_dept values(105, 100, '运维部门', 5, '马运', '15011112226', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); insert into sys_dept values(106, 101, '研发一部', 1, '马一', '15011112227', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); -insert into sys_dept values(107, 101, '研发二部', 2, '马二', '15011112228', 'ry@qq.com', 1, 'admin', '2018-03-01', 'ry', '2018-03-01'); +insert into sys_dept values(107, 101, '研发二部', 2, '马二', '15011112228', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); insert into sys_dept values(108, 102, '市场一部', 1, '马一', '15011112229', 'ry@qq.com', 0, 'admin', '2018-03-01', 'ry', '2018-03-01'); insert into sys_dept values(109, 102, '市场二部', 2, '马二', '15011112210', 'ry@qq.com', 1, 'admin', '2018-03-01', 'ry', '2018-03-01'); @@ -61,8 +61,8 @@ create table sys_user ( -- ---------------------------- -- 初始化-用户信息表数据 -- ---------------------------- -insert into sys_user values(1, 106, 'admin', '若依', 'yzz_ivy@163.com', '15088888888', '0', 'img/a5.jpg', '29c67a30398638269fe600f73a054934', '111111', 'N', 1, '维护中', 'admin', '2018-03-01', 'ry', '2018-03-01'); -insert into sys_user values(2, 108, 'ry', '若依', 'ry@163.com', '15288888888', '1', 'img/a5.jpg', '8e6d98b90472783cc73c17047ddccf36', '222222', 'N', 1, '锁定中', 'admin', '2018-03-01', 'ry', '2018-03-01'); +insert into sys_user values(1, 106, 'admin', '若依', 'yzz_ivy@163.com', '15088888888', '0', 'img/a5.jpg', '29c67a30398638269fe600f73a054934', '111111', 'N', 0, '维护中', 'admin', '2018-03-01', 'ry', '2018-03-01'); +insert into sys_user values(2, 108, 'ry', '若依', 'ry@163.com', '15288888888', '1', 'img/a5.jpg', '8e6d98b90472783cc73c17047ddccf36', '222222', 'N', 0, '锁定中', 'admin', '2018-03-01', 'ry', '2018-03-01'); -- ---------------------------- diff --git a/src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java b/src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java index 726f0e85..b9875cbc 100644 --- a/src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java +++ b/src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java @@ -1,6 +1,8 @@ package com.ruoyi.common.utils.security; import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.PrincipalCollection; +import org.apache.shiro.subject.SimplePrincipalCollection; import org.apache.shiro.subject.Subject; import com.ruoyi.project.system.user.domain.User; @@ -28,6 +30,16 @@ public class ShiroUtils return (User) getSubjct().getPrincipal(); } + public static void setUser(User user) + { + Subject subject = getSubjct(); + PrincipalCollection principalCollection = subject.getPrincipals(); + String realmName = principalCollection.getRealmNames().iterator().next(); + PrincipalCollection newPrincipalCollection = new SimplePrincipalCollection(user, realmName); + // 重新加载Principal + subject.runAs(newPrincipalCollection); + } + public static Long getUserId() { return getUser().getUserId().longValue(); diff --git a/src/main/java/com/ruoyi/framework/web/controller/BaseController.java b/src/main/java/com/ruoyi/framework/web/controller/BaseController.java index 676f8769..d8d599a6 100644 --- a/src/main/java/com/ruoyi/framework/web/controller/BaseController.java +++ b/src/main/java/com/ruoyi/framework/web/controller/BaseController.java @@ -58,6 +58,11 @@ public class BaseController { return ShiroUtils.getUser(); } + + public void setUser(User user) + { + ShiroUtils.setUser(user); + } public Long getUserId() { diff --git a/src/main/java/com/ruoyi/project/system/user/controller/ProfileController.java b/src/main/java/com/ruoyi/project/system/user/controller/ProfileController.java new file mode 100644 index 00000000..063000b2 --- /dev/null +++ b/src/main/java/com/ruoyi/project/system/user/controller/ProfileController.java @@ -0,0 +1,119 @@ +package com.ruoyi.project.system.user.controller; + +import org.apache.shiro.crypto.hash.Md5Hash; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +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.ResponseBody; +import com.ruoyi.framework.aspectj.lang.annotation.Log; +import com.ruoyi.framework.web.controller.BaseController; +import com.ruoyi.framework.web.domain.Message; +import com.ruoyi.project.system.user.domain.User; +import com.ruoyi.project.system.user.service.IUserService; + +/** + * 个人信息 业务处理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/user/profile") +public class ProfileController extends BaseController +{ + private String prefix = "system/user/profile"; + + @Autowired + private IUserService userService; + + /** + * 个人信息 + */ + @GetMapping() + public String profile(Model model) + { + User user = getUser(); + String sex = user.getSex(); + if ("0".equals(sex)) + { + user.setSex("性别:男"); + } + else if ("1".equals(sex)) + { + user.setSex("性别:女"); + } + String roleGroup = userService.selectUserRoleGroup(user.getUserId()); + String postGroup = userService.selectUserPostGroup(user.getUserId()); + model.addAttribute("user", user); + model.addAttribute("roleGroup", roleGroup); + model.addAttribute("postGroup", postGroup); + return prefix + "/profile"; + } + + @RequestMapping("/checkPassword") + @ResponseBody + public boolean checkPassword(String password) + { + User user = getUser(); + String encrypt = new Md5Hash(user.getLoginName() + password + user.getSalt()).toHex().toString(); + if (user.getPassword().equals(encrypt)) + { + return true; + } + return false; + } + + @Log(title = "系统管理", action = "个人信息-重置密码") + @GetMapping("/resetPwd/{userId}") + public String resetPwd(@PathVariable("userId") Long userId, Model model) + { + User user = userService.selectUserById(userId); + model.addAttribute("user", user); + return prefix + "/resetPwd"; + } + + @Log(title = "系统管理", action = "个人信息-重置密码") + @PostMapping("/resetPwd") + @ResponseBody + public Message resetPwd(User user) + { + int rows = userService.resetUserPwd(user); + if (rows > 0) + { + setUser(userService.selectUserById(user.getUserId())); + return Message.ok(); + } + return Message.error(); + } + + /** + * 修改用户 + */ + @Log(title = "系统管理", action = "个人信息-修改用户") + @GetMapping("/edit/{userId}") + public String edit(@PathVariable("userId") Long userId, Model model) + { + User user = userService.selectUserById(userId); + model.addAttribute("user", user); + return prefix + "/edit"; + } + + /** + * 修改用户 + */ + @Log(title = "系统管理", action = "个人信息-保存用户") + @PostMapping("/update") + @ResponseBody + public Message update(User user) + { + if (userService.updateUser(user) > 0) + { + setUser(userService.selectUserById(user.getUserId())); + return Message.ok(); + } + return Message.error(); + } +} diff --git a/src/main/java/com/ruoyi/project/system/user/controller/UserController.java b/src/main/java/com/ruoyi/project/system/user/controller/UserController.java index 920e4976..925e2f02 100644 --- a/src/main/java/com/ruoyi/project/system/user/controller/UserController.java +++ b/src/main/java/com/ruoyi/project/system/user/controller/UserController.java @@ -109,7 +109,7 @@ public class UserController extends BaseController @ResponseBody public Message resetPwd(User user) { - int rows = userService.updateUser(user); + int rows = userService.resetUserPwd(user); if (rows > 0) { return Message.ok(); @@ -152,10 +152,10 @@ public class UserController extends BaseController } /** - * 保存 + * 保存用户 */ @RequiresPermissions("system:user:save") - @Log(title = "系统管理", action = "部门管理-保存部门") + @Log(title = "系统管理", action = "用户管理-保存用户") @PostMapping("/save") @Transactional(rollbackFor = Exception.class) @ResponseBody @@ -183,28 +183,4 @@ public class UserController extends BaseController return uniqueFlag; } - /** - * 个人信息 - */ - @GetMapping("/profile") - public String profile(Model model) - { - User user = getUser(); - String sex = user.getSex(); - if ("0".equals(sex)) - { - user.setSex("性别:男"); - } - else if ("1".equals(sex)) - { - user.setSex("性别:女"); - } - String roleGroup = userService.selectUserRoleGroup(user.getUserId()); - String postGroup = userService.selectUserPostGroup(user.getUserId()); - model.addAttribute("user", user); - model.addAttribute("roleGroup", roleGroup); - model.addAttribute("postGroup", postGroup); - return prefix + "/profile"; - } - } \ No newline at end of file diff --git a/src/main/java/com/ruoyi/project/system/user/service/IUserService.java b/src/main/java/com/ruoyi/project/system/user/service/IUserService.java index d07fcf24..ab518b35 100644 --- a/src/main/java/com/ruoyi/project/system/user/service/IUserService.java +++ b/src/main/java/com/ruoyi/project/system/user/service/IUserService.java @@ -58,7 +58,7 @@ public interface IUserService * @return 结果 */ public int saveUser(User user); - + /** * 修改用户信息 * @@ -67,6 +67,14 @@ public interface IUserService */ public int updateUser(User user); + /** + * 修改用户密码信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int resetUserPwd(User user); + /** * 校验用户名称是否唯一 * diff --git a/src/main/java/com/ruoyi/project/system/user/service/UserServiceImpl.java b/src/main/java/com/ruoyi/project/system/user/service/UserServiceImpl.java index b1edf2b8..24a3ba62 100644 --- a/src/main/java/com/ruoyi/project/system/user/service/UserServiceImpl.java +++ b/src/main/java/com/ruoyi/project/system/user/service/UserServiceImpl.java @@ -162,8 +162,19 @@ public class UserServiceImpl implements IUserService * @param user 用户信息 * @return 结果 */ - @Override public int updateUser(User user) + { + return userDao.updateUser(user); + } + + /** + * 修改用户密码 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int resetUserPwd(User user) { user.randomSalt(); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f3b2c8ee..eafe2458 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,7 +1,7 @@ # 项目名称、版本、版权年份 ruoyi: name: RuoYi - version: 1.1.1 + version: 1.1.2 copyrightYear: 2018 #开发环境配置 diff --git a/src/main/resources/static/img/a1.jpg b/src/main/resources/static/img/a1.jpg deleted file mode 100644 index 4db26bc3..00000000 Binary files a/src/main/resources/static/img/a1.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a2.jpg b/src/main/resources/static/img/a2.jpg deleted file mode 100644 index 36f7728f..00000000 Binary files a/src/main/resources/static/img/a2.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a3.jpg b/src/main/resources/static/img/a3.jpg deleted file mode 100644 index 64c20499..00000000 Binary files a/src/main/resources/static/img/a3.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a4.jpg b/src/main/resources/static/img/a4.jpg deleted file mode 100644 index f82f9f4b..00000000 Binary files a/src/main/resources/static/img/a4.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a6.jpg b/src/main/resources/static/img/a6.jpg deleted file mode 100644 index 935ccc7f..00000000 Binary files a/src/main/resources/static/img/a6.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a7.jpg b/src/main/resources/static/img/a7.jpg deleted file mode 100644 index 975ac181..00000000 Binary files a/src/main/resources/static/img/a7.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a8.jpg b/src/main/resources/static/img/a8.jpg deleted file mode 100644 index 7c89190c..00000000 Binary files a/src/main/resources/static/img/a8.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a9.jpg b/src/main/resources/static/img/a9.jpg deleted file mode 100644 index 508eb092..00000000 Binary files a/src/main/resources/static/img/a9.jpg and /dev/null differ diff --git a/src/main/resources/static/img/a5.jpg b/src/main/resources/static/img/profilel.jpg similarity index 100% rename from src/main/resources/static/img/a5.jpg rename to src/main/resources/static/img/profilel.jpg diff --git a/src/main/resources/static/ruoyi/css/RuoYi.css b/src/main/resources/static/ruoyi/css/RuoYi.css index 0b5d740b..d4df17c7 100644 --- a/src/main/resources/static/ruoyi/css/RuoYi.css +++ b/src/main/resources/static/ruoyi/css/RuoYi.css @@ -1,5 +1,5 @@ /*! - * ruoyi.css v1.1.1 + * ruoyi.css * Author: Ruoyi */ diff --git a/src/main/resources/static/ruoyi/system/dept/add.js b/src/main/resources/static/ruoyi/system/dept/add.js index 7c0bde11..7b957314 100644 --- a/src/main/resources/static/ruoyi/system/dept/add.js +++ b/src/main/resources/static/ruoyi/system/dept/add.js @@ -5,7 +5,7 @@ $("#form-dept-add").validate({ remote: { url: ctx + "system/dept/checkDeptNameUnique", type: "post", - dataType: "text", + dataType: "json", data: { "deptName" : function() { return $("input[name='deptName']").val(); diff --git a/src/main/resources/static/ruoyi/system/dept/edit.js b/src/main/resources/static/ruoyi/system/dept/edit.js index 4cce1924..f5906885 100644 --- a/src/main/resources/static/ruoyi/system/dept/edit.js +++ b/src/main/resources/static/ruoyi/system/dept/edit.js @@ -5,7 +5,7 @@ $("#form-dept-edit").validate({ remote: { url: ctx + "system/dept/checkDeptNameUnique", type: "post", - dataType: "text", + dataType: "json", data: { "deptId": function() { return $("input[name='deptId']").val(); diff --git a/src/main/resources/static/ruoyi/system/dict/type/add.js b/src/main/resources/static/ruoyi/system/dict/type/add.js index c5b0dfde..1d1d681e 100644 --- a/src/main/resources/static/ruoyi/system/dict/type/add.js +++ b/src/main/resources/static/ruoyi/system/dict/type/add.js @@ -9,7 +9,7 @@ $("#form-dict-add").validate({ remote: { url: ctx + "system/dict/checkDictTypeUnique", type: "post", - dataType: "text", + dataType: "json", data: { name : function() { return $.trim($("#dictType").val()); diff --git a/src/main/resources/static/ruoyi/system/dict/type/edit.js b/src/main/resources/static/ruoyi/system/dict/type/edit.js index 9964744f..7c8591db 100644 --- a/src/main/resources/static/ruoyi/system/dict/type/edit.js +++ b/src/main/resources/static/ruoyi/system/dict/type/edit.js @@ -9,7 +9,7 @@ $("#form-dict-edit").validate({ remote: { url: ctx + "system/dict/checkDictTypeUnique", type: "post", - dataType: "text", + dataType: "json", data: { dictId : function() { return $.trim($("#dictId").val()); diff --git a/src/main/resources/static/ruoyi/system/menu/add.js b/src/main/resources/static/ruoyi/system/menu/add.js index 37958dfc..0a3d3f0e 100644 --- a/src/main/resources/static/ruoyi/system/menu/add.js +++ b/src/main/resources/static/ruoyi/system/menu/add.js @@ -5,7 +5,7 @@ $("#form-menu-add").validate({ remote: { url: ctx + "system/menu/checkMenuNameUnique", type: "post", - dataType: "text", + dataType: "json", data: { "menuName" : function() { return $.trim($("#menuName").val()); diff --git a/src/main/resources/static/ruoyi/system/menu/edit.js b/src/main/resources/static/ruoyi/system/menu/edit.js index 4e1a096c..cf7cb1b1 100644 --- a/src/main/resources/static/ruoyi/system/menu/edit.js +++ b/src/main/resources/static/ruoyi/system/menu/edit.js @@ -10,7 +10,7 @@ $("#form-menu-edit").validate({ remote: { url: ctx + "system/menu/checkMenuNameUnique", type: "post", - dataType: "text", + dataType: "json", data: { "menuId": function() { return $("input[name='menuId']").val(); diff --git a/src/main/resources/static/ruoyi/system/role/add.js b/src/main/resources/static/ruoyi/system/role/add.js index 8d4b4fe8..24ff9b2a 100644 --- a/src/main/resources/static/ruoyi/system/role/add.js +++ b/src/main/resources/static/ruoyi/system/role/add.js @@ -23,7 +23,7 @@ $("#form-role-add").validate({ remote: { url: ctx + "system/role/checkRoleNameUnique", type: "post", - dataType: "text", + dataType: "json", data: { "roleName" : function() { return $.trim($("#roleName").val()); diff --git a/src/main/resources/static/ruoyi/system/role/edit.js b/src/main/resources/static/ruoyi/system/role/edit.js index 6a0ac8ba..af45a296 100644 --- a/src/main/resources/static/ruoyi/system/role/edit.js +++ b/src/main/resources/static/ruoyi/system/role/edit.js @@ -23,7 +23,7 @@ $("#form-role-edit").validate({ remote: { url: ctx + "system/role/checkRoleNameUnique", type: "post", - dataType: "text", + dataType: "json", data: { "roleId": function() { return $("input[name='roleId']").val(); diff --git a/src/main/resources/static/ruoyi/system/user/add.js b/src/main/resources/static/ruoyi/system/user/add.js index 0720a56b..69747ea0 100644 --- a/src/main/resources/static/ruoyi/system/user/add.js +++ b/src/main/resources/static/ruoyi/system/user/add.js @@ -6,7 +6,7 @@ $("#form-user-add").validate({ remote: { url: ctx + "system/user/checkUserNameUnique", type: "post", - dataType: "text", + dataType: "json", data: { name : function() { return $.trim($("#loginName").val()); diff --git a/src/main/resources/templates/include.html b/src/main/resources/templates/include.html index 1d9d6d9b..3c74bed7 100644 --- a/src/main/resources/templates/include.html +++ b/src/main/resources/templates/include.html @@ -33,8 +33,8 @@ - - + + diff --git a/src/main/resources/templates/main.html b/src/main/resources/templates/main.html index e3165663..c3e9db33 100644 --- a/src/main/resources/templates/main.html +++ b/src/main/resources/templates/main.html @@ -45,8 +45,8 @@ 访问码云 - - 访问博客 + + 访问主页

@@ -94,13 +94,35 @@
+
+
+
+ v1.1.22018.05.07 +
+
+
+
+
    +
  1. 新增个人信息修改
  2. +
  3. 菜单存在子菜单不允许删除
  4. +
  5. 菜单分配角色不允许删除
  6. +
  7. 角色分配人员不允许删除
  8. +
  9. 岗位使用后不允许删除
  10. +
  11. 保证用户的数据完整性加入事物
  12. +
  13. 新增环境使用手册、数据建模
  14. +
  15. Thymeleaf升级到3.0
  16. +
  17. 支持非ROOT部署
  18. +
+
+
+
v1.1.12018.04.23
-
+
  1. 新增表单构建器
  2. diff --git a/src/main/resources/templates/system/user/profile/edit.html b/src/main/resources/templates/system/user/profile/edit.html new file mode 100644 index 00000000..5fa38c3b --- /dev/null +++ b/src/main/resources/templates/system/user/profile/edit.html @@ -0,0 +1,90 @@ + + + + + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    +
    + + + diff --git a/src/main/resources/templates/system/user/profile.html b/src/main/resources/templates/system/user/profile/profile.html similarity index 82% rename from src/main/resources/templates/system/user/profile.html rename to src/main/resources/templates/system/user/profile/profile.html index e86f603f..4b5fe1bc 100644 --- a/src/main/resources/templates/system/user/profile.html +++ b/src/main/resources/templates/system/user/profile/profile.html @@ -25,9 +25,8 @@
@@ -35,7 +34,7 @@
- image + image
CEO
@@ -60,17 +59,14 @@ diff --git a/src/main/resources/templates/system/user/profile/resetPwd.html b/src/main/resources/templates/system/user/profile/resetPwd.html new file mode 100644 index 00000000..645c4bfa --- /dev/null +++ b/src/main/resources/templates/system/user/profile/resetPwd.html @@ -0,0 +1,113 @@ + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+
+
+ + + + +