基于javaweb+springboot的在线点餐系统(java+Springboot+ssm+mysql+maven)
一、项目简述
功能:数据库采用mysq昨为数据存储,系统中涉及到的关 键表有,用户表、用户详情表、商品表、订单表、商品订 单关联表、评价表等等。本系统分为前端和后端,前端功 能有:登录注册、修改个人信息、修改收货地址、查看商 品、加购商品、结算商品,对订单进行评价、用户留言等 功能;后端功能有:登录、商品管理、用户管理、订单管 理、留言公告管理等功能。本系统中的购物车功能设计、io流读写图片存放本地、订单导出、“echarts插件实现订单信 息统计、后台批量操作、pagehelper实现分页等细节值得 学习。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Springboot+ SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + Layui+ maven等等。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
public String toAnsEva(String orderId,Model model){
Evaluate evaluate = evaService.findEvaListByOrderId(orderId);
model.addAttribute("evaluate",evaluate);
return "/admin/adminAnsEva";
}
@RequestMapping("/admin/ansEva")
public String ansEva(String orderId,String ansContent,Integer orderStatus){
evaService.saveAnsEva(orderId,ansContent);
orderService.updateOrderStatus(orderStatus,orderId);
return "redirect:/admin/toOrderList";
}
//跳转到订单详情页面
@RequestMapping("/admin/orderDetailed")
public String orderDetailed(String orderId,Model model){
Order order = orderService.findListByOrderId(orderId);
model.addAttribute("order",order);
return "/admin/order/order_detailed";
}
/**
* @return
*/
@RequestMapping("/admin/toOrderList")
public String orderForm(@RequestParam(required = true, defaultValue = "1") Integer page, Model model) {
PageHelper.startPage(page, 5);
List<Order> orderAll = orderService.findOrderAll();
model.addAttribute("order",orderAll);
PageInfo<Order> pageInfo = new PageInfo<>(orderAll);
model.addAttribute("page", pageInfo);
return "/admin/order/order_list";
}
@RequestMapping("/admin/deleteOrder")
public String deleteOrder(String orderId){
orderService.deleteOrder(orderId);
return "redirect:/admin/toOrderList";
}
/**
* 修改后台订单状态
* @param orderId
* @param orderStatus
* @return
*/
@RequestMapping("/admin/updateAdminOrderStatus")
public String updateAdminOrderStatus(String orderId,Integer orderStatus){
public String brandManage() {
return "/admin/Brand_Manage";
}
@RequestMapping("toProduct_category_add")
public String toProduct_category_add(){
return "/admin/product-category-add";
}
@RequestMapping("/advertising")
public String advertising() {
return "/admin/advertising";
}
@RequestMapping("/admin/transaction")
varList.add(data);
}
dataMap.put("varList", varList);
return dataMap;
}
/**
*@描述 1-3-导出excel-自定义Excel标题和文件名
*/
protected Map<String,String> getExcelTitleAndFileName(){
Map<String,String> excelMap = new HashMap<String,String>();
excelMap.put("excelTitle","订单信息表格");//excel标题
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String time = sdf.format(new Timestamp(System.currentTimeMillis()));
excelMap.put("fileName","订单信息表格" + time);//文件名
return excelMap;
}
管理员控制层:
/**
* 管理员控制层
*/
@Controller
public class Back_AdminController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@GetMapping("/admin/toMemberList")
public String toMemberList(Model model){
List<User> allUser = userService.findAllUser();
List<Role> roleList = roleService.findRoleList();
model.addAttribute("userList",allUser);
model.addAttribute("roleList", roleList);
return "/admin/member/member_list";
}
/**
*
* @param session 前台传过来的管理员的session,里面存有user对象
*/
model.addAttribute("messageNum",messageList.size());
subject.getSession().setAttribute("user",dbUser);
return "/admin/common/index";
}
//3-如果不是管理员 返回登录界面
model.addAttribute("errorInfo","非管理员不能登录后台管理系统~~");
return "/admin/common/login";
}
@RequestMapping("/admin/home")
public String home() {
//跳转回用户列表页面
return "/admin/common/home";
}
@RequestMapping("/brandManage")
public String brandManage() {
return "/admin/Brand_Manage";
}
@RequestMapping("toProduct_category_add")
public String toProduct_category_add(){
return "/admin/product-category-add";
}
@RequestMapping("/advertising")
public String advertising() {
public String memberGrading() {
return "/admin/member-Grading";
}
@RequestMapping("/integration")
public String integration() {
return "/admin/integration";
}
@RequestMapping("/feedBack")
public String feedBack() {
return "/admin/Feedback";
}
@RequestMapping("/systems")
public String systems() {
return "/admin/Systems";
}
/* @RequestMapping("/menuManage")
public String menuManage() {
return "/admin/test";
}*/
@RequestMapping("/userManage")
public String userManage() {
return "/admin/test";
.stream().filter(leave -> leave.getStatus() == 0).collect(Collectors.toList());
model.addAttribute("messageNum",messageList.size());
subject.getSession().setAttribute("user",dbUser);
return "/admin/common/index";
}
//3-如果不是管理员 返回登录界面
model.addAttribute("errorInfo","非管理员不能登录后台管理系统~~");
return "/admin/common/login";
}
@RequestMapping("/admin/home")
public String home() {
//跳转回用户列表页面
return "/admin/common/home";
}
@RequestMapping("/brandManage")
public String brandManage() {
return "/admin/Brand_Manage";
}
@RequestMapping("toProduct_category_add")
public String toProduct_category_add(){
ModelAndView mv = new ModelAndView();
try {
//1-根据id数组获取数据库数据
List<Object> dataList = getExcelDataList();
//2-获取列标题和封装数据
Map<String, Object> dataMap = getTitleArrayAndVarList(dataList);
//3-获取Excel表格文件名和表格标题
Map<String, String> excelMap = getExcelTitleAndFileName();
//4-创建AbstractExcelView
AbstractExcelView erv = getAbstractExcelView(excelMap);
}
@PostMapping("/admin/stopStatus")
public void stopState(String userId) {
int status = 0;
userService.updateUserStatus(userId, status);
}
@PostMapping("/admin/startStatus")
public void startState(String userId) {
int status = 1;
userService.updateUserStatus(userId, status);
}
@RequestMapping("/admin/deleteUserById")
public void deleteUserById(String userId) {
userService.deleteUserById(userId);
}
@RequestMapping("/adminCompetence")
public String adminCompetence(Model model) {
List<User> userList = userService.findAdminList();
@Autowired
private LeaveMapper leaveMapper;
/**
* 去后台登录系统
*/
@RequestMapping("/admin/index")
public String adminLogin() {
return "/admin/common/login";
}
@PostMapping("/admin/backLogin")
public String backLogin(User user, Model model){
User dbUser = userMapper.findUserByU_P(user.getUserName(),user.getPassword());
//1-如果登录账号不存在 直接返回
if(dbUser == null){
model.addAttribute("errorInfo","用户名或密码错误~~");
return "/admin/common/login";
}
//2-如果登录账号存在 判断是否为管理员身份
if(dbUser.getRoleId() == 1){
Subject subject = SecurityUtils.getSubject();
//2-1-查询未读的留言
public String ansEva(String orderId,String ansContent,Integer orderStatus){
evaService.saveAnsEva(orderId,ansContent);
orderService.updateOrderStatus(orderStatus,orderId);
return "redirect:/admin/toOrderList";
}
//跳转到订单详情页面
@RequestMapping("/admin/orderDetailed")
public String orderDetailed(String orderId,Model model){
Order order = orderService.findListByOrderId(orderId);
model.addAttribute("order",order);
return "/admin/order/order_detailed";
public String memberGrading() {
return "/admin/member-Grading";
}
@RequestMapping("/integration")
public String integration() {
return "/admin/integration";
}
@RequestMapping("/feedBack")
public String feedBack() {
return "/admin/Feedback";
}
@PostMapping("/admin/startStatus")
public void startState(String userId) {
int status = 1;
userService.updateUserStatus(userId, status);
}
@RequestMapping("/admin/deleteUserById")
public void deleteUserById(String userId) {
userService.deleteUserById(userId);
}
@RequestMapping("/adminCompetence")
public String adminCompetence(Model model) {
List<User> userList = userService.findAdminList();
String pRoleName = "";
String sRoleName = "";
int pCount = 0;
int sCount = 0;
}
/* @RequestMapping("/menuManage")
public String menuManage() {
return "/admin/test";
}*/
@RequestMapping("/userManage")
public String userManage() {
return "/admin/test";
}
/* */
@RequestMapping("/systemSet")
public String systemSet() {
return "/admin/Systems";
public String deleteAdmins(@RequestParam("userId") String[] userIds){
userService.deleteAdminsById(userIds);
return "redirect:/admin/toMemberList";
}
@RequestMapping("/admin/selectUser")
public String selectUser(String userName, Model model){
List<User> dbUserList = userService.findUserByUsername(userName);
model.addAttribute("userList", dbUserList);
return "/admin/member/member_list";
}
@PostMapping("/admin/stopStatus")
public void stopState(String userId) {
int status = 0;
userService.updateUserStatus(userId, status);
}
@PostMapping("/admin/startStatus")
public void startState(String userId) {
int status = 1;
userService.updateUserStatus(userId, status);
userService.addUser(user);
return "redirect:/admin/toMemberList";
}
@RequestMapping("/deleteAdmins")
public String deleteAdmins(@RequestParam("userId") String[] userIds){
userService.deleteAdminsById(userIds);
return "redirect:/admin/toMemberList";
}
@RequestMapping("/admin/selectUser")
public String selectUser(String userName, Model model){
List<User> dbUserList = userService.findUserByUsername(userName);
model.addAttribute("userList", dbUserList);
return "/admin/member/member_list";
}
@PostMapping("/admin/stopStatus")
public void stopState(String userId) {
int status = 0;
userService.updateUserStatus(userId, status);
}
@PostMapping("/admin/startStatus")
public void startState(String userId) {
int status = 1;
userService.updateUserStatus(userId, status);
}
protected Map<String,String> getExcelTitleAndFileName(){
Map<String,String> excelMap = new HashMap<String,String>();
excelMap.put("excelTitle","订单信息表格");//excel标题
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String time = sdf.format(new Timestamp(System.currentTimeMillis()));
excelMap.put("fileName","订单信息表格" + time);//文件名
return excelMap;
}
/**
*@描述 1-4-创建AbstractExcelView
*/
protected AbstractExcelView getAbstractExcelView(Map<String, String> excelMap){
try {
ObjectExcelViewOrder erv = new ObjectExcelViewOrder(excelMap.get("fileName"),excelMap.get("excelTitle"));
return erv;
} catch (Exception e) {
}
@RequestMapping("/admin/ansEva")
public String ansEva(String orderId,String ansContent,Integer orderStatus){
evaService.saveAnsEva(orderId,ansContent);
orderService.updateOrderStatus(orderStatus,orderId);
return "redirect:/admin/toOrderList";
}
//跳转到订单详情页面
@RequestMapping("/admin/orderDetailed")
public String orderDetailed(String orderId,Model model){
Order order = orderService.findListByOrderId(orderId);
model.addAttribute("order",order);
return "/admin/order/order_detailed";
public String checkPassowrd(User user, String npassword){
*//* String password = userService.findUserByUserId(user.getUserId()).getPassword();
if(user.getPassword().equals(password)){
user.setPassword(npassword);
userService.updateUserPassword(user);
return "true";
}else{
return "false";
}*//*
return "false";
}*/
@RequestMapping("/addAdmin")
public String addAdmin(User user) {
userService.addUser(user);
}
/**
*@描述 1-2-导出Excel-自定义列标题和数据
*/
protected Map<String,Object> getTitleArrayAndVarList(List<Object> dataList) {
Map<String,Object> dataMap = new HashMap<String,Object>();
//1-标题
String[] titleArray = {
"订单序号",
"订单编号",
"订单金额",
"收货人",
"收获地址",
"下单时间",
"订单状态"
AbstractExcelView erv = getAbstractExcelView(excelMap);
//ObjectExcelViewOrderOperation erv = new ObjectExcelViewOrderOperation(excelMap.get("fileName"),excelMap.get("excelTitle"));
mv = new ModelAndView(erv, dataMap);
} catch (Exception e) {
e.printStackTrace();
}
return mv;
}
/**
*@描述 1-1-从数据库获取数据
*/
protected List<Object> getExcelDataList(){
try {
List<Object> dataList = orderService.find4ExcelDown();
return dataList;
} catch (Exception e) {
e.printStackTrace();
return null;
}
"订单状态"
};
dataMap.put("titles", Arrays.asList(titleArray));
//2-数据
List<OrderExcelExportVO> varList = new ArrayList<OrderExcelExportVO>();
for(int i=0;i<dataList.size();i++){
OrderExcelExportVO data = (OrderExcelExportVO)dataList.get(i);
List<Object> vpd = new ArrayList<>();
varList.add(data);
}
dataMap.put("varList", varList);
return dataMap;
}
/**
*@描述 1-3-导出excel-自定义Excel标题和文件名
*/
protected Map<String,String> getExcelTitleAndFileName(){
Map<String,String> excelMap = new HashMap<String,String>();
excelMap.put("excelTitle","订单信息表格");//excel标题
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String time = sdf.format(new Timestamp(System.currentTimeMillis()));
/* @RequestMapping("/menuManage")
public String menuManage() {
return "/admin/test";
}*/
@RequestMapping("/userManage")
public String userManage() {
return "/admin/test";
}
/* */
@RequestMapping("/systemSet")
public String systemSet() {
return "/admin/Systems";
}
public String advertising() {
return "/admin/advertising";
}
@RequestMapping("/admin/transaction")
public String transaction() {
return "/admin/order/transaction";
}
@RequestMapping("/amounts")
public String amounts() {
return "/admin/Amounts";
}
@RequestMapping("/orderHandling")
public String orderHandling() {
return "/admin/Order_handling";
}
@RequestMapping("/coverManagement")
public String coverManagement() {
return "/admin/Cover_management";
}
@RequestMapping("/userList")
public String userList() {
return "/admin/user_list";
}
try {
ObjectExcelViewOrder erv = new ObjectExcelViewOrder(excelMap.get("fileName"),excelMap.get("excelTitle"));
return erv;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
管理员控制层:
/**
* 管理员控制层
*/
@Controller
public class Back_AdminController {
@Autowired