作者主页:夜未央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/ 登录

- package com.learn.controller;
-
- import com.learn.utils.ShiroUtils;
- import com.learn.entity.SysUserEntity;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
-
- /**
- * Controller公共组件
- *
- * @author chenshun
- * @email sunlightcs@gmail.com
- * @date 2018年11月9日 下午9:42:26
- */
- public abstract class AbstractController {
- protected Logger logger = LoggerFactory.getLogger(getClass());
-
- protected SysUserEntity getUser() {
- return ShiroUtils.getUserEntity();
- }
-
- protected Long getUserId() {
- return getUser().getUserId();
- }
- }
- package com.learn.controller;
-
- import java.util.List;
- import java.util.Map;
-
- import org.apache.shiro.authz.annotation.RequiresPermissions;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
-
- import com.learn.entity.ZuoyeEntity;
- import com.learn.service.ZuoyeService;
- import com.learn.utils.PageUtils;
- import com.learn.utils.Query;
- import com.learn.utils.R;
-
-
- /**
- * 作业信息
- *
- * @author chenshun
- * @email sunlightcs@gmail.com
- * @date 2020-04-01 16:42:55
- */
- @RestController
- @RequestMapping("zuoye")
- public class ZuoyeController extends AbstractController {
- @Autowired
- private ZuoyeService zuoyeService;
-
- /**
- * 列表
- */
- @RequestMapping("/list")
- public R list(@RequestParam Map
params) { -
- if (super.getUserId() > 1)
- params.put("user", super.getUserId());
-
-
- //查询列表数据
- Query query = new Query(params);
-
- List
zuoyeList = zuoyeService.queryList(query); - int total = zuoyeService.queryTotal(query);
-
- PageUtils pageUtil = new PageUtils(zuoyeList, total, query.getLimit(), query.getPage());
-
- return R.ok().put("page", pageUtil);
- }
-
-
- /**
- * 列表
- */
- @RequestMapping("/list2")
- public R list2(@RequestParam Map
params) { - Query query = new Query(params);
- List
zuoyeList = zuoyeService.queryList(query); - return R.ok().put("list", zuoyeList );
- }
-
-
- /**
- * 信息
- */
- @RequestMapping("/info/{id}")
- public R info(@PathVariable("id") Long id){
- ZuoyeEntity zuoye = zuoyeService.queryObject(id);
-
- return R.ok().put("zuoye", zuoye);
- }
-
- /**
- * 保存
- */
- @RequestMapping("/save")
- public R save(@RequestBody ZuoyeEntity zuoye){
-
- if (zuoye.getUser() == null)
- zuoye.setUser(super.getUserId());
-
-
- zuoyeService.save(zuoye);
-
- return R.ok();
- }
-
- /**
- * 修改
- */
- @RequestMapping("/update")
- public R update(@RequestBody ZuoyeEntity zuoye){
- zuoyeService.update(zuoye);
-
- return R.ok();
- }
-
- /**
- * 删除
- */
- @RequestMapping("/delete")
- public R delete(@RequestBody Long[] ids){
- zuoyeService.deleteBatch(ids);
-
- return R.ok();
- }
-
- }
- package com.learn.controller;
-
- import com.learn.utils.MultipartFileUtil;
- import com.learn.utils.R;
- import com.learn.utils.RRException;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.RestController;
- import org.springframework.web.multipart.MultipartFile;
-
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.io.PrintWriter;
-
-
- /**
- * 文件上传
- *
- * @author shenyt
- * @email syt12322@163.com
- * @date 2020-03-25 12:13:26
- */
- @RestController
- @RequestMapping("file")
- public class UploadController {
-
- public static String[] suffixs = {"IMG", "PNG", "JPG", "JPEG", "GIF", "BPM"};
-
- /**
- * 上传文件
- */
- @RequestMapping("/upload")
- public R upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception {
- if (file.isEmpty()) {
- throw new RRException("上传文件不能为空");
- }
- String url = MultipartFileUtil.uploadFile("/cdn", file, request);
- return R.ok().put("url", "/ssm_xueyeyujing_sys/"+url);
- }
-
-
- /**
- * 上传资讯内容的图片
- *
- * @param upload 图片
- * @param response 响应
- */
- @ResponseBody
- @RequestMapping("ckEditorUpload")
- public void uploadFile(MultipartFile upload, String CKEditorFuncNum, HttpServletRequest request, HttpServletResponse response) throws IOException {
-
- response.setContentType("text/html; charset=UTF-8");
- PrintWriter out = response.getWriter();
- try {
-
- String path = null;
-
- if (upload != null && !upload.isEmpty()) {
-
- String url = MultipartFileUtil.uploadFile("/cdn", upload, request);
- path = url;
- }
-
-
- // 返回“图像”选项卡并显示图片
- out.println("");
-
- } catch (RuntimeException e) {
- out.println("");
- }
- }
-
-
- }
- package com.learn.controller;
-
- import com.learn.entity.SysUserEntity;
- import com.learn.service.SysUserRoleService;
- import com.learn.service.SysUserService;
- import com.learn.utils.PageUtils;
- import com.learn.utils.Query;
- import com.learn.utils.R;
- import com.learn.utils.ShiroUtils;
- import org.apache.commons.lang.ArrayUtils;
- import org.apache.shiro.crypto.hash.Sha256Hash;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
-
- import java.util.List;
- import java.util.Map;
-
- /**
- * 系统用户
- *
- * @author chenshun
- * @email sunlightcs@gmail.com
- * @date 2018年10月31日 上午10:40:10
- */
- @RestController
- @RequestMapping("/sys/user")
- public class SysUserController extends AbstractController {
- @Autowired
- private SysUserService sysUserService;
- @Autowired
- private SysUserRoleService sysUserRoleService;
-
- /**
- * 所有用户列表
- */
- @RequestMapping("/list")
- public R list(@RequestParam Map
params) { -
- //查询列表数据
- Query query = new Query(params);
- List
userList = sysUserService.queryList(query); - int total = sysUserService.queryTotal(query);
-
- PageUtils pageUtil = new PageUtils(userList, total, query.getLimit(), query.getPage());
-
- return R.ok().put("page", pageUtil);
- }
-
- @RequestMapping("/list2")
- public R list2(@RequestParam Map
params) { -
- //查询列表数据
- Query query = new Query(params);
- List
userList = sysUserService.queryList(query); -
- return R.ok().put("list", userList);
- }
-
- /**
- * 获取登录的用户信息
- */
- @RequestMapping("/info")
- public R info() {
- return R.ok().put("user", this.sysUserService.queryObject(getUser().getUserId()));
- }
-
- /**
- * 修改登录用户密码
- */
- @RequestMapping("/password")
- public R password(String password, String newPassword) {
-
- //sha256加密
- password = new Sha256Hash(password).toHex();
- //sha256加密
- newPassword = new Sha256Hash(newPassword).toHex();
-
- //更新密码
- int count = sysUserService.updatePassword(getUserId(), password, newPassword);
- if (count == 0) {
- return R.error("原密码不正确");
- }
-
- //退出
- ShiroUtils.logout();
-
- return R.ok();
- }
-
- @RequestMapping("/updateInfo")
- public R updateInfo(@RequestBody SysUserEntity user) {
- this.sysUserService.update(user);
- return R.ok();
- }
-
- /**
- * 用户信息
- */
- @RequestMapping("/info/{userId}")
- public R info(@PathVariable("userId") Long userId) {
- SysUserEntity user = sysUserService.queryObject(userId);
-
- //获取用户所属的角色列表
- List
roleIdList = sysUserRoleService.queryRoleIdList(userId); - user.setRoleIdList(roleIdList);
-
- return R.ok().put("user", user);
- }
-
- /**
- * 保存用户
- */
- @RequestMapping("/save")
- public R save(@RequestBody SysUserEntity user) {
-
- user.setCreateUserId(getUserId());
- sysUserService.save(user);
-
- return R.ok();
- }
-
- /**
- * 修改用户
- */
- @RequestMapping("/update")
- public R update(@RequestBody SysUserEntity user) {
-
- user.setCreateUserId(getUserId());
- sysUserService.update(user);
-
- return R.ok();
- }
-
- /**
- * 删除用户
- */
- @RequestMapping("/delete")
- public R delete(@RequestBody Long[] userIds) {
- if (ArrayUtils.contains(userIds, 1L) || ArrayUtils.contains(userIds, -1L)) {
- return R.error("系统管理员不能删除");
- }
-
- if (ArrayUtils.contains(userIds, getUserId())) {
- return R.error("当前用户不能删除");
- }
-
- sysUserService.deleteBatch(userIds);
-
- return R.ok();
- }
- }
- package com.learn.controller;
-
- import com.learn.entity.SysRoleEntity;
- import com.learn.service.SysRoleMenuService;
- import com.learn.service.SysRoleService;
- import com.learn.utils.PageUtils;
- import com.learn.utils.Query;
- import com.learn.utils.R;
- import org.apache.shiro.authz.annotation.RequiresPermissions;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
-
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- /**
- * 角色管理
- *
- * @author chenshun
- * @email sunlightcs@gmail.com
- * @date 2018年11月8日 下午2:18:33
- */
- @RestController
- @RequestMapping("/sys/role")
- public class SysRoleController extends AbstractController {
- @Autowired
- private SysRoleService sysRoleService;
- @Autowired
- private SysRoleMenuService sysRoleMenuService;
-
- /**
- * 角色列表
- */
- @RequestMapping("/list")
- public R list(@RequestParam Map
params) { - //如果不是超级管理员,则只查询自己创建的角色列表
- // if(getUserId() != Constant.SUPER_ADMIN){
- // params.put("createUserId", getUserId());
- // }
-
- //查询列表数据
- Query query = new Query(params);
- List
list = sysRoleService.queryList(query); - int total = sysRoleService.queryTotal(query);
-
- PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
-
- return R.ok().put("page", pageUtil);
- }
-
- /**
- * 角色列表
- */
- @RequestMapping("/select")
- public R select(){
- Map
map = new HashMap<>(); -
- //如果不是超级管理员,则只查询自己所拥有的角色列表
- // if(getUserId() != Constant.SUPER_ADMIN){
- // map.put("createUserId", getUserId());
- // }
- List
list = sysRoleService.queryList(map); -
- return R.ok().put("list", list);
- }
-
- /**
- * 角色信息
- */
- @RequestMapping("/info/{roleId}")
- public R info(@PathVariable("roleId") Long roleId){
- SysRoleEntity role = sysRoleService.queryObject(roleId);
-
- //查询角色对应的菜单
- List
menuIdList = sysRoleMenuService.queryMenuIdList(roleId); - role.setMenuIdList(menuIdList);
-
- return R.ok().put("role", role);
- }
-
- /**
- * 保存角色
- */
- @RequestMapping("/save")
- public R save(@RequestBody SysRoleEntity role){
-
- role.setCreateUserId(getUserId());
- sysRoleService.save(role);
-
- return R.ok();
- }
-
- /**
- * 修改角色
- */
- @RequestMapping("/update")
- public R update(@RequestBody SysRoleEntity role){
-
- role.setCreateUserId(getUserId());
- sysRoleService.update(role);
-
- return R.ok();
- }
-
- /**
- * 删除角色
- */
- @RequestMapping("/delete")
- public R delete(@RequestBody Long[] roleIds){
- sysRoleService.deleteBatch(roleIds);
-
- return R.ok();
- }
- }
如果也想学习本系统,下面领取。关注并回复:095ssm