Design and implementation of restaurant ordering management system based on SSM

Get the source code at the end
Development language: Java
Java development tool: JDK1.8
Back-end framework: SSM
Front-end: developed using Vue technology
Database: MySQL5.7 combined with Navicat management tools
Server: Tomcat8.5
Development software: IDEA/Eclipse
Whether it is a Maven project: yes


Table of contents

1. Project Introduction

2. System functions

3. System project screenshots

food inventory management

Dishes display management

Unreserved table management

In-store flow management

paid order

Dishes information

shopping cart

Submit Order

paid order

Contact Customer Service

Ordering dishes

No table reservation

Table reserved

Order record

4. Core code

Login related

File Upload

encapsulation


1. Project Introduction

Since the development of network technology and computer technology, it has a profound theoretical foundation and has been fully used in reality. In particular, software based on computer operation has attracted attention from all walks of life. In addition, people have now entered the information age, so the promotion and management of information is very critical. Therefore, it is necessary to computerize and systematize the management of restaurant ordering information. Designing and developing a restaurant ordering management system will not only save manpower and management costs, but also safely store a huge amount of data. It does not take a lot of time to maintain and retrieve restaurant ordering information, which is very convenient.

The restaurant ordering management system establishes a data table in MySQL to save information, and is written using the Vue framework and Java language. And design and implement according to the software design and development process. The system is user-friendly and fully functional. Its administrator manages food inventory, dish information, manages reserved and unreserved tables, manages in-store order flow and takeaway orders. Users can view restaurant information, collect dishes, place orders for dishes, and view takeout orders. Users can also reserve a table in the restaurant, order dishes, and view in-store order records.

While the restaurant ordering management system standardizes restaurant ordering information, it can also promptly detect erroneous data through the validity rules of data input, allowing data entry to achieve accuracy, thereby improving the data provided by the restaurant ordering management system. The reliability minimizes the error rate of system data.


2. System functions

The function formulation of this system strictly refers to the user's requirements, but when designing this system, it must also meet the design requirements of easy operation and convenient use. Therefore, to design a system that is standardized and meets user needs, the following system goals must be achieved.

The first system goal: The operation mode between the user and the system is based on human-computer dialogue. The design of the visual interface is not only beautiful but also friendly. The various types of information provided by the visual interface meet the requirements of accuracy and reliability, and can be easily viewed by users flexibly.

The second system goal: the data generated by the interaction between users and the system must be stored in the database in a strict and standardized manner. Whether it is searched and managed by later managers, data security must be ensured.

The third system goal: realize the functions required by users. Based on the functional requirements derived from user surveys, the design and implementation of the restaurant ordering management system are completed.

The fourth system goal: In necessary links, check the data registered by users, including checking the data length, data input type, etc., provide timely feedback when errors are found, and guide users to standardize registration data. Common data verification includes password modification, registration and login, filling in user information and other aspects.

The fifth system goal: The design and development of this system requires the greatest efforts. In addition to the easy operation of the system, it is also required that the system be easy to maintain during later use, so that the system can be easy to maintain.

The sixth system goal: When this system is delivered to users, it can achieve the goal of stable operation. In addition, the system is safe and meets the conditions of reliability, so users can use it with confidence.

The functional analysis done above is only a general function of this system. This part requires detailed design of each module on this basis.

The detailed functions of the designed administrator are shown in the figure below. After the administrator logs in and enters his backend, he can manage food inventory, dish information, manage reserved and unbooked tables, and manage in-store order flow and takeout orders.

The detailed functions of the designed user are shown in the figure below. Users can view restaurant information, collect dishes, place orders for dishes, and view takeout orders. Users can also reserve a table in the restaurant, order dishes, and view in-store order records.



3. System project screenshots

food inventory management

The operation effect of food inventory management under administrator authority is shown in the figure below. The administrator can check the inventory quantity of various dishes, query the dish inventory according to the dish name, modify the dish inventory, and delete the dish inventory information.

Dishes display management

The operation effect of the dish display management in the administrator's rights is shown in the figure below. The administrator adds dish information, can modify the dish name, dish pictures, dish unit price and other information, and can delete the dish information.

 

Unreserved table management

The operation effect of unreserved table management in administrator rights is shown in the figure below. The administrator can query the unbooked table information based on the table name, and can modify or delete the unbooked table information.

 

In-store flow management

The operation effect of in-store flow management under administrator authority is shown in the figure below. The administrator queries the in-store transaction information and sets the paid status of the user's paid orders.

 

paid order

The operation effect of paid order management in administrator rights is shown in the figure below. When a user orders food at the front desk, the administrator needs to deliver the paid food order on the current page.

 

Dishes information

The operation effect of the dish information in user permissions is shown in the figure below. There are many functions that users can operate on this page. They can collect the dishes displayed on this page, purchase them directly, or temporarily add them to the shopping cart to save the dishes.

 

shopping cart

The operation effect of the shopping cart in user permissions is shown in the figure below. The shopping cart helps users temporarily save the purchased dishes, making it convenient for users to place an order for multiple dishes at once.

 

Submit Order

The operation effect of submitting orders in user permissions is shown in the figure below. Before the user places an order for payment, the delivery address and purchased dishes need to be verified again, and the order is finally paid.

 

paid order

The operating effect of paid orders in user permissions is shown in the figure below. Users can check the order details and choose to refund certain dishes purchased by mistake.

 

Contact Customer Service

Contact customer service in user permissions, its operation effect is shown in the figure below. Users can consult customer service if they encounter any problems during the operation of the restaurant ordering management system, and the customer service will be responsible for answering the user's questions.

 

Ordering dishes

The operation effect of ordering dishes in user permissions is shown in the figure below. When the user has reserved a table, he can register the order quantity of the required dishes on this page, and finally submit the order.

 

No table reservation

The operation effect of unbooked tables in user permissions is shown in the figure below. The user selects an unbooked table to make a reservation.

 

Table reserved

The operation effect of the reserved table in user permissions is shown in the figure below. Users can view reserved table information and cancel reserved tables.

 

Order record

The operation effect of the order record in user permissions is shown in the figure below. The user views the order details consumed at the restaurant.

 


4. Core code

Login related


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();
    }
}

File Upload

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);
	}
	
}

encapsulation

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;
	}
}

Guess you like

Origin blog.csdn.net/weixin_52721608/article/details/133530629