基于SSM的蜀都天香酒楼管理系统

末尾获取源码

开发语言:Java

Java开发工具:JDK1.8

后端框架:SSM

前端:采用JSP技术开发

数据库:MySQL5.7和Navicat管理工具结合

服务器:Tomcat8.5

开发软件:IDEA / Eclipse

是否Maven项目:是


目录

一、项目简介

二、研究背景与意义

三、系统项目截图

3.1管理员功能实现

3.2用户功能实现

四、核心代码

4.1登录相关

4.2文件上传

4.3封装

五、系统测试

5.1测试概述

5.2测试结果


一、项目简介

近年来,信息化管理行业的不断兴起,使得人们的日常生活越来越离不开计算机和互联网技术。首先,根据收集到的用户需求分析,对设计系统有一个初步的认识与了解,确定蜀都天香酒楼管理系统的总体功能模块。然后,详细设计系统的主要功能模块,通过数据库设计过程将相关的数据信息存储到数据库中,再通过使用关键的开发工具,如MyEclipse开发平台、JSP技术等,编码设计相关的功能模块。接着,主要采用功能测试的方式对系统进行测试,找出系统在运行过程中存在的问题,以及解决问题的方法,不断地改进和完善系统的设计。最后,总结本文介绍的系统的设计和实现过程,并且针对于系统的开发提出未来的展望工作。本系统的研发具有重大的意义,在安全性方面,用户使用浏览器访问网站时,采用注册和密码等相关的保护措施,提高系统的可靠性,维护用户的个人信息和财产的安全。在方便性方面,促进了酒楼管理行业的信息化建设,极大的方便了相关的工作人员对酒楼信息进行管理。


二、研究背景与意义

信息化管理模式是将行业中的工作流程由人工服务,逐渐转换为使用计算机技术的信息化管理服务。这种管理模式发展迅速,使用起来非常简单容易,用户甚至不用掌握相关的专业知识,根据教程指导即可正常使用相关的系统,因而被越来越多的用户所使用。由于相关行业管理信息化,这就使得管理工作不在受到时间和区域的限制,随时随地即可完成相关的工作任务和结果[1]。就目前而言,管理信息化在现代社会中非常流行,使用比较广泛。早在20世纪70年代末,就出现了早期的电子商务,相关的公司企业使用计算机建立专用的内部网络,通过内部网络完成相应的采购、销售等活动,加快相关的企业之间的交易速度,提高了工作效率[2]。

当下,许多行业采用互联网技术将工作流程信息化、数字化,提高了相关人员的服务质量和效率,节约了相关行业的人力、财力、物力等资源,与此同时,人们获取外界的相关信息主要依赖于主流的信息化技术和工具。人们对生活的需求也在不断的发生着变化,为了应对用户的多样化需求,许多相关的第三产业应运而生,管理信息化也逐渐的流行起来,比如电子商务行业。本人通过查询大量学习资料,了解基本的开发系统的基本背景和关键任务,学习与掌握Java语言、web技术、JSP技术、HTML语言等开发技术,设计系统功能模块,以及MySQL数据库的相关语法和工具,创建和存储数据表格,反映和关联表格之间相互存在的关系,由此对蜀都天香酒楼管理系统进行研发和实现。


三、系统项目截图

3.1管理员功能实现

管理员可以选择任一浏览器打开网址,输入信息无误后,以管理员的身份行使相关的管理权限

管理员可以通过选择用户管理,管理相关的用户信息记录,比如进行用户账号查看,用户名称修改等操作

管理员可以通过选择类型管理,管理相关的类型信息记录,比如进行菜品类型添加,套餐类型查看,饮料类型修改等操作

管理员可以通过选择菜品管理,管理相关的菜品信息记录,比如进行菜品名称查看,详情信息查看,价格修改等操作

管理员通过选择包间管理,管理相关的包间信息记录,比如进行包间名称查看,包间信息查询,包间定金修改等操作

管理员通过选择系统管理,管理相关的系统信息,比如进行客服管理,轮播图管理,活动咨询查看等操作

3.2用户功能实现

用户在浏览器中打开本系统,可以进行活动咨讯查看,包间预定,菜品信息查看等操作

用户可以通过选择包间预定,预定相关的包间信息,比如进行包间详情信息查看,包间预定,包间评价等操作

用户可以通过选择菜品信息,查看相关的菜品信息记录,比如进行菜品名称查看,添加菜品到购物车,立即购买菜品等操作

用户可以通过选择个人中心,管理与个人相关的信息,比如进行个人资料查看,个人订单查看,个人收藏管理等操作


四、核心代码

4.1登录相关

java 复制代码
package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.RequestBody;
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 com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

4.2文件上传

java 复制代码
package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
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 org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

4.3封装

java 复制代码
package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

五、系统测试

5.1测试概述

在系统将要投入使用前,需要进行的一个必不可少的工作环节就是系统测试。测试人员通过系统测试工作,验证在系统的使用过程中,界面环境是否整洁友好,用户账号信息是否安全可靠,性能方面是否稳定健壮,功能方面是否符合用户需要等。系统测试不仅需要找出系统运行中会出现的问题,还需要分析产生这些问题的原因,并且找到解决这些问题的方法[21]。

系统测试主要分为黑盒测试和白盒测试[22]。黑盒测试即功能测试,其主要是站在使用者的角度对系统进行测试。在黑盒测试过程中,测试人员无需关注和了解系统内部的代码等内容,根据系统的程序接口,运行和检测系统功能。白盒测试即结构测试,其主要是站在程序员的角度对系统进行测试。与黑盒测试不同,白盒是一种基于代码的测试过程,测试人员需要了解系统内部的代码等内容,通过检测实际的系统程序状态、逻辑路径等情况与预期达到的结果是否一致,确认系统的设计内容是否符合规范。

5.2测试结果

本系统主要使用功能测试的方法,测试系统功能效果。

测试环境是使用一台配置不高的电脑或者笔记本,配置Windows 7或者更高版本的操作系统环境,在浏览器中输入本系统网址,如果能正常访问本系统的首页,说明本系统可以成功的进行测试。总之,根据以上相关的系统测试内容显示,本系统的测试结果比较顺利,系统性能比较稳定,基本上没有出现问题。

相关推荐
小筱在线几秒前
SpringCloud微服务实现服务熔断的实践指南
java·spring cloud·微服务
luoluoal5 分钟前
java项目之基于Spring Boot智能无人仓库管理源码(springboot+vue)
java·vue.js·spring boot
ChinaRainbowSea10 分钟前
十三,Spring Boot 中注入 Servlet,Filter,Listener
java·spring boot·spring·servlet·web
小游鱼KF13 分钟前
Spring学习前置知识
java·学习·spring
扎克begod17 分钟前
JAVA并发编程系列(9)CyclicBarrier循环屏障原理分析
java·开发语言·python
青灯文案118 分钟前
SpringBoot 项目统一 API 响应结果封装示例
java·spring boot·后端
我就是程序猿28 分钟前
tomcat的配置
java·tomcat
阳光阿盖尔34 分钟前
EasyExcel的基本使用——Java导入Excel数据
java·开发语言·excel
二十雨辰36 分钟前
[苍穹外卖]-12Apache POI入门与实战
java·spring boot·mybatis
程序员皮皮林36 分钟前
开源PDF工具 Apache PDFBox 认识及使用(知识点+案例)
java·pdf·开源·apache