Java项目:角色权限后台脚手架系统(java+Springboot+Maven+myBaits-Plus+Vue+Element-UI+Mysql)
源码获取:博客首页 "资源" 里下载!
Springboot框架+myBaits-Plus+MySQL实现的角色权限后台管理脚手架系统实战项目,实现的是所有系统最基础的后台管理功能,有了这个脚手架,以后开发别的项目就在这上面快速增加功能即可。本系统主要实现的功能有:菜单管理、角色管理、用户管理、登录、登出,不同的角色分配相应的权限,用户分配不同的角色登录后显示相应被分配的功能。
本系统采用前后端分离的思想设计,后端采用springboot微服务架构,主要包含一个网关服务和一个权限管理服务,开发其他功能可以再创建其他的微服务,前端采用vue+element-UI实现。
1.本系统开发所需的基础环境及版本:
软件 | 版本 |
jdk | 1.8 |
MySQL | 5.7 |
maven | 3.6.1 |
nacos | 1.1.4 |
Redis | 5.0.10 |
Node | 14.17.3 |
用户管理控制层:
@Controller
@RequestMapping("/user")
public class UserController extends BaseController{private String prefix = "system/user/";@AutowiredIUserService iUserService;@AutowiredIRoleService iRoleService;@AutowiredIDeptService iDeptService;@AutowiredIPositionService iPositionService;@Autowiredprivate SysPasswordService passwordService;/**** @描述 跳转到用户页面** @date 2018/9/16 10:54*/@RequestMapping("/tolist")@RequiresPermissions("user:list")public String toUserList(){return prefix + "user";}/*** @描述 用户数据* @date 2018/9/15 12:30*/@RequestMapping("/tableList")@ResponseBodypublic TableDataInfo list(User user){startPage();List<User> users = iUserService.selectByUser(user);return getDataTable(users);}/*** 编辑用户 system/user/edit/20180914-1*/@RequiresPermissions("user:update")@RequestMapping("/edit/{userId}")public String edit(@PathVariable("userId") String userId, Model model){// 个人信息User user = iUserService.selectByPrimaryKey(userId);Map<String, Object> role_post_dept = getRole_Post_Dept();model.addAttribute("depts", role_post_dept.get("dept"));model.addAttribute("roles", role_post_dept.get("role"));model.addAttribute("positions", role_post_dept.get("position"));model.addAttribute("user", user);return prefix + "edit";}/**** @描述 保存用户** @date 2018/9/15 18:53*/@PostMapping("/editSave")@RequiresPermissions("user:update")@Operlog(modal = "用户管理", descr = "修改用户信息")@ResponseBodypublic AjaxResult save(User user){if (StringUtils.isNotNull(user.getUid()) && User.isBoss(user.getUid())){return error("不允许修改管理员用户");}if(user.getPwd()!=null){user.setSalt(ShiroUtils.randomSalt());SimpleHash md5 = new SimpleHash("MD5", user.getPwd(), user.getSalt(), 1024);user.setPwd(md5.toHex());}return result(iUserService.updateByPrimaryKeySelective(user));}/*** @描述 添加用户页面* @date 2018/9/15 18:46*/@RequestMapping("/toAdd")@RequiresPermissions("user:add")public String toaddUser(Model model){Map<String, Object> role_post_dept = getRole_Post_Dept();model.addAttribute("depts", role_post_dept.get("dept"));model.addAttribute("roles", role_post_dept.get("role"));model.addAttribute("positions", role_post_dept.get("position"));return prefix + "add";}/**** @描述 添加用户** @date 2018/9/15 20:40*/@RequestMapping("/addSave")@RequiresPermissions("user:add")@Operlog(modal = "用户管理", descr = "添加用户")@ResponseBodypublic AjaxResult addUser(User user){user.setSalt(ShiroUtils.randomSalt());SimpleHash md5 = new SimpleHash("MD5", user.getPwd(), user.getSalt(), 1024);user.setPwd(md5.toHex());user.setAvatar(CsEnum.avatar.USER_AVATAR.getValue());user.setCreateTime(new Date());return result(iUserService.insertSelective(user));}/**** @描述 批量删除** @date 2018/9/16 9:31*/@RequestMapping("/del")@RequiresPermissions("user:del")@Operlog(modal = "用户模块", descr = "删除用户")@ResponseBodypublic AjaxResult delByUserIds(String[] ids){try{int i = iUserService.deleteByPrimaryKeys(ids);}catch (Exception e){return error(e.getMessage());}return success();}/**** @描述 编辑密码修改页面** @date 2018/9/16 10:25*/@RequestMapping("/resetPwd/{userId}")@RequiresPermissions("user:update")public String editPwd(@PathVariable("userId") String id, Model model){model.addAttribute("uid", id);return prefix + "resetPwd";}/**** @描述 密码修改** @date 2018/9/16 10:42*/@RequestMapping("/resetPwd")@RequiresPermissions("user:update")@Operlog(modal = "用户模块", descr = "修改密码")@ResponseBodypublic AjaxResult resetPwd(User user){return result(iUserService.resrtPwd(user));}/*** 校验手机号码*/@PostMapping("/checkPhoneUnique")@ResponseBodypublic String checkPhoneUnique(User user){String uniqueFlag = "0";if (user != null){uniqueFlag = iUserService.checkPhoneUnique(user);}return uniqueFlag;}/*** 校验email邮箱*/@PostMapping("/checkEmailUnique")@ResponseBodypublic String checkEmailUnique(User user){String uniqueFlag = "0";if (user != null){uniqueFlag = iUserService.checkEmailUnique(user);}return uniqueFlag;}/**** @描述: 校验登录名唯一性** @params:* @return:* @date: 2018/10/2 17:06*/@PostMapping("/checkLoginNameUnique")@ResponseBodypublic String checkLoginNameUnique(User user){String uniqueFlag = "0";if (user != null){uniqueFlag = iUserService.checkLoginNameUnique(user);}return uniqueFlag;}public Map<String, Object> getRole_Post_Dept(){Map<String, Object> map = new HashMap<>();
// 角色List<Role> roles = iRoleService.selectRoleList(new Role());
// 部门信息List<Dept> depts = iDeptService.selectDeptList(new Dept());
// 岗位List<Position> positions = iPositionService.selectPositionList(new Position());map.put("role", roles);map.put("dept", depts);map.put("position", positions);return map;}/*** 用户个人信息查看页面*/@RequestMapping("/myMsg")public String ToMyMsg(Model model, HttpServletRequest request){User user = iUserService.selectByPrimaryKey(getUserId());model.addAttribute("user", user);model.addAttribute("loginIp", HttpHeaderUtil.getIpAddr(request));return prefix + "profile/msg";}/*** 密码修改页面*/@RequestMapping("/resetMyPwd")public String toResetPwd(Model model){User user = iUserService.selectByPrimaryKey(getUserId());model.addAttribute("user", user);return prefix + "profile/resetPwd";}/*** 密码修改保存*/@RequestMapping("/updateMyPwdSave")@ResponseBody@RequiresPermissions("user:update")@Operlog(modal = "个人信息", descr = "修改密码")public AjaxResult updateMyPwdSave(String password){User user = new User();user.setSalt(ShiroUtils.randomSalt());SimpleHash md5 = new SimpleHash("MD5", password, user.getSalt(), 1024);user.setPwd(md5.toHex());user.setUid(getUserId());int i = iUserService.updateByPrimaryKeySelective(user);if (i > 0){//更新shiro中的信息ShiroUtils.reloadUser(iUserService.selectByPrimaryKey(getUserId()));return success();}return error();}/*** 编辑用户头像修改*/@RequestMapping("/updateAvatar")public String toupdateAvatar(Model model){model.addAttribute("user", getUser());return prefix + "profile/avatar";}/*** 修改保存用户头像*/@RequestMapping("/updateAvatarSave")@RequiresPermissions("user:update")@Operlog(modal = "个人信息", descr = "修改头像")@ResponseBodypublic AjaxResult toupdateAvatar(MultipartFile file){try{String imgPath = UploadFile.uploadUserImg(file);if (StringUtils.isEmpty(imgPath)){return error("图片上传失败,稍后再试!");}User user = new User();user.setUid(getUserId());user.setAvatar(imgPath);int i = iUserService.updateByPrimaryKeySelective(user);if (i > 0){ShiroUtils.reloadUser(iUserService.selectByPrimaryKey(getUserId()));}return result(i);}catch (IOException e){return error();}catch (FileSizeException e){//文件过大return error(e.getMsg());}catch (FileNameLengthException e){//文件名字超长return error(e.getMsg());}}/*** 校验密码和原来密码是否相同*/@RequestMapping("/checkPassword")@ResponseBodypublic boolean checkPassword(String password){//加密后与数据库密码比较User user = getUser();SimpleHash md5 = new SimpleHash("MD5", password, user.getSalt(), 1024);String oldPassword = md5.toHex();String pwd = getPwd();if (pwd.equals(oldPassword)){return true;}return false;}}
角色管理控制层:
@Controller
@RequestMapping("/role")
public class RoleController extends BaseController{private String prefix = "system/role/";@AutowiredIUserService iUserService;@AutowiredIRoleService iRoleService;@AutowiredIPermissionService iPermissionService;/**** @描述 页面跳转** @date 2018/9/16 10:59*/@RequestMapping("/tolist")@RequiresPermissions("role:list")public String tolist(){return prefix + "role";}/**** @描述 ajax请求所有** @date 2018/9/16 10:48*/@RequestMapping("/ajaxlist")@ResponseBodypublic List<Role> list(Role role){List<Role> roles = iRoleService.selectRoleList(role);return roles;}/**** @描述 列表** @date 2018/9/16 10:52*/@RequestMapping("/tableList")@ResponseBodypublic TableDataInfo listPag(Role role){//开启分页startPage();List<Role> roles = iRoleService.selectRoleList(role);return getDataTable(roles);}/**** @描述 新增页面** @date 2018/9/16 11:37*/@RequestMapping("/toAdd")@RequiresPermissions("role:add")public String toAdd(Model model){return prefix + "add";}/**** @描述 批量删除** @date 2018/9/16 11:53*/@RequestMapping("/del")@RequiresPermissions("role:del")@Operlog(modal = "角色管理",descr = "删除角色")@ResponseBodypublic AjaxResult del(Integer[] ids){try{iRoleService.deleteByPrimaryKeys(ids);}catch (Exception e){return error(e.getMessage());}return success();}/**** @描述 添加保存** @date 2018/9/16 11:54*/@RequestMapping("/addSave")@RequiresPermissions("role:update")@Operlog(modal = "角色管理",descr = "添加角色")@ResponseBodypublic AjaxResult addRole(Role role, Integer[] ids){role.setCreateTime(new Date());int insert = 0;try{if (StringUtils.isEmpty(ids)){ids = new Integer[0];}insert = iRoleService.insert(role, ids);}catch (Exception e){return error(e.getMessage());}//清空缓存ShiroUtils.clearCachedAuthorizationInfo();return result(insert);}/**** @描述: 根据ID 获取u他的所有权限 做回显** @params: roleId 角色Id* @return:* @date: 2018/9/27 14:04*/@RequestMapping("/selectById/{roleId}")@ResponseBodypublic Role selectById(@PathVariable("roleId") Integer roleId){Role role = iRoleService.selectByPrimaryKey(roleId);return role;}/**** @描述 编辑修改页面** @date 2018/9/16 14:06*/@RequestMapping("/edit/{id}")@RequiresPermissions("role:update")public String edit(@PathVariable("id") Integer id, Model model){Role role = iRoleService.selectByPrimaryKey(id);model.addAttribute("Role", role);return prefix + "edit";}/**** @描述 编辑修改权限页面** @date 2018/9/16 14:06*/@RequestMapping("/editPower/{id}")@RequiresPermissions("role:update")public String editPower(@PathVariable("id") Integer id, Model model){Role role = iRoleService.selectByPrimaryKey(id);model.addAttribute("Role", role);return prefix + "editPower";}/**** @描述 修改角色信息保存** @date 2018/9/16 16:12*/@RequestMapping("/editSave")@RequiresPermissions("role:update")@Operlog(modal = "角色管理",descr = "修改角色信息")@ResponseBodypublic AjaxResult save(Role role){int i = 0;try{i = iRoleService.updateByPrimaryKeySelective(role);}catch (Exception e){return error(e.getMessage());}return result(i);}/**** @描述 修改角色权限信息保存** @date 2018/9/16 16:12*/@RequestMapping("/editPowerSave")@RequiresPermissions("role:update")@Operlog(modal = "角色管理",descr = "修改角色权限")@ResponseBodypublic AjaxResult editPowerSave(Role role, Integer[] ids){int i = 0;try{if (StringUtils.isEmpty(ids)){ids = new Integer[0];}i = iRoleService.updateByPrimaryKeyPowerSelective(role, ids);}catch (Exception e){return error(e.getMessage());}//清空缓存ShiroUtils.clearCachedAuthorizationInfo();//如果用户正在修改的角色id 是当前用户的角色id 则刷新 subject的User信息if (role.getRoleId().equals(getRoleId())){ShiroUtils.reloadUser(iUserService.selectByPrimaryKey(getUserId()));}return result(i);}/*** 校验名称唯一*/@PostMapping("/checkRoleNameUnique")@ResponseBodypublic String checkDeptNameUnique(Role role){String uniqueFlag = "0";if (role != null){uniqueFlag = iRoleService.checkRoleNameUnique(role);}return uniqueFlag;}
}
登录管理控制层:
@org.springframework.stereotype.Controller
@RequestMapping("/oa")
public class LoginController extends BaseController{private static final Logger logger = LoggerFactory.getLogger(LoginController.class);private String prefix = "system/user/";@AutowiredLoginService loginService;@AutowiredIUserService userService;/**** @描述: 执行登录操作** @params: user:用户登录信息;* validateCode:验证码* @return:* @date: 2018/9/29 21:20*/@RequestMapping("/login")@Operlog(descr = "用户登录", modal = "登录模块")@ResponseBodypublic AjaxResult Logining(User user, String validateCode, Boolean rememberMe, HttpServletRequest request){HttpSession session = ServletUtils.getSession();UsernamePasswordToken token = new UsernamePasswordToken(user.getName(), user.getPwd());token.setRememberMe(rememberMe);Subject subject = SecurityUtils.getSubject();//验证用户名和密码 验证码的问题try{loginService.checkLogin(user.getName(), user.getPwd(), validateCode);}catch (Exception e){session.setAttribute(Constants.LOGIN_ERROR, e.getMessage());return error(e.getMessage());}try{if (!subject.isAuthenticated()){subject.login(token);}}catch (IncorrectCredentialsException e){session.setAttribute(Constants.LOGIN_ERROR,"密码错误");return error("密码错误!");}catch (UnknownAccountException e){session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());return error(e.getMessage());}catch (LockedAccountException e){session.setAttribute("login",e.getMessage());return error(e.getMessage());}catch (AuthenticationException e){
// String msg = "用户名或密码错误!";
// if (!StringUtils.isEmpty(e.getMessage()))
// {
// msg = e.getMessage();
// }session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());return error("系统异常!");}return success();}/**s sl** @描述: 登录页面** @params:* @return:* @date: 2018/9/29 21:20*/@RequestMapping("/toLogin")public String toLogin(){return "login";}}
源码获取:博客首页 "资源" 里下载!
相关文章:

30+程序员,平时都忙些什么事情?平时都想些什么?以后有啥计划?
很多人都说,30岁以后了,写程序还有前途嘛?我有时候也迷茫,但是迷茫过后,总会给自己寻找方向,每个人都需要有个信念、没有信念,活着就没意思,无聊,觉得没奔头了。 废话少说…

用于制图、写电子邮件、创建条形码控件Aspose.Total
2019独角兽企业重金招聘Python工程师标准>>> Aspose.Total 提供了 Aspose 可以使用的任何组件,以及你每年订阅中发布的所有新组件。通过它,你能够有计划地操纵一些商业中最流行的文件格式:Word, Excel, PowerPoint, Project, PDF …

循环for语句 if语句
if语句: if(表达式){ 代码 }else if(表达式){ 代码 } for循环: for(var i0; i<10; i){ alert(1); (弹窗) } if语句: if(表达式){ 代码 }else if(表达式){ 代码 } for循环: for(var i0; i<10; i){ alert(1); (弹窗…

Linux中的粘滞位
Linux中的粘滞位 Sticky 位是一个访问权限标志位,可以用来标示文件和路径。 历史: 粘滞位是在1974年Unix的第5版中引入的,用来设置可执行文件。当可执行文件设置粘滞位之后,它能够指示操作系统在程序退出后,保留程序…

Java项目:实现权限管理系统(java+SpringBoot+MyBatis+AOP+LayUI+Mysql)
源码获取:博客首页 "资源" 里下载! springbootmybatis使用面向切面编程(AOP)实现的权限管理系统。 共五个模块,角色管理,菜单管理,实验室管理,学生管理,管理员…

阅读10、11、12章
第10章 假设用户交付给我们一个 任务,然后我们通过调研的出来的结果进行设计,最后的结果跟用户想象的不一样,这应该怎么做? 第11章 团队合作真的需要有那么繁琐的步骤(例如每日例会)吗? 第12章 …

SQL删除重复数据方法
原文:SQL删除重复数据方法例如: id name value 1 a pp 2 a pp 3 b iii 4 b pp 5 b …

#pragma once与#ifndef
在C/C中,在使用预编译指令#include的时候,为了防止重复引用造成二义性的两种方法。 #ifndef 它不光可以保证同一份文件不会被包含两次,也能够保证不同文件完全相同的内容不会被包含两次。但,同样的,如果自定义的宏名不…

grep 在HP-UX下的递归查找
grep 在HP-UX下的递归查找Linux: man grep 可以看到 -r 选项-R, -r, --recursiveRead all files under each directory, recursively; this is equivalent to the -d recurse option.即:-r 选项可以查找指定目录下每个子目录下的所有文件eg:grep -r "28281&quo…

Java项目:实现个人博客系统(java+springboot+mybatis+redis+vue+elementui+Mysql)
源码获取:博客首页 "资源" 里下载! springbootmybatis前端vue,使用前后端分离架构实现的个人博客系统,共7个模块,首页,写博客,博客详情页,评论管理,文章分类&a…

软件工程--总作业(已经完成)
用户调研:http://www.cnblogs.com/OuZeBo/p/4580146.htmlalpha阶段总结:http://www.cnblogs.com/OuZeBo/p/4580146.html对其他组评价的反馈:已评论其他组,暂时没有其他组对我们组进行评论描述项目的典型用户与场景:已完…

linux各文件夹的作用域
目錄應放置檔案內容/bin系統有很多放置執行檔的目錄,但/bin比較特殊。因為/bin放置的是在單人維護模式下還能夠被操作的指令。在/bin底下的指令可以被root與一般帳號所使用,主要有:cat, chmod, chown, date, mv, mkdir, cp, bash等等常用的指…

LOJ 2721 「NOI2018」屠龙勇士——扩展中国剩余定理
题目:https://loj.ac/problem/2721 1.注意别一输入 p[ i ] 就 a[ i ] % p[ i ] ,因为在 multiset 里找的时候还需要真实值。 2.注意用 multiset 。并且,因为要 upper_bound( a[ i ] ) ,而 a[ i ] 是一个 long long 类型的…

setuid和setgid
setuid 和 setgid (全称分别是:set user ID upon execution 和 set group ID upon execution)是Unix的访问权限标志位,它允许 用户以可执行文件owner或group的权限来运行这个可执行文件。它们经常适用于:为了运行特定的任务,可以允…

Java项目:宠物医院预约挂号系统(java+JSP+Spring+SpringBoot+MyBatis+html+layui+maven+Mysql)
源码获取:博客首页 "资源" 里下载! 一、项目简述功能包括: 用户分为宠物,医生,管理员,宠物主人可进行注册选择医生挂号,选择日期,选择号源,医生可进行宠物接诊…

大智慧面试经验
15-06-18下午1点,大智慧面试; 面试题全英文,第一部分基础的,诸如echo print printf的区别,include与require的区别等; 第二部分细节方面的,如在string中\n的意义,ucwords函数&#x…

Android 获取apk签名的fingerprint
为什么80%的码农都做不了架构师?>>> 假定安装了JDK,如果想查HelloWorld.apk所使用的签名的fingerprint,可以这样做:1. 查找apk里的rsa文件 (Windows) > jar tf HelloWorld.apk |findstr RSA…

Dinic二分图匹配 || Luogu P3386
题面:【模板】二分图匹配 思路:Dinic实现二分图匹配,要建一个超级源点(S)和超级汇点(T),分别定为NM1和NM2 然后S去和N中的数建正边和反边,正边权值为1,反边权…

shell中引号的使用方法
1. shell使用引号(单引号/双引号)和反斜线("\")用于向shell解释器屏蔽一些特殊字符. 反引号[h2] 对shell则有特殊意义. 1.1 单引号和反斜线 [h1] 可以阻止shell代入变量的值; 1.2 双引号不能阻止代入 例如: sles10i32-1:han$ personha…

Java学习笔记(二)不定时更新
Java语言画图 package cn.witksy.dev;import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException;/*** Author: Alfred* Created: 2015/5/7*/ public class Main {public void run() {Buffered…

Java项目:前台后台玩具商城系统(java+JSP+SSM+Springboot+Jsp+maven+Mysql)
源码获取:博客首页 "资源" 里下载! 一、项目简述本系统主要实现的功能有: 网上商城系统,前台后台管理,用户注册,登录,商品展示,分组展示,搜索,收货…
Tempdb数据库详细介绍
Tempdb数据库详细介绍一、Tempdb简介tempdb是SQLServer的系统数据库一直都是SQLServer的重要组成部分,用来存储临时对象。可以简单理解tempdb是SQLServer的速写板。应用程序与数据库都可以使用tempdb作为临时的数据存储区。一个实例的所有用户都共享一个Tempdb。很明…

java——逻辑运算符与(和)或(|和||)
区别: 1意思不同: &&是“与”的意思,||是“或者”的意思。 2 使用上不同:a && b:a和b同时为true 才返回 true, 否则返回false;a || b:a或b任意一个为true 就返回tru…

UTRAN 的用户面和控制面
UTRAN接口的通用协议模型如下图: 通俗地讲,通讯网络由终端(terminal)、连接(links)、网络节点(nodes)组成, links将nodes 关联起来。源终端(MO)发送的消息是怎样才能到目的终端(MT)呢? 消息经过links 和nodes,直至到达MT,其中关键是nodes怎么…

Java项目:疫情人员流动管理系统(java+JSP+SSM+Springboot+maven+Mysql)
源码获取:博客首页 "资源" 里下载! 一、项目简述 本系统主要实现的功能有: 社区疫情流动人员管理系统,住户管理,出入管理,访客管理,体温录入,高风险警示等等。 二、项目运…
[原创]CentOS下Mysql双机互为备份
一、环境: 1.安装Centos-6.5-x64位系统的机器两台: host1:192.168.2.3 host2:192.168.2.4 (互相能ping通) 2.安装Mysql。 命令:Yum install mysql-* 二、配置: 1、启动mysql。命令&…

《Effective Java》读书笔记--创建和销毁对象
2019独角兽企业重金招聘Python工程师标准>>> 考虑用静态工厂方法代替构造函数。 当我们在写一个工具类时,是不希望用户将该类实例化的,所以应该定义一个private的构造函数,而不 是将类声明成abstract,因为这样用户可以…

用chrome的snippets片段功能创建页面js外挂程序,从控制台创建js小脚本
用chrome的snippets片段功能创建页面js外挂程序,从控制台创建js小脚本 Chrome的snippets是小脚本,还可以创作并在Chrome DevTools的来源面板中执行。可以访问和从任何页面运行它们。当你运行一个片段,它从当前打开的页面的上下文中执行。 要创…

两个类相互包含引用的问题--类前向声明
在构造自己的类时,有可能会碰到两个类之间的相互引用问题,例如:定义了类A类B,A中使用了B定义的类型,B中也使用了A定义的类型 class A { int i; B b; } class B { int i; A* a; } 请注意上面的定义内…

Java项目:网上电子书城项目(java+SSM+JSP+maven+Mysql)
源码获取:博客首页 "资源" 里下载! 项目描述: spring mvc jsp实现的简单书城项目,可以在支付宝沙箱内实现支付 运行环境: jdk8tomcat9mysqlIntelliJ IDEA 项目技术: springspring mvcmybati…