三方線上美食城|基于Springboot的三方線上美食商城系統(tǒng)
收藏點贊不迷路? 關(guān)注作者有好處
文末獲取源碼?
項目編號:BS-SC-023
前言:
隨著21世紀的進步,社會的生活節(jié)奏越來越快,網(wǎng)絡(luò)的迅速崛起,互聯(lián)網(wǎng)已日益成為提供信息的最佳渠道和連步進去傳統(tǒng)的流通領(lǐng)域,傳統(tǒng)的餐飲業(yè)也面連著巨大的挑戰(zhàn),網(wǎng)上訂餐主要是針對白領(lǐng)還有大學(xué)生這些特定群體,一些白領(lǐng)在中午時間或者晚上高峰時間就餐,許多順客由于高峰時間擁擠根本沒時間來享受美味,這樣既可以提前訂餐不浪費中午午休的時間,也可以和同事加深感情,更可以每天換各種各樣的菜式,保證每天工作的效率和身體的健康,這些問題就產(chǎn)生了快捷訂餐的要求,最快的方式莫過于利用計算機網(wǎng)絡(luò),將餐飲業(yè)和計算機網(wǎng)絡(luò)結(jié)合起來,就形成了網(wǎng)上訂餐系統(tǒng),能足不出戶,輕松閑逸地實現(xiàn)自己訂購餐飲和食品(包括飯、菜、眾飯便當(dāng)?shù)?。網(wǎng)上訂餐不僅減少了傳統(tǒng)店面所需面臨的租金問題,還能提供24小時不打烊服務(wù),讓顧客隨時隨地點餐的同時,也為商家減少了許多負擔(dān)。
一,項目簡介
本項目主要基于Springboot框架開發(fā)和實現(xiàn)了一個三方的美食商城系統(tǒng),主要包含買方,賣方,管理員三種用戶角色,不同的角色在系統(tǒng)中操作的功能模塊是不一樣的。
買方用戶需要注冊登陸后方可進行相應(yīng)的操作,主要包含餐品分類瀏覽,詳情查看,加入購物車,聯(lián)系商家,查看自己的訂單等功能,也可對餐品進行相應(yīng)評論操作。
賣房用戶注冊登陸后可以進行相應(yīng)的售賣商品操作,主要包含添加商品,查看購買我商品的訂單信息,對發(fā)布的商品進行維護管理等功能。
管理員用戶登陸系統(tǒng)后臺,主要進行用戶管理,商品類型管理,商品管理,訂單管理,評論管理,系統(tǒng)管理,角色管理,權(quán)限管理,日志管理等相關(guān)功能模塊。
系統(tǒng)整體功能完整,實現(xiàn)了一個基于買房,商家和平臺用戶的幾種不同角色的應(yīng)用,很適合做畢設(shè)。
二,環(huán)境介紹
語言環(huán)境:Java:? jdk1.8
數(shù)據(jù)庫:Mysql: mysql5.7
應(yīng)用服務(wù)器:Tomcat:? tomcat8.5.31
開發(fā)工具:IDEA或eclipse
后臺開發(fā)技術(shù):Springboot+Mybatis
前臺開發(fā)技術(shù):Bootstrap+Ajax
三,系統(tǒng)展示
系統(tǒng)首頁

注冊登陸

瀏覽商品添加購物車

查看購物車

我的訂單

個人中心

商品評論

賣家登陸

發(fā)布售賣 商品

查看己售訂單

商品信息維護

后臺管理系統(tǒng)-用戶登陸

后臺管理首頁

菜單管理

角色管理

管理員管理

分類管理

商品管理

用戶管理

新聞公告管理

訂單管理
四,核心代碼展示
package com.dong.controller.admin;import com.dong.config.TitleConfig;import com.dong.exception.CodeMsg;import com.dong.exception.Result;import com.dong.pojo.Category;import com.dong.service.CategoryService;import com.dong.utils.CategoryUtil;import com.dong.utils.ValidataUtil;import com.dong.vo.PageResult;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.*;/**
* 分類管理控制器
*/public class CategoryController { ? ?
? ?private TitleConfig titleConfig; ? ?
? ?private CategoryService categoryService; ? ?
? ?public String list({
? ? ? ?model.addAttribute( String name, PageResult pageResult, Model model)"title",titleConfig.getCategoryTitle() );
? ? ? ?model.addAttribute("name",name );
? ? ? ?model.addAttribute("pageResult", categoryService.selectPage(name, pageResult));
? ? ? ?model.addAttribute("parentList", CategoryUtil.getParentCategory(categoryService.selectAll())); ? ? ? ?return "/admin/category/list";
? ?} ? ?
? ?public String add(Model model){
? ? ? ?model.addAttribute("parentList", ?CategoryUtil.getParentCategory(categoryService.selectAll())); ? ? ? ?return "/admin/category/add";
? ?} ? ?
? ?
? ?public Result<Boolean> add(Category category){ ? ? ? ?CodeMsg validata = ValidataUtil.validata(category); ? ? ? ?if(validata.getCode()!=CodeMsg.SUCCESS.getCode()){ ? ? ? ? ? ?return Result.exception(validata);
? ? ? ?} ? ? ? ?try {
? ? ? ? ? ?categoryService.saveCategory(category);
? ? ? ?}catch (Exception e){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_CATEGORY_ADD_ERROR);
? ? ? ?} ? ? ? ?return Result.success(true);
? ?} ? ?
? ?public String edit(Model model,{
? ? ? ?model.addAttribute( Integer id)"category", categoryService.selectCategoryById(id));
? ? ? ?model.addAttribute("parentList", CategoryUtil.getParentCategory(categoryService.selectAll())); ? ? ? ?return "/admin/category/edit";
? ?} ? ?
? ?
? ?public Result<Boolean> edit(Category category){ ? ? ? ?CodeMsg validata = ValidataUtil.validata(category); ? ? ? ?if(validata.getCode()!=CodeMsg.SUCCESS.getCode()){ ? ? ? ? ? ?return Result.exception(validata);
? ? ? ?} ? ? ? ?try {
? ? ? ? ? ?categoryService.updateCategory(category);
? ? ? ?}catch (Exception e){
? ? ? ? ? ?Result.exception(CodeMsg.ADMIN_CATEGORY_EDIT_ERROR);
? ? ? ?} ? ? ? ?return Result.success(true);
? ?} ? ?
? ?
? ?public Result<Boolean> delete({ ? ? ? ? Integer id)try {
? ? ? ? ? ?categoryService.deleteCategory(id);
? ? ? ?}catch (Exception e){
? ? ? ? ? ?Result.exception(CodeMsg.ADMIN_CATEGORY_DELETE_ERROR);
? ? ? ?} ? ? ? ?return Result.success(true);
? ?}
}
package com.dong.controller.admin;import com.dong.config.TitleConfig;import com.dong.exception.Result;import com.dong.service.CommentService;import com.dong.vo.PageResult;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.*;/**
* 評論控制器
*/public class CommentController { ? ?
? ?private CommentService commentService; ? ?
? ?private TitleConfig titleConfig; ? ?
? ?public String list(PageResult pageResult, {
? ? ? ?model.addAttribute( String name, Model model)"title",titleConfig.getCommentTitle());
? ? ? ?model.addAttribute("name",name );
? ? ? ?model.addAttribute("pageResult",commentService.selectPage(pageResult,name)); ? ? ? ?return "admin/comment/list";
? ?} ? ?
? ?
? ?public Result<Boolean> delete({
? ? ? ?commentService.deleteComment(id); ? ? ? ? Integer id)return Result.success(true);
? ?}
}
package com.dong.controller.admin;import com.dong.config.TitleConfig;import com.dong.exception.CodeMsg;import com.dong.exception.Result;import com.dong.service.GoodService;import com.dong.vo.PageResult;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.*;/**
* 商品管理控制器
*/public class GoodController { ? ?
? ?private GoodService goodService; ? ?
? ?private TitleConfig titleConfig; ? ?
? ?public String list(Model model, {
? ? ? ?model.addAttribute( String name, PageResult pageResult)"title", titleConfig.getGoodTitle());
? ? ? ?model.addAttribute("name",name );
? ? ? ?model.addAttribute("pageResult",goodService.selectPages(pageResult,name )); ? ? ? ?return "/admin/good/list";
? ?} ? ?
? ?
? ?public Result<Boolean> delete({ ? ? ? ? Integer id)try {
? ? ? ? ?goodService.deleteGood(id);
? ? ? ?} catch (Exception e) { ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_GOODS_DELETE_ERROR);
? ? ? ?} ? ? ? ?return Result.success(true);
? ?}
}
package com.dong.controller.admin;import com.dong.constant.SessionConstant;import com.dong.exception.CodeMsg;import com.dong.exception.Result;import com.dong.listener.SessionListener;import com.dong.pojo.User;import com.dong.service.LogService;import com.dong.service.UserService;import com.dong.utils.StringUtil;import com.dong.utils.ValidataUtil;import org.apache.commons.lang3.StringUtils;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpSession;import java.util.Date;/**
* 系統(tǒng)控制器
*/public class SystemController { ? ?
? ?private UserService userService; ? ?
? ?private LogService logService;
? ?Logger logger= LoggerFactory.getLogger(UserController.class); ? ?/**
? ? * 管理員登錄
? ? * @param user
? ? * @param cpacha
? ? * @param session
? ? * @return
? ? */
? ?
? ?
? ?public Result<Boolean> Login(User user, String cpacha,HttpSession session){ ? ? ? ?CodeMsg validata = ValidataUtil.validata(user); ? ? ? ?if(validata.getCode()!=CodeMsg.SUCCESS.getCode()){ ? ? ? ? ? ?return Result.exception(validata);
? ? ? ?} ? ? ? ?if(StringUtils.isEmpty(cpacha)){ ? ? ? ? ? ?return Result.exception(CodeMsg.CPACHA_EMPTY);
? ? ? ?} ? ? ? ?Object adminCpacha =session.getAttribute("admin_login"); ? ? ? if(adminCpacha==null){ ? ? ? ? ? ?return Result.exception(CodeMsg.SESSION_EXPIRED);
? ? ? ?} ? ? ? ?if(!cpacha.equalsIgnoreCase(adminCpacha.toString())){ ? ? ? ? ? ?return Result.exception(CodeMsg.CPACHA_ERROR);
? ? ? ?} ? ? ? ?User users = userService.selectUserByName(user.getUsername()); ? ? ? ?if(users==null){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_USERNAME_EXIST);
? ? ? ?} ? ? ? ?if(!users.getPassword().equals(user.getPassword())){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_PASSWORD_ERROR);
? ? ? ?} ? ? ? ?if(users.getStatus()==User.ADMIN_USER_STATUS_UNABLE){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_USER_UNABLE);
? ? ? ?} ? ? ? ?//檢查一切符合,可以登錄,將用戶信息存放至session
? ? ? ?session.setAttribute(SessionConstant.USER_SESSION, users); ? ? ? ?//銷毀驗證碼
? ? ? ?session.removeAttribute("admin_login");
? ? ? ?logger.info("用戶成功登錄,user="+users);
? ? ? ?logService.addLog(user.getUsername(),"【"+user.getUsername()+"】"+"用戶在"+ StringUtil.dataFormat(new Date(), "yyyy-MM-dd HH:mm:ss")+"登錄系統(tǒng)!"); ? ? ? ?return Result.success(true);
? ?} ? ?/**
? ? * 后臺主頁
? ? * @param model
? ? * @return
? ? */
? ?
? ?public String index(Model model){
? ? ? ?model.addAttribute("userTotal", userService.selectUserTotal());
? ? ? ?model.addAttribute("operatorLogTotal", logService.selectLogTotal());
? ? ? ?model.addAttribute("operatorLogs", logService.selectRecentLog());
? ? ? ?model.addAttribute("onlineUserTotal", SessionListener.onlineUserCount); ? ? ? ?return "admin/system/index";
? ?} ? ?/**
? ? * 修改信息
? ? * @param user
? ? * @param session
? ? * @return
? ? */
? ?
? ?
? ?public Result<Boolean> update_userinfo(User user,HttpSession session){ ? ? ? ?User users =(User) session.getAttribute(SessionConstant.USER_SESSION); ? ? ? ?if(userService.selectUserByName(user.getUsername()) != null){ ? ? ? ? ? ?return ?Result.exception(CodeMsg.ADMIN_USERNAME_EXIST);
? ? ? ?}
? ? ? ?users.setImage(user.getImage());
? ? ? ?users.setEmail(user.getEmail());
? ? ? ?users.setMobile(user.getMobile());
? ? ? ? userService.updateUser(user);
? ? ? ?logService.addLog(user.getUsername(),"【"+user.getUsername()+"】"+"用戶在"+ StringUtil.dataFormat(new Date(), "yyyy-MM-dd HH:mm:ss")+"修改了自己的信息!"); ? ? ? ?return Result.success(true);
? ?} ? ?/**
? ? * 修改密碼
? ? * @param oldpwd
? ? * @param newpwd
? ? * @param id
? ? * @param session
? ? * @return
? ? */
? ?
? ?
? ?public Result<Boolean> update_pwd({ ? ? ? ? String oldpwd, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String newpwd, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Integer id,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?HttpSession session)User user =(User) session.getAttribute(SessionConstant.USER_SESSION); ? ? ? ?if(!user.getPassword().equals(oldpwd)){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_USER_UPDATE_PWD_ERROR);
? ? ? ?} ? ? ? ?if(StringUtils.isEmpty(newpwd)){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_USER_UPDATE_PWD_EMPTY);
? ? ? ?} ? ? ? ?if(newpwd.length()<6){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_PASSWORD_MINLENGTH);
? ? ? ?} ? ? ? ?if(newpwd.length()>18){ ? ? ? ? ? ?return Result.exception(CodeMsg.ADMIN_PASSWORD_MAXLENGTH);
? ? ? ?} ? ? ? ?User user1 = new User();
? ? ? ?user1.setId(id);
? ? ? ?user1.setPassword(newpwd);
? ? ? ?userService.updateUser(user1);
? ? ? ?user.setPassword(newpwd);
? ? ? ?logService.addLog(user.getUsername(),"【"+user.getUsername()+"】"+"用戶在"+ StringUtil.dataFormat(new Date(), "yyyy-MM-dd HH:mm:ss")+"更新了自己的密碼!"); ? ? ? ?return Result.success(true);
? ?} ? ?/**
? ? * 退出登錄
? ? * @param session
? ? * @return
? ? */
? ?
? ?public String logout(HttpSession session){
? ? ? ?session.removeAttribute(SessionConstant.USER_SESSION); ? ? ? ?return "redirect:login";
? ?}
}
五,項目總結(jié)
在國外,許多知名餐飲企業(yè)多年前就開始提供網(wǎng)上訂餐服務(wù)了,眾所周知,肯德基、麥當(dāng)勞等快餐巨頭是最早開始的?,F(xiàn)在網(wǎng)上訂餐對餐飲企業(yè)的門檻不斷降低,越來越多的餐飲企業(yè)開始提供網(wǎng)上訂餐服務(wù)。人們只需一部電腦和一張銀行卡,就可全天訂座。以往一家有名的餐廳,你需要提前很多時間或安排人手前往餐廳預(yù)定,這種做法大大影響了辦事效率,與現(xiàn)代人的生活節(jié)奏不符。如今人們只需提前登錄該餐廳網(wǎng)站預(yù)定,而不是把大量時間浪費在無謂的路程上。網(wǎng)上訂餐的流程一般是餐飲企業(yè)先開通網(wǎng)上訂餐服務(wù),再由專業(yè)的物流配送公司運送。消費者只需在網(wǎng)上選擇餐飲企業(yè)提供的菜品,就有配送公司送貨上門。網(wǎng)上訂餐的方式已經(jīng)被國外的許多家庭所認可。
在國內(nèi),2012年之前我國使用的訂餐方式大都還停留在電話訂餐的層次上。毋容置疑,電話訂餐方便,隨時打一個電話就可以預(yù)定餐品。這種訂餐方式逐漸受到消費者的認可,使用量逐年增長,很多問題開始凸顯出來。例如訂餐效率低,信息的處理程序繁雜,耗費大量人力資源。由于這些缺點,單獨的電話訂餐很難滿足現(xiàn)代人的需求。總體而言,該行業(yè)發(fā)展不夠迅速,國內(nèi)也缺乏龍頭企業(yè)。經(jīng)過這幾年的初步發(fā)展和互聯(lián)網(wǎng)技術(shù)的不斷進步,網(wǎng)絡(luò)訂餐市場被迅速催化。這種雙贏的模式逐漸被消費者與企業(yè)認可。網(wǎng)上訂餐成為現(xiàn)在炙手可熱的新興行業(yè),美團、餓了么等國內(nèi)知名app已經(jīng)成為人們生活中不可或缺的一部分。