• Java项目:SSM台球室计费管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    主要功能包括:

    登录,管理员首页,点击球台开台,增加会员,查看-删除会员,充值会员,酒水外卖,营业额查看,打烊设置等功能。 

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

    5.数据库:MySql 5.7版本;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:HTML+CSS+JavaScript+jsp

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入localhost:8080/ 登录

    运行截图

     

     

     

     

     

     

     

    相关代码

    AbstractController

    1. package com.learn.controller;
    2. import com.learn.utils.ShiroUtils;
    3. import com.learn.entity.SysUserEntity;
    4. import org.slf4j.Logger;
    5. import org.slf4j.LoggerFactory;
    6. /**
    7. * Controller公共组件
    8. *
    9. * @author chenshun
    10. * @email sunlightcs@gmail.com
    11. * @date 2018年11月9日 下午9:42:26
    12. */
    13. public abstract class AbstractController {
    14. protected Logger logger = LoggerFactory.getLogger(getClass());
    15. protected SysUserEntity getUser() {
    16. return ShiroUtils.getUserEntity();
    17. }
    18. protected Long getUserId() {
    19. return getUser().getUserId();
    20. }
    21. }

    ZuoyeController

    1. package com.learn.controller;
    2. import java.util.List;
    3. import java.util.Map;
    4. import org.apache.shiro.authz.annotation.RequiresPermissions;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.web.bind.annotation.PathVariable;
    7. import org.springframework.web.bind.annotation.RequestBody;
    8. import org.springframework.web.bind.annotation.RequestMapping;
    9. import org.springframework.web.bind.annotation.RequestParam;
    10. import org.springframework.web.bind.annotation.RestController;
    11. import com.learn.entity.ZuoyeEntity;
    12. import com.learn.service.ZuoyeService;
    13. import com.learn.utils.PageUtils;
    14. import com.learn.utils.Query;
    15. import com.learn.utils.R;
    16. /**
    17. * 作业信息
    18. *
    19. * @author chenshun
    20. * @email sunlightcs@gmail.com
    21. * @date 2020-04-01 16:42:55
    22. */
    23. @RestController
    24. @RequestMapping("zuoye")
    25. public class ZuoyeController extends AbstractController {
    26. @Autowired
    27. private ZuoyeService zuoyeService;
    28. /**
    29. * 列表
    30. */
    31. @RequestMapping("/list")
    32. public R list(@RequestParam Map params){
    33. if (super.getUserId() > 1)
    34. params.put("user", super.getUserId());
    35. //查询列表数据
    36. Query query = new Query(params);
    37. List zuoyeList = zuoyeService.queryList(query);
    38. int total = zuoyeService.queryTotal(query);
    39. PageUtils pageUtil = new PageUtils(zuoyeList, total, query.getLimit(), query.getPage());
    40. return R.ok().put("page", pageUtil);
    41. }
    42. /**
    43. * 列表
    44. */
    45. @RequestMapping("/list2")
    46. public R list2(@RequestParam Map params){
    47. Query query = new Query(params);
    48. List zuoyeList = zuoyeService.queryList(query);
    49. return R.ok().put("list", zuoyeList );
    50. }
    51. /**
    52. * 信息
    53. */
    54. @RequestMapping("/info/{id}")
    55. public R info(@PathVariable("id") Long id){
    56. ZuoyeEntity zuoye = zuoyeService.queryObject(id);
    57. return R.ok().put("zuoye", zuoye);
    58. }
    59. /**
    60. * 保存
    61. */
    62. @RequestMapping("/save")
    63. public R save(@RequestBody ZuoyeEntity zuoye){
    64. if (zuoye.getUser() == null)
    65. zuoye.setUser(super.getUserId());
    66. zuoyeService.save(zuoye);
    67. return R.ok();
    68. }
    69. /**
    70. * 修改
    71. */
    72. @RequestMapping("/update")
    73. public R update(@RequestBody ZuoyeEntity zuoye){
    74. zuoyeService.update(zuoye);
    75. return R.ok();
    76. }
    77. /**
    78. * 删除
    79. */
    80. @RequestMapping("/delete")
    81. public R delete(@RequestBody Long[] ids){
    82. zuoyeService.deleteBatch(ids);
    83. return R.ok();
    84. }
    85. }

    UploadController

    1. package com.learn.controller;
    2. import com.learn.utils.MultipartFileUtil;
    3. import com.learn.utils.R;
    4. import com.learn.utils.RRException;
    5. import org.springframework.web.bind.annotation.RequestMapping;
    6. import org.springframework.web.bind.annotation.RequestParam;
    7. import org.springframework.web.bind.annotation.ResponseBody;
    8. import org.springframework.web.bind.annotation.RestController;
    9. import org.springframework.web.multipart.MultipartFile;
    10. import javax.servlet.http.HttpServletRequest;
    11. import javax.servlet.http.HttpServletResponse;
    12. import java.io.IOException;
    13. import java.io.PrintWriter;
    14. /**
    15. * 文件上传
    16. *
    17. * @author shenyt
    18. * @email syt12322@163.com
    19. * @date 2020-03-25 12:13:26
    20. */
    21. @RestController
    22. @RequestMapping("file")
    23. public class UploadController {
    24. public static String[] suffixs = {"IMG", "PNG", "JPG", "JPEG", "GIF", "BPM"};
    25. /**
    26. * 上传文件
    27. */
    28. @RequestMapping("/upload")
    29. public R upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception {
    30. if (file.isEmpty()) {
    31. throw new RRException("上传文件不能为空");
    32. }
    33. String url = MultipartFileUtil.uploadFile("/cdn", file, request);
    34. return R.ok().put("url", "/ssm_xueyeyujing_sys/"+url);
    35. }
    36. /**
    37. * 上传资讯内容的图片
    38. *
    39. * @param upload 图片
    40. * @param response 响应
    41. */
    42. @ResponseBody
    43. @RequestMapping("ckEditorUpload")
    44. public void uploadFile(MultipartFile upload, String CKEditorFuncNum, HttpServletRequest request, HttpServletResponse response) throws IOException {
    45. response.setContentType("text/html; charset=UTF-8");
    46. PrintWriter out = response.getWriter();
    47. try {
    48. String path = null;
    49. if (upload != null && !upload.isEmpty()) {
    50. String url = MultipartFileUtil.uploadFile("/cdn", upload, request);
    51. path = url;
    52. }
    53. // 返回“图像”选项卡并显示图片
    54. out.println("");
    55. } catch (RuntimeException e) {
    56. out.println("");
    57. }
    58. }
    59. }

    SysUserController

    1. package com.learn.controller;
    2. import com.learn.entity.SysUserEntity;
    3. import com.learn.service.SysUserRoleService;
    4. import com.learn.service.SysUserService;
    5. import com.learn.utils.PageUtils;
    6. import com.learn.utils.Query;
    7. import com.learn.utils.R;
    8. import com.learn.utils.ShiroUtils;
    9. import org.apache.commons.lang.ArrayUtils;
    10. import org.apache.shiro.crypto.hash.Sha256Hash;
    11. import org.springframework.beans.factory.annotation.Autowired;
    12. import org.springframework.web.bind.annotation.*;
    13. import java.util.List;
    14. import java.util.Map;
    15. /**
    16. * 系统用户
    17. *
    18. * @author chenshun
    19. * @email sunlightcs@gmail.com
    20. * @date 2018年10月31日 上午10:40:10
    21. */
    22. @RestController
    23. @RequestMapping("/sys/user")
    24. public class SysUserController extends AbstractController {
    25. @Autowired
    26. private SysUserService sysUserService;
    27. @Autowired
    28. private SysUserRoleService sysUserRoleService;
    29. /**
    30. * 所有用户列表
    31. */
    32. @RequestMapping("/list")
    33. public R list(@RequestParam Map params) {
    34. //查询列表数据
    35. Query query = new Query(params);
    36. List userList = sysUserService.queryList(query);
    37. int total = sysUserService.queryTotal(query);
    38. PageUtils pageUtil = new PageUtils(userList, total, query.getLimit(), query.getPage());
    39. return R.ok().put("page", pageUtil);
    40. }
    41. @RequestMapping("/list2")
    42. public R list2(@RequestParam Map params) {
    43. //查询列表数据
    44. Query query = new Query(params);
    45. List userList = sysUserService.queryList(query);
    46. return R.ok().put("list", userList);
    47. }
    48. /**
    49. * 获取登录的用户信息
    50. */
    51. @RequestMapping("/info")
    52. public R info() {
    53. return R.ok().put("user", this.sysUserService.queryObject(getUser().getUserId()));
    54. }
    55. /**
    56. * 修改登录用户密码
    57. */
    58. @RequestMapping("/password")
    59. public R password(String password, String newPassword) {
    60. //sha256加密
    61. password = new Sha256Hash(password).toHex();
    62. //sha256加密
    63. newPassword = new Sha256Hash(newPassword).toHex();
    64. //更新密码
    65. int count = sysUserService.updatePassword(getUserId(), password, newPassword);
    66. if (count == 0) {
    67. return R.error("原密码不正确");
    68. }
    69. //退出
    70. ShiroUtils.logout();
    71. return R.ok();
    72. }
    73. @RequestMapping("/updateInfo")
    74. public R updateInfo(@RequestBody SysUserEntity user) {
    75. this.sysUserService.update(user);
    76. return R.ok();
    77. }
    78. /**
    79. * 用户信息
    80. */
    81. @RequestMapping("/info/{userId}")
    82. public R info(@PathVariable("userId") Long userId) {
    83. SysUserEntity user = sysUserService.queryObject(userId);
    84. //获取用户所属的角色列表
    85. List roleIdList = sysUserRoleService.queryRoleIdList(userId);
    86. user.setRoleIdList(roleIdList);
    87. return R.ok().put("user", user);
    88. }
    89. /**
    90. * 保存用户
    91. */
    92. @RequestMapping("/save")
    93. public R save(@RequestBody SysUserEntity user) {
    94. user.setCreateUserId(getUserId());
    95. sysUserService.save(user);
    96. return R.ok();
    97. }
    98. /**
    99. * 修改用户
    100. */
    101. @RequestMapping("/update")
    102. public R update(@RequestBody SysUserEntity user) {
    103. user.setCreateUserId(getUserId());
    104. sysUserService.update(user);
    105. return R.ok();
    106. }
    107. /**
    108. * 删除用户
    109. */
    110. @RequestMapping("/delete")
    111. public R delete(@RequestBody Long[] userIds) {
    112. if (ArrayUtils.contains(userIds, 1L) || ArrayUtils.contains(userIds, -1L)) {
    113. return R.error("系统管理员不能删除");
    114. }
    115. if (ArrayUtils.contains(userIds, getUserId())) {
    116. return R.error("当前用户不能删除");
    117. }
    118. sysUserService.deleteBatch(userIds);
    119. return R.ok();
    120. }
    121. }

    SysRoleController

    1. package com.learn.controller;
    2. import com.learn.entity.SysRoleEntity;
    3. import com.learn.service.SysRoleMenuService;
    4. import com.learn.service.SysRoleService;
    5. import com.learn.utils.PageUtils;
    6. import com.learn.utils.Query;
    7. import com.learn.utils.R;
    8. import org.apache.shiro.authz.annotation.RequiresPermissions;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.web.bind.annotation.*;
    11. import java.util.HashMap;
    12. import java.util.List;
    13. import java.util.Map;
    14. /**
    15. * 角色管理
    16. *
    17. * @author chenshun
    18. * @email sunlightcs@gmail.com
    19. * @date 2018年11月8日 下午2:18:33
    20. */
    21. @RestController
    22. @RequestMapping("/sys/role")
    23. public class SysRoleController extends AbstractController {
    24. @Autowired
    25. private SysRoleService sysRoleService;
    26. @Autowired
    27. private SysRoleMenuService sysRoleMenuService;
    28. /**
    29. * 角色列表
    30. */
    31. @RequestMapping("/list")
    32. public R list(@RequestParam Map params){
    33. //如果不是超级管理员,则只查询自己创建的角色列表
    34. // if(getUserId() != Constant.SUPER_ADMIN){
    35. // params.put("createUserId", getUserId());
    36. // }
    37. //查询列表数据
    38. Query query = new Query(params);
    39. List list = sysRoleService.queryList(query);
    40. int total = sysRoleService.queryTotal(query);
    41. PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
    42. return R.ok().put("page", pageUtil);
    43. }
    44. /**
    45. * 角色列表
    46. */
    47. @RequestMapping("/select")
    48. public R select(){
    49. Map map = new HashMap<>();
    50. //如果不是超级管理员,则只查询自己所拥有的角色列表
    51. // if(getUserId() != Constant.SUPER_ADMIN){
    52. // map.put("createUserId", getUserId());
    53. // }
    54. List list = sysRoleService.queryList(map);
    55. return R.ok().put("list", list);
    56. }
    57. /**
    58. * 角色信息
    59. */
    60. @RequestMapping("/info/{roleId}")
    61. public R info(@PathVariable("roleId") Long roleId){
    62. SysRoleEntity role = sysRoleService.queryObject(roleId);
    63. //查询角色对应的菜单
    64. List menuIdList = sysRoleMenuService.queryMenuIdList(roleId);
    65. role.setMenuIdList(menuIdList);
    66. return R.ok().put("role", role);
    67. }
    68. /**
    69. * 保存角色
    70. */
    71. @RequestMapping("/save")
    72. public R save(@RequestBody SysRoleEntity role){
    73. role.setCreateUserId(getUserId());
    74. sysRoleService.save(role);
    75. return R.ok();
    76. }
    77. /**
    78. * 修改角色
    79. */
    80. @RequestMapping("/update")
    81. public R update(@RequestBody SysRoleEntity role){
    82. role.setCreateUserId(getUserId());
    83. sysRoleService.update(role);
    84. return R.ok();
    85. }
    86. /**
    87. * 删除角色
    88. */
    89. @RequestMapping("/delete")
    90. public R delete(@RequestBody Long[] roleIds){
    91. sysRoleService.deleteBatch(roleIds);
    92. return R.ok();
    93. }
    94. }

    如果也想学习本系统,下面领取。关注并回复:095ssm  

  • 相关阅读:
    论文阅读:Detecting, Explaining, and Mitigating Memorization in Diffusion Models
    WWDC 2024及其AI功能的引入对中国用户和开发者的影响
    py2neo代码封装
    神经网络的原理和应用,神经网络理论及应用
    面试官这一套 Framework 连环炮;看看你能撑到第几步?
    Web安全专业学习路线
    第77题. 组合
    Kubernetes——裸机搭建集群环境
    基础复习——数据库SQLite——SQL的基本语法——数据库管理器SQLiteDatabase——数据库帮助器SQLiteOpenHelper...
    大华相机C#学习之IDevice类
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126654495