当前位置:   article > 正文

Java基于Springboot实现仓库管理系统_基于springboot的仓库管理系统

基于springboot的仓库管理系统

 

基础环境

1.运行环境:最好是java jdk 1.8,在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.数据库:MySql 5.7版本;

技术栈

1. 后端:SpringBoot
2. 前端:HTML+CSS+JavaScript+jsp

系统展示

主页面

基础管理

进货管理

销售管理

系统管理

 系统实现

权限相关代码实现

  1. @RestController
  2. @RequestMapping("permission")
  3. public class PermissionController {
  4. @Autowired
  5. private IPermissionService permissionService;
  6. /**
  7. * 加载权限左边的权限树
  8. * @param permissionVo
  9. * @return
  10. */
  11. @RequestMapping("loadPermissionManagerLeftTreeJson")
  12. public DataGridView loadPermissionManagerLeftTreeJson(PermissionVo permissionVo){
  13. QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
  14. queryWrapper.eq("type", Constast.TYPE_MENU);
  15. //查询出所有的权限,存放进list中
  16. List<Permission> list = permissionService.list(queryWrapper);
  17. List<TreeNode> treeNodes = new ArrayList<>();
  18. //将权限放入treeNodes中,组装成json
  19. for (Permission permission : list) {
  20. Boolean open = permission.getOpen()==1?true:false;
  21. treeNodes.add(new TreeNode(permission.getId(),permission.getPid(),permission.getTitle(),open));
  22. }
  23. return new DataGridView(treeNodes);
  24. }
  25. /**
  26. * 查询所有权限数据
  27. * @param permissionVo
  28. * @return
  29. */
  30. @RequestMapping("loadAllPermission")
  31. public DataGridView loadAllPermission(PermissionVo permissionVo){
  32. IPage<Permission> page = new Page<>(permissionVo.getPage(),permissionVo.getLimit());
  33. //进行模糊查询
  34. QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
  35. //只能查询权限
  36. queryWrapper.eq("type",Constast.TYPE_PERMISSION);
  37. queryWrapper.like(StringUtils.isNotBlank(permissionVo.getTitle()),"title",permissionVo.getTitle());
  38. queryWrapper.like(StringUtils.isNotBlank(permissionVo.getPercode()),"percode",permissionVo.getPercode());
  39. queryWrapper.eq(permissionVo.getId()!=null,"pid",permissionVo.getId());
  40. queryWrapper.orderByAsc("ordernum");
  41. //进行查询
  42. permissionService.page(page,queryWrapper);
  43. //返回DataGridView
  44. return new DataGridView(page.getTotal(),page.getRecords());
  45. }
  46. /**
  47. * 添加权限
  48. * @param permissionVo
  49. * @return
  50. */
  51. @RequestMapping("addPermission")
  52. public ResultObj addPermission(PermissionVo permissionVo){
  53. try {
  54. //设置添加类型为 permission
  55. permissionVo.setType(Constast.TYPE_PERMISSION);
  56. permissionService.save(permissionVo);
  57. return ResultObj.ADD_SUCCESS;
  58. } catch (Exception e) {
  59. e.printStackTrace();
  60. return ResultObj.ADD_ERROR;
  61. }
  62. }
  63. /**
  64. * 加载排序码
  65. * @return
  66. */
  67. @RequestMapping("loadPermissionMaxOrderNum")
  68. public Map<String,Object> loadPermissionMaxOrderNum(){
  69. Map<String,Object> map = new HashMap<String,Object>();
  70. QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
  71. queryWrapper.orderByDesc("ordernum");
  72. IPage<Permission> page = new Page<>(1,1);
  73. List<Permission> list = permissionService.page(page,queryWrapper).getRecords();
  74. if (list.size()>0){
  75. map.put("value",list.get(0).getOrdernum()+1);
  76. }else {
  77. map.put("value",1);
  78. }
  79. return map;
  80. }
  81. /**
  82. * 更新权限
  83. * @param permissionVo
  84. * @return
  85. */
  86. @RequestMapping("updatePermission")
  87. public ResultObj updatePermission(PermissionVo permissionVo){
  88. try {
  89. permissionService.updateById(permissionVo);
  90. return ResultObj.UPDATE_SUCCESS;
  91. } catch (Exception e) {
  92. e.printStackTrace();
  93. return ResultObj.UPDATE_ERROR;
  94. }
  95. }
  96. /**
  97. * 检查当前权限是否有子权限
  98. * @param permissionVo
  99. * @return
  100. */
  101. @RequestMapping("checkPermissionHasChildrenNode")
  102. public Map<String,Object> checkPermissionHasChildrenNode(PermissionVo permissionVo){
  103. Map<String,Object> map = new HashMap<String, Object>();
  104. QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
  105. queryWrapper.eq("pid",permissionVo.getId());
  106. List<Permission> list = permissionService.list(queryWrapper);
  107. if (list.size()>0){
  108. map.put("value",true);
  109. }else {
  110. map.put("value",false);
  111. }
  112. return map;
  113. }
  114. /**
  115. * 删除权限
  116. * @param permissionVo
  117. * @return
  118. */
  119. @RequestMapping("deletePermission")
  120. public ResultObj deletePermission(PermissionVo permissionVo){
  121. try {
  122. permissionService.removeById(permissionVo.getId());
  123. return ResultObj.DELETE_SUCCESS;
  124. } catch (Exception e) {
  125. e.printStackTrace();
  126. return ResultObj.DELETE_ERROR;
  127. }
  128. }
  129. }

登录相关代码

  1. @RestController
  2. @RequestMapping("login")
  3. public class LoginController {
  4. @Autowired
  5. private ILoginfoService loginfoService;
  6. @Autowired
  7. private IRoleService roleService;
  8. public static void main(String[] args) {
  9. String hashAlgorithmName = "MD5";//加密
  10. String credentials = "123456";//密码
  11. int hashIterations = 1024; //加密次数
  12. Object obj = new SimpleHash(hashAlgorithmName, credentials, "04A93C74C8294AA09A8B974FD1F4ECBB", 2);//null 为盐
  13. System.out.println(obj);
  14. }
  15. @RequestMapping("login")
  16. public ResultObj login(UserVo userVo, String code, HttpSession session){
  17. //获得存储在session中的验证码
  18. String sessionCode = (String) session.getAttribute("code");
  19. if (code!=null&&sessionCode.equals(code)){
  20. Subject subject = SecurityUtils.getSubject();
  21. AuthenticationToken token = new UsernamePasswordToken(userVo.getLoginname(),userVo.getPwd());
  22. try {
  23. //对用户进行认证登陆
  24. subject.login(token);
  25. //通过subject获取以认证活动的user
  26. ActiverUser activerUser = (ActiverUser) subject.getPrincipal();
  27. //将user存储到session中
  28. WebUtils.getSession().setAttribute("user",activerUser.getUser());
  29. //查询当前用户拥有的角色
  30. /* List<Integer> currentUserRoleIds = roleService.queryUserRoleIdsByUid(activerUser.getUser().getId());
  31. WebUtils.getSession().setAttribute("roles",activerUser.getRoles());
  32. System.out.println("roles:"+activerUser.getRoles());*/
  33. //记录登陆日志
  34. Loginfo entity = new Loginfo();
  35. entity.setLoginname(activerUser.getUser().getName()+"-"+activerUser.getUser().getLoginname());
  36. entity.setLoginip(WebUtils.getRequest().getRemoteAddr());
  37. entity.setLogintime(new Date());
  38. loginfoService.save(entity);
  39. return ResultObj.LOGIN_SUCCESS;
  40. } catch (AuthenticationException e) {
  41. e.printStackTrace();
  42. return ResultObj.LOGIN_ERROR_PASS;
  43. }
  44. }else {
  45. return ResultObj.LOGIN_ERROR_CODE;
  46. }
  47. }
  48. /**
  49. * 得到登陆验证码
  50. * @param response
  51. * @param session
  52. * @throws IOException
  53. */
  54. @RequestMapping("getCode")
  55. public void getCode(HttpServletResponse response, HttpSession session) throws IOException{
  56. //定义图形验证码的长和宽
  57. LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36,4,5);
  58. session.setAttribute("code",lineCaptcha.getCode());
  59. try {
  60. ServletOutputStream outputStream = response.getOutputStream();
  61. lineCaptcha.write(outputStream);
  62. outputStream.close();
  63. } catch (IOException e) {
  64. e.printStackTrace();
  65. }
  66. }
  67. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/146697
推荐阅读
相关标签
  

闽ICP备14008679号