Shudu Tianxiang Restaurant Management System Based on SSM

Get the source code at the end
Development language: Java
Java development tools: JDK1.8
Back-end framework: SSM
Front-end: Developed using JSP technology
Database: MySQL5.7 and Navicat management tools combined
Server: Tomcat8.5
Development software: IDEA / Eclipse
Maven project: yes


Table of contents

1. Project Introduction

2. Research background and significance

3. System project screenshots

3.1 Administrator function implementation

3.2 User function implementation

4. Core code

4.1 Login related

4.2 File upload

4.3 Packaging

5. System testing

5.1 Test Overview

5.2 Test results


1. Project Introduction

In recent years, the continuous rise of the information management industry has made people's daily lives increasingly inseparable from computers and Internet technology. First of all, based on the collected user demand analysis, we have a preliminary understanding of the design system and determine the overall functional modules of the Shudu Tianxiang Restaurant management system. Then, the main functional modules of the system are designed in detail, the relevant data information is stored in the database through the database design process, and then the relevant functional modules are coded and designed by using key development tools, such as MyEclipse development platform, JSP technology, etc. Then, we mainly use functional testing to test the system to find out problems existing in the system during operation and methods to solve the problems, and continuously improve and perfect the system design. Finally, the design and implementation process of the system introduced in this article is summarized, and future prospects for system development are proposed. The research and development of this system is of great significance. In terms of security, when users use a browser to access the website, relevant protection measures such as registration and password are used to improve the reliability of the system and maintain the security of the user's personal information and property. In terms of convenience, it promotes the informatization construction of the restaurant management industry and greatly facilitates relevant staff to manage restaurant information.


2. Research background and significance

The information management model is to gradually transform the work processes in the industry from manual services to information management services using computer technology. This management model has developed rapidly and is very simple and easy to use. Users do not even need to master relevant professional knowledge and can use the relevant systems normally according to tutorial guidance, so it is used by more and more users. Due to the informatization of management in related industries, management work is no longer limited by time and region, and relevant work tasks and results can be completed anytime and anywhere [1]. For now, management informatization is very popular in modern society and is widely used. As early as the late 1970s, early e-commerce appeared. Related companies used computers to establish dedicated internal networks, and completed corresponding purchasing, sales and other activities through the internal networks to speed up transactions between related companies. Improved work efficiency [2].

At present, many industries use Internet technology to informatize and digitize their work processes, which improves the service quality and efficiency of relevant personnel and saves human, financial, material and other resources in related industries. At the same time, people mainly rely on the Internet to obtain relevant information from the outside world. mainstream information technology and tools. People's demands for life are also constantly changing. In order to cope with the diverse needs of users, many related tertiary industries have emerged, and management informatization has gradually become popular, such as the e-commerce industry. By consulting a large amount of learning materials, I understand the basic background and key tasks of the basic development system, learn and master development technologies such as Java language, web technology, JSP technology, HTML language, etc., design system function modules, and related syntax and tools of MySQL database , create and store data tables, reflect and associate the mutual relationships between tables, and thus develop and implement the Shudu Tianxiang Restaurant management system.



3. System project screenshots

3.1 Administrator function implementation

Administrators can choose any browser to open the URL, enter the information correctly, and then exercise relevant management rights as an administrator.

Administrators can manage related user information records by selecting user management, such as viewing user accounts, modifying user names, etc.

 

Administrators can manage related type information records by selecting type management, such as adding dish types, viewing package types, modifying beverage types, etc.

 

Administrators can manage related dish information records by selecting dish management, such as viewing dish names, viewing detailed information, modifying prices, etc.

 

Administrators can manage related private room information records by selecting private room management, such as viewing private room names, querying private room information, modifying private room deposits, etc.

 

Administrators can manage related system information by selecting system management, such as customer service management, carousel chart management, activity consultation and viewing, etc.

 

 

 

3.2 User function implementation

When users open this system in a browser, they can view event information, reserve private rooms, view menu information, etc.

Users can select private room reservations and reserve related private room information, such as viewing private room details, booking private rooms, and evaluating private rooms, etc.

 

Users can view related dish information records by selecting dish information, such as viewing dish names, adding dishes to the shopping cart, and purchasing dishes immediately.

 

Users can manage personal-related information by selecting the personal center, such as viewing personal information, viewing personal orders, and managing personal collections.

 


4. Core code

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

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

4.3 Packaging

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. System testing

5.1 Test Overview

Before the system is put into use, an essential part of the work that needs to be done is system testing. Through system testing, testers verify whether the interface environment is clean and friendly during use of the system, whether user account information is safe and reliable, whether performance is stable and robust, and whether functions meet user needs, etc. System testing not only needs to find out the problems that will occur during system operation, but also needs to analyze the causes of these problems and find ways to solve them [21].

System testing is mainly divided into black box testing and white box testing [22]. Black box testing is functional testing, which mainly tests the system from the user's perspective. During the black box testing process, testers do not need to pay attention to and understand the internal code of the system, and run and detect system functions according to the system's program interface. White box testing is structural testing, which mainly tests the system from the perspective of the programmer. Different from black box testing, white box testing is a code-based testing process. Testers need to understand the internal code of the system and confirm whether the actual system program status, logical path, etc. are consistent with the expected results. Whether the design content complies with the specifications.

5.2 Test results

This system mainly uses functional testing methods to test the system functional effects.

 

The test environment is to use a computer or notebook with low configuration, configure the operating system environment of Windows 7 or higher, enter the system URL in the browser, if the homepage of the system can be accessed normally, it means that the system can be successful. carry out testing. In short, according to the above related system test content, the test results of this system are relatively smooth, the system performance is relatively stable, and there are basically no problems. 

Guess you like

Origin blog.csdn.net/weixin_52721608/article/details/132758882
Recommended