1 Basic training information
1.1 Name of training project
"Takeaway ordering" system.
1.2 Training time and place
2 Introduction to training content
This project ("Takeaway Ordering" system) is a software product specially customized for catering enterprises (restaurants, restaurants), including two parts: the system management background and the mobile terminal application.
Among them, the system management background is mainly provided for the internal staff of the catering company, which can manage and maintain the dishes, set meals, orders, etc. of the restaurant. Mobile applications are mainly provided to consumers, who can browse dishes online, add shopping carts, place orders, etc.
3 Demand Analysis
3.1 Software and hardware conditions
IDEA 2021.2.3
MySQL 5.5
MyBatis
MyBatisPlus
Git: version control tool.
Maven: 3.6.1
Junit: A unit testing tool.
3.2 Technical Feasibility
3.2.1 Technical requirements
Functions such as takeout ordering, payment, order management, and delivery are essential technical requirements for St. Regis Takeout. In addition, functions such as user registration, login, feedback, and recommendation also need to be provided.
3.2.2 Market demand
The demand in the food delivery market is huge, but the competition is also very fierce. Market segmentation should be carried out, and differentiated business models and target users should be identified, while providing differentiated services and experiences.
3.2.3 Development costs
The cost of developing the St. Regis food delivery application should be evaluated, including technical design, software engineering, mobile application development, data analysis, etc.
3.2.4 Data Connectivity
The food delivery application needs to connect with the applications of multiple delivery and payment providers to ensure the smooth delivery of orders and the correct processing of payments.
3.2.5 User Experience
A good user experience is an important element of being appreciated and remembered by users. In the food delivery application, the user experience includes many aspects such as ease of use, speed, accuracy, and convenience.
4 functional design
4.1 Management terminal
4.1.1 Login/logout
Internal employees must log in before they can access the system management background.
4.1.2 Employee Management
Administrators can manage employee information in the background of the system, including query, add, edit, disable and other functions.
4.1.3 Category management
It mainly manages and maintains the classification of dishes or set meals operated by the current restaurant, including functions such as query, addition, modification, and deletion.
4.1.4 Dishes management
Mainly maintain the dish information under each category, including query, add, modify, delete, start selling, stop selling and other functions.
4.1.5 Package Management
Mainly maintain the package information in the current restaurant, including query, add, modify, delete, start selling, stop selling and other functions.
4.1.6 Order Details
Mainly maintain the order information placed by the user on the mobile terminal, including functions such as query, cancellation, delivery, completion, and order report download.
4.2 Client
4.2.1 Login/logout
On the mobile side, users also need to log in and use the APP to order food.
4.2.2 Order-Menu
In the ordering interface, it is necessary to display the category of dishes/sets, and load the information of the dishes in it according to the currently selected category for users to query and select.
4.2.3 Order-Shopping Cart
The dishes selected by the user will be added to the user's shopping cart, which mainly includes functions such as querying the shopping cart, adding to the shopping cart, deleting the shopping cart, and emptying the shopping cart.
4.2.4 Order payment
After the user selects the dishes/sets, he can settle and pay for the dishes in the shopping cart, and at this time, he needs to pay for the order.
4.2.5 Personal information
The basic information of the current user will be displayed on the personal center page, and the user can manage the delivery address and query historical order data.
5 Database design
user table
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Name |
varchar(50) |
no |
no |
no |
Name |
Phone |
varchar(100) |
no |
no |
no |
Phone number |
Sex |
varchar(2) |
no |
no |
no |
gender |
Id_number |
varchar(18) |
no |
no |
no |
ID number |
Avatar Status |
varchar(500) int(11) |
no no |
no no |
no no |
avatar state |
shopping cart table
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Name |
varchar(50) |
no |
no |
no |
name |
Image |
varchar(100) |
no |
no |
no |
picture |
User_id |
bigint(20) |
no |
no |
no |
User ID |
Dish_Id |
bigint(20) |
no |
no |
no |
dish ID |
Setmeal_Id DishFlavor |
bigint(20)varchar(50) |
no no |
no no |
no no |
Package ID taste |
Number |
int(11) |
no |
no |
no |
quantity |
Amount CreateTime |
decimal(10) datetime |
no no |
no no |
no no |
the amount creation time |
address book form
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
User_Id |
bigint(20) |
no |
no |
no |
User ID |
Consignee |
varchar(50) |
no |
no |
no |
Receiver |
Sex |
tinyint(4) |
no |
no |
no |
gender |
Phone Province |
varchar(11) varchar(12) |
no no |
no no |
no no |
Phone number Provincial number |
Province |
Varchar(32) |
no |
no |
no |
Provincial name |
City_code City_name |
varchar(12) varchar(32) |
no no |
no no |
no no |
Municipal number Municipal name |
District |
varchar(12) |
no |
no |
no |
District code |
District |
varchar(32) |
no |
no |
no |
district name |
Detail |
varchar(200) |
no |
no |
no |
Address |
Label |
varchar(100) |
no |
no |
no |
Label |
Is_default |
tinyint(1) |
no |
no |
no |
Is it the default |
Createtime |
datetime |
no |
no |
no |
creation time |
Updatetime |
datetime |
no |
no |
no |
update time |
Createuser |
Bigint(20) |
no |
no |
no |
creator |
Updateuser |
Bigint(20) |
no |
no |
no |
editor |
Is_deleted |
int(11) |
no |
no |
no |
delete or not |
classification table
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Type |
int(11) |
no |
no |
no |
type |
Name |
varchar(64) |
no |
no |
no |
name |
Sort |
int(11) |
no |
no |
no |
order |
CreateTime UpdateTime |
datetime datetime |
no no |
no no |
no no |
creation time update time |
Createuser |
bigint(20) |
no |
no |
no |
creator |
Updateuser |
bigint(20) |
no |
no |
no |
editor |
Menu
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Name |
varchar(64) |
no |
no |
no |
dish name |
CategoryId |
bigint(20) |
no |
no |
no |
Dishes category ID |
Price |
decimal(10) |
no |
no |
no |
dish price |
Code |
varchar(64) |
no |
no |
no |
commodity code |
Image Descripte |
varchar(200) varchar(400) |
no no |
no no |
no no |
picture Description |
Status |
int(11) |
no |
no |
no |
status code |
Sort |
int(11) |
no |
no |
no |
order |
CreateTime UpdateTime |
datetime datetime |
no no |
no no |
no no |
creation time update time |
Createuser |
Bigint(20) |
no |
no |
no |
creator |
Updateuser |
Bigint(20) |
no |
no |
no |
editor |
Is_deleted |
int(11) |
no |
no |
no |
delete or not |
taste chart
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Dish_Id |
bigint(20) |
no |
no |
no |
dish ID |
Name |
varchar(64) |
no |
no |
no |
flavor name |
Value |
varchar(500) |
no |
no |
no |
taste data |
CreateTime UpdateTime |
datetime datetime |
no no |
no no |
no no |
creation time update time |
Createuser |
Bigint(20) |
no |
no |
no |
creator |
Updateuser |
Bigint(20) |
no |
no |
no |
editor |
Is_deleted |
int(11) |
no |
no |
no |
delete or not |
employee form
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Name |
varchar(32) |
no |
no |
no |
Name |
Username |
varchar(32) |
no |
no |
no |
username |
Password |
varchar(64) |
no |
no |
no |
password |
Phone |
varchar(11) |
no |
no |
no |
Phone number |
Sex |
varchar(2) |
no |
no |
no |
gender |
Id_Number |
varchar(18) |
no |
no |
no |
ID number |
Status |
Int(11) |
no |
no |
no |
state |
CreateTime UpdateTime |
datetime datetime |
no no |
no no |
no no |
creation time update time |
Createuser |
Bigint(20) |
no |
no |
no |
creator |
Updateuser |
Bigint(20) |
no |
no |
no |
editor |
order form
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Number |
varchar(50) |
no |
no |
no |
order number |
Status |
Int(11) |
no |
no |
no |
Order Status |
User_Id |
bigint(20) |
no |
no |
no |
Order user |
Address_id |
bigint(20) |
no |
no |
no |
Address ID |
Order_Time CheckTime |
datetime datetime |
no no |
no no |
no no |
order time checkout time |
Pay_method |
int(11) |
no |
no |
no |
payment method |
Amount |
decimal(10) |
no |
no |
no |
Amount received |
Remark |
varchar(100) |
no |
no |
no |
Remark |
Phone |
varchar(255) |
no |
no |
no |
Phone number |
Address |
varchar(255) |
no |
no |
no |
user address |
User_name |
varchar(255) |
no |
no |
no |
username |
Consignee |
varchar(255) |
no |
no |
no |
Receiver |
Order Details Form
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
Name |
varchar(50) |
no |
no |
no |
name |
Image |
varchar(100) |
no |
no |
no |
picture |
Order_Id |
bigint(20) |
no |
no |
no |
order ID |
Dish_Id |
bigint(20) |
no |
no |
no |
dish ID |
Setmeal_Id DishFlavor |
bigint(20) varchar(50) |
no no |
no no |
no no |
Package ID taste |
Number |
int(11) |
no |
no |
no |
quantity |
Amount |
decimal(10) |
no |
no |
no |
the amount |
Package table
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
CategoryId |
bigint(20) |
no |
no |
no |
Category ID |
Name |
varchar(64) |
no |
no |
no |
package name |
Price |
decimal(10) |
no |
no |
no |
package price |
Status |
Int(11) |
no |
no |
no |
state |
Code |
varchar(32) |
no |
no |
no |
coding |
Descripte |
varchar(512) |
no |
no |
no |
Description |
Image |
varchar(255) |
no |
no |
no |
picture |
CreateTime UpdateTime |
datetime datetime |
no no |
no no |
no no |
creation time update time |
Createuser |
Bigint(20) |
no |
no |
no |
creator |
Updateuser |
Bigint(20) |
no |
no |
no |
editor |
Is_Delete |
varchar(50) |
no |
no |
no |
delete or not |
classification table
Menu
taste chart
employee form
Package relationship table
field |
type of data |
primary key |
foreign key |
Is it empty |
illustrate |
Id |
bigint(20) |
yes |
no |
no |
|
CategoryId |
bigint(20) |
no |
no |
no |
Category ID |
Name |
varchar(64) |
no |
no |
no |
package name |
Price |
decimal(10) |
no |
no |
no |
package price |
Status |
Int(11) |
no |
no |
no |
state |
Code |
varchar(32) |
no |
no |
no |
coding |
Descripte |
varchar(512) |
no |
no |
no |
Description |
Image |
varchar(255) |
no |
no |
no |
picture |
CreateTime UpdateTime |
datetime datetime |
no no |
no no |
no no |
creation time update time |
Createuser |
Bigint(20) |
no |
no |
no |
creator |
Updateuser |
Bigint(20) |
no |
no |
no |
editor |
Is_Delete |
varchar(50) |
no |
no |
no |
delete or not |
user table
shopping cart table
address book form
classification table
Menu
taste chart
employee form
order form
Order Details Form
Package table
Package relationship table
Entity ER Diagram
6 concrete realization
6.1 Staff login
6.1.1 Login function
Internal employees must enter the employee account number and password, and only after passing the verification can they access the system management background. The filter will determine whether the user has logged in, and if not, jump to the login page.
Employee login and logout core code:
@PostMapping("/employee/login")
public R<Employee> login(HttpServletRequest request, @RequestBody Employee employee){
//RequestBody可以接收JSON格式的数据并解析为实体类(Employee)
String username = employee.getUsername();
String password = DigestUtils.md5DigestAsHex(employee.getPassword().getBytes());
System.out.println("用户名:"+username+"--密码:"+password);
//LambdaQueryWrapper<List<Map>> lambdaQueryWrapper = new LambdaQueryWrapper<>();
LambdaQueryWrapper<Employee> queryWrapper = new LambdaQueryWrapper<>();
//查询结果是单张表,用实体类接收;如果是if交叉查询(多张表查询)用List<Map>
queryWrapper.eq(Employee::getUsername,username);
//使用LambdaQueryWrapper免除写sql,相当于进行select操作
Employee employee1 = employeeService.getOne(queryWrapper);
System.out.println("2********username:"+employee1.getPhone());
if (employee1 == null){
return R.error("用户名错误,登录失败,请重试!");
}
if (!password.equals(employee1.getPassword())){
return R.error("密码错误,登录失败,请重试!");
}
if (employee1.getStatus()!=1){
return R.error("该账户被删除或禁用,登录失败!");
}
request.getSession().setAttribute("employee",employee1); //为了filter、后续调用方便
BaseContext.setCurrentUserID(employee1.getId()); //为了普通类能够调用
return R.success(employee1);
}
@PostMapping("/employee/logout")
public R<Employee> logout(HttpServletRequest request){
request.getSession().removeAttribute("employee");
request.getSession().invalidate();
return R.success(null);
}
6.2 Employee Management
6.2.1 Query function
Enter the corresponding employee name to find the employee.
6.2.2 Add function
Add new employees by inputting new employee information.
6.2.3 修改功能
点击编辑可以对所选员工的个人信息进行修改。
6.2.4 禁用功能
可以点击禁用禁止该员工的登录权限。
6.3 分类管理
6.3.1 查看功能
可以查看当前显示所有菜品或套餐类型。
6.3.2 添加功能
对新的菜品和套餐类型进行添加操作。
6.3.3 修改功能
对于一些错误的菜品或套餐信息进行更改。
6.3.4 删除功能
对于某些过时或者冷门的菜品或套餐进行删除。
6.4 菜品管理
6.4.1 查询功能
可以根据个人需求查找当前现有菜品信息。
6.4.2 添加功能
对于当前热门菜品可以新增到菜品管理中。
6.4.3 修改功能
对一些冷门菜品可以对其价格进行修改。
6.4.4 删除功能
对于一些冷门菜品可以进行停售或删除操作。
菜品信息修改核心代码:
@PutMapping("/edit")
public R<String> update(@RequestBody DishDto dishDto) {
// 更新dish表
dishService.updateById(dishDto);
// 清理当前菜品口味信息,dish_flavor表的delete操作
// 不能使用removeById, 因为dishDto的id不是dish_flavor的主键
LambdaQueryWrapper<DishFlavor> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DishFlavor::getDishId, dishDto.getId());
dishFlavorService.remove(queryWrapper);
// 重新插入菜品口味信息,dish_flavor表的insert操作
List<DishFlavor> dishFlavor = new ArrayList<>();
for (DishFlavor item :dishDto.getFlavors()) {
item.setDishId(dishDto.getId());
dishFlavor.add(item);
}
dishFlavorService.saveBatch(dishFlavor);
return R.success("修改成功");
}
6.5 套餐管理
6.5.1 查询功能
对于所需要的套餐类型进行检索。
6.5.2 添加功能
对于新的套餐类型加入到套餐管理中。
6.5.3 修改功能
针对一些信息有误的套餐进行修改。
6.5.4 删除功能
某些套餐长期无人购买可以选择性进行删除。
6.6 订单明细
6.6.1 查询功能
在订单明细中可以查看用户的所有订单和派送状态。
6.6.2 订单查看
点击查看订单可以看到用户的个人信息以及地址详情等。
6.7 用户管理
6.7.1 登录管理
在移动端, 手机用户需要输入手机号验证码登录后进入APP进行点餐。
6.7.2 点餐-菜单
在点餐界面需要展示出菜品分类/套餐分类, 并根据当前选择的分类加载其中的菜品信息, 供用户查询选择。
6.7.3 点餐-购物车
用户选中的菜品就会加入用户的购物车, 主要包含查询购物车、加入购物车、删除购物车、清空购物车等功能。
减少购物车菜品核心代码:
@PostMapping("/sub")
public R<String> sub(@RequestBody ShoppingCart shoppingCart, HttpSession session) {
// 1.获取当前用户
User user = (User) session.getAttribute("employee");
// 2.查询当前用户、当前商品在购物车表里是否已存在
LambdaQueryWrapper<ShoppingCart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ShoppingCart::getUserId, user.getId()) // 筛选用户ID
.eq(shoppingCart.getDishId() != null, ShoppingCart::getDishId, shoppingCart.getDishId()) // 如果传入的商品ID不为空,筛选商品ID
.eq(shoppingCart.getSetmealId() != null, ShoppingCart::getSetmealId, shoppingCart.getSetmealId()); // 如果传入的套餐ID不为空,筛选套餐ID
ShoppingCart shoppingCart1 = shoppingCartService.getOne(lambdaQueryWrapper); // 返回符合条件的购物车记录
int shoppingCartNumber = shoppingCart1.getNumber();
try {
if (shoppingCartNumber > 1) { // 如果记录的数量大于1,则减少数量
shoppingCartNumber = shoppingCart1.getNumber() - 1; // 记录的数量减1
shoppingCart1.setNumber(shoppingCartNumber); // 更新记录的数量
shoppingCartService.updateById(shoppingCart1); // 更新购物车记录
} else { // 如果记录的数量为1,则删除该记录
shoppingCartService.removeById(shoppingCart1.getId());
}
} catch (Exception e) {
return R.error("删除失败");
}
return R.success("删除成功");
}
6.7.4 订单支付
用户选完菜品/套餐后, 可以对购物车菜品进行结算支付, 这时就需要进行订单的支付。
6.7.5 个人信息
在个人中心页面中会展示当前用户的基本信息, 用户可以管理收货地址, 也可以查询历史订单数据。
地址修改与删除核心代码:
@PutMapping
public R<String> addressBookupdate(@RequestBody AddressBook addressBook, HttpSession session){
//设置修改时间
addressBook.setUpdateTime(LocalDateTime.now());
//设置修改人
addressBook.setUpdateUser((Long)session.getAttribute("user"));
addressBookService.updateById(addressBook);
return R.success("修改地址成功!");
}
@DeleteMapping
public R<String> detele(@RequestParam("ids") Long id){
addressBookService.removeById(id);
return R.success("删除地址成功!");
}
7 测试
7.1 员工管理功能测试
员工管理测试表
测试用例 |
期望结果 |
实际结果 |
查询员工 |
通过账号登录进入后可以根据员工姓名查找该员工信息 |
测试通过 |
添加员工 |
通过输入新员工的信息实现对新员工的添加操作。 |
测试通过 |
修改员工 |
点击编辑可以对所选员工的个人信息进行修改 |
测试通过 |
禁用员工 |
点击禁用能够有效的禁止该员工的登录权限 |
测试通过 |
根据上面的测试结果来看,该功能通过所有的测试用例并且符合需求。
7.2 分类管理功能测试
分类管理测试表
测试用例 |
期望结果 |
实际结果 |
查看菜品/套餐 |
员工可以查看当前显示所有菜品或套餐类型 |
测试通过 |
添加菜品/套餐 |
员工能够对新的菜品或套餐类型进行添加操作 |
测试通过 |
修改菜品/套餐 |
员工可以对于信息错误的菜品或套餐进行更改 |
测试通过 |
删除菜品/套餐 |
员工能够对于过时或冷门的菜品或套餐进行删除 |
测试通过 |
根据上面的测试结果来看,该功能通过所有的测试用例并且符合需求。
7.3 地址管理功能测试
地址管理测试表
测试用例 |
期望结果 |
实际结果 |
查看地址 |
用户可以查看当前显示的所有个人地址信息 |
测试通过 |
添加地址 |
用户能够对新的地址信息进行添加操作 |
测试通过 |
修改地址 |
用户可以对于错误的地址信息进行更改 |
测试通过 |
删除地址 |
用户能够对于一些不常用的地址进行删除 |
测试通过 |
根据上面的测试结果来看,该功能通过所有的测试用例并且符合需求。
8 部署
- 首先打开项目Maven工具栏,确定将要打包的模块,点开Lifecycle选项,然后选择Install开始打包。
- 先在IDEA控制台上单击切换到Terminal终端页面,然后在项目所在位置后的指令输入提示位置指令部署即可。
9 总结
通过实训我们学习到MyBatisPlus是MyBatis的增强工具,它为MyBatis提供了更加方便快捷的使用方式,同时也提供了更多的扩展功能。
它提供了大量的注解和接口,如@TableField注解可以定义表字段的属性等等。另外它还提供了一些高级特性,如分页查询、逻辑删除和多表关联查询等。
在这次实训中,我通过编写代码、模拟实际场景等方式,来提升自己的编程能力,同时需要注重代码规范和功能的完整性,不断优化和完善项目。
其次,我深刻的认识到Java编程需要掌握各种开发工具和框架,如IntelliJ IDEA、Spring boot等,这些工具和框架可以提高开发效率。因此,在实训中也应该注重培养学员的独立学习能力,让他们自主学习并运用各种工具和框架。
最后,Java编程需要具备良好的团队协作能力,因为实际项目中不可能仅仅由单人完成,需要多人协作完成。在实训中也应该注重培养个人的沟通技巧和团队合作精神,如果能够在团队中融洽合作,就能极大地提高项目的实战效果。
注:由于源码量过多,需要的朋友可在资源中下载,也可私信我拿取!