Java通過SSM完成水果商城批發平臺流程
一,項目簡介
項目編號:BS-SC-029
本系統主要為種值水果和農戶和水果經銷商搭建一個B2B的電子商務平臺,系統共包含三個角色:農戶、經銷商和管理員。
1.農戶角色功能
前臺首頁、用戶註冊登錄、新聞公告、查看水果詳情、收藏、留言、個人中心、我的收藏、意見反饋、發佈水果、我的銷售等功能。
2.經銷商角色功能
前臺首頁、用戶註冊登錄、新聞公告、查看水果詳情、收藏、留言、個人中心、我的收藏、意見反饋、在線購買、下單結算、查看我的訂單等功能。
3.管理員後臺功能
用戶管理、管理員管理、網站內容管理、水果類型管理、水果信息管理、采購訂單管理、用戶評價管理、意見反饋管理、留言交流管理等
二,環境介紹
語言環境:Java: jdk1.8
數據庫:Mysql: mysql5.7
應用服務器:Tomcat: tomcat8.5.31
開發工具:IDEA或eclipse
後臺開發技術:SSM框架
前臺開發技術:H-UI框架
三,系統展示
用戶註冊
用戶登陸
系統首頁
新聞公告
商品展示
全文檢索
在線留言
添加購物車
經銷商個人中心
農戶個人中心
後臺管理功能模塊
四,核心代碼展示
package com.controller; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.entity.Admin; import com.service.AdminService; import com.util.PageHelper; import com.util.VeDate; //定義為控制器 @Controller // 設置路徑 @RequestMapping(value = "/admin" , produces = "text/plain;charset=utf-8") public class AdminController extends BaseController { // 註入Service 由於標簽的存在 所以不需要getter setter @Autowired private AdminService adminService; // 管理員準備 @RequestMapping("index.action") public String index() { return "admin/index"; } // 管理員登錄 1 驗證用戶名是否存在 2 驗證密碼是否正確 @RequestMapping("login.action") public String login() { String username = this.getRequest().getParameter("username"); String password = this.getRequest().getParameter("password"); Admin adminEntity = new Admin(); adminEntity.setUsername(username); List<Admin> adminlist = this.adminService.getAdminByCond(adminEntity); if (adminlist.size() == 0) { this.getRequest().setAttribute("message", "用戶名不存在"); return "redirect:/admin/index.action"; } else { Admin admin = adminlist.get(0); if (password.equals(admin.getPassword())) { this.getSession().setAttribute("adminid", admin.getAdminid()); this.getSession().setAttribute("adminname", admin.getUsername()); this.getSession().setAttribute("realname", admin.getRealname()); } else { this.getRequest().setAttribute("message", "密碼錯誤"); return "redirect:/admin/index.action"; } } return "admin/main"; } // 管理員準備修改密碼 @RequestMapping("prePwd.action") public String prePwd() { return "admin/editpwd"; } // 修改密碼 @RequestMapping("editpwd.action") public String editpwd() { String adminid = (String) this.getSession().getAttribute("adminid"); String password = this.getRequest().getParameter("password"); String repassword = this.getRequest().getParameter("repassword"); Admin admin = this.adminService.getAdminById(adminid); if (password.equals(admin.getPassword())) { admin.setPassword(repassword); this.adminService.updateAdmin(admin); } else { this.getRequest().setAttribute("message", "舊密碼錯誤"); } return "redirect:/admin/prePwd.action"; } // 管理員退出登錄 @RequestMapping("exit.action") public String exit() { this.getSession().removeAttribute("adminid"); this.getSession().removeAttribute("adminname"); this.getSession().removeAttribute("realname"); return "redirect:/admin/index.action"; } // 準備添加數據 @RequestMapping("createAdmin.action") public String createAdmin() { return "admin/addadmin"; } // 添加數據 @RequestMapping("addAdmin.action") public String addAdmin(Admin admin) { admin.setAddtime(VeDate.getStringDateShort()); this.adminService.insertAdmin(admin); return "redirect:/admin/createAdmin.action"; } // 通過主鍵刪除數據 @RequestMapping("deleteAdmin.action") public String deleteAdmin(String id) { this.adminService.deleteAdmin(id); return "redirect:/admin/getAllAdmin.action"; } // 批量刪除數據 @RequestMapping("deleteAdminByIds.action") public String deleteAdminByIds() { String[] ids = this.getRequest().getParameterValues("adminid"); for (String adminid : ids) { this.adminService.deleteAdmin(adminid); } return "redirect:/admin/getAllAdmin.action"; } // 更新數據 @RequestMapping("updateAdmin.action") public String updateAdmin(Admin admin) { this.adminService.updateAdmin(admin); return "redirect:/admin/getAllAdmin.action"; } // 顯示全部數據 @RequestMapping("getAllAdmin.action") public String getAllAdmin(String number) { List<Admin> adminList = this.adminService.getAllAdmin(); PageHelper.getPage(adminList, "admin", null, null, 10, number, this.getRequest(), null); return "admin/listadmin"; } // 按條件查詢數據 (模糊查詢) @RequestMapping("queryAdminByCond.action") public String queryAdminByCond(String cond, String name, String number) { Admin admin = new Admin(); if(cond != null){ if ("username".equals(cond)) { admin.setUsername(name); } if ("password".equals(cond)) { admin.setPassword(name); } if ("realname".equals(cond)) { admin.setRealname(name); } if ("contact".equals(cond)) { admin.setContact(name); } if ("addtime".equals(cond)) { admin.setAddtime(name); } } List<String> nameList = new ArrayList<String>(); List<String> valueList = new ArrayList<String>(); nameList.add(cond); valueList.add(name); PageHelper.getPage(this.adminService.getAdminByLike(admin), "admin", nameList, valueList, 10, number, this.getRequest(), "query"); name = null; cond = null; return "admin/queryadmin"; } // 按主鍵查詢數據 @RequestMapping("getAdminById.action") public String getAdminById(String id) { Admin admin = this.adminService.getAdminById(id); this.getRequest().setAttribute("admin", admin); return "admin/editadmin"; } }
package com.controller; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.entity.Article; import com.service.ArticleService; import com.entity.Banner; import com.service.BannerService; import com.util.PageHelper; import com.util.VeDate; //定義為控制器 @Controller // 設置路徑 @RequestMapping(value = "/article" , produces = "text/plain;charset=utf-8") public class ArticleController extends BaseController { // 註入Service 由於標簽的存在 所以不需要getter setter @Autowired private ArticleService articleService; @Autowired private BannerService bannerService; // 準備添加數據 @RequestMapping("createArticle.action") public String createArticle() { List<Banner> bannerList = this.bannerService.getAllBanner(); this.getRequest().setAttribute("bannerList", bannerList); return "admin/addarticle"; } // 添加數據 @RequestMapping("addArticle.action") public String addArticle(Article article) { article.setAddtime(VeDate.getStringDateShort()); article.setHits("0"); this.articleService.insertArticle(article); return "redirect:/article/createArticle.action"; } // 通過主鍵刪除數據 @RequestMapping("deleteArticle.action") public String deleteArticle(String id) { this.articleService.deleteArticle(id); return "redirect:/article/getAllArticle.action"; } // 批量刪除數據 @RequestMapping("deleteArticleByIds.action") public String deleteArticleByIds() { String[] ids = this.getRequest().getParameterValues("articleid"); for (String articleid : ids) { this.articleService.deleteArticle(articleid); } return "redirect:/article/getAllArticle.action"; } // 更新數據 @RequestMapping("updateArticle.action") public String updateArticle(Article article) { this.articleService.updateArticle(article); return "redirect:/article/getAllArticle.action"; } // 顯示全部數據 @RequestMapping("getAllArticle.action") public String getAllArticle(String number) { List<Article> articleList = this.articleService.getAllArticle(); PageHelper.getPage(articleList, "article", null, null, 10, number, this.getRequest(), null); return "admin/listarticle"; } // 按條件查詢數據 (模糊查詢) @RequestMapping("queryArticleByCond.action") public String queryArticleByCond(String cond, String name, String number) { Article article = new Article(); if(cond != null){ if ("title".equals(cond)) { article.setTitle(name); } if ("bannerid".equals(cond)) { article.setBannerid(name); } if ("image".equals(cond)) { article.setImage(name); } if ("contents".equals(cond)) { article.setContents(name); } if ("addtime".equals(cond)) { article.setAddtime(name); } if ("hits".equals(cond)) { article.setHits(name); } } List<String> nameList = new ArrayList<String>(); List<String> valueList = new ArrayList<String>(); nameList.add(cond); valueList.add(name); PageHelper.getPage(this.articleService.getArticleByLike(article), "article", nameList, valueList, 10, number, this.getRequest(), "query"); name = null; cond = null; return "admin/queryarticle"; } // 按主鍵查詢數據 @RequestMapping("getArticleById.action") public String getArticleById(String id) { Article article = this.articleService.getArticleById(id); this.getRequest().setAttribute("article", article); List<Banner> bannerList = this.bannerService.getAllBanner(); this.getRequest().setAttribute("bannerList", bannerList); return "admin/editarticle"; } }
package com.controller; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.entity.Banner; import com.service.BannerService; import com.util.PageHelper; import com.util.VeDate; //定義為控制器 @Controller // 設置路徑 @RequestMapping(value = "/banner" , produces = "text/plain;charset=utf-8") public class BannerController extends BaseController { // 註入Service 由於標簽的存在 所以不需要getter setter @Autowired private BannerService bannerService; // 準備添加數據 @RequestMapping("createBanner.action") public String createBanner() { return "admin/addbanner"; } // 添加數據 @RequestMapping("addBanner.action") public String addBanner(Banner banner) { banner.setAddtime(VeDate.getStringDateShort()); this.bannerService.insertBanner(banner); return "redirect:/banner/createBanner.action"; } // 通過主鍵刪除數據 @RequestMapping("deleteBanner.action") public String deleteBanner(String id) { this.bannerService.deleteBanner(id); return "redirect:/banner/getAllBanner.action"; } // 批量刪除數據 @RequestMapping("deleteBannerByIds.action") public String deleteBannerByIds() { String[] ids = this.getRequest().getParameterValues("bannerid"); for (String bannerid : ids) { this.bannerService.deleteBanner(bannerid); } return "redirect:/banner/getAllBanner.action"; } // 更新數據 @RequestMapping("updateBanner.action") public String updateBanner(Banner banner) { this.bannerService.updateBanner(banner); return "redirect:/banner/getAllBanner.action"; } // 顯示全部數據 @RequestMapping("getAllBanner.action") public String getAllBanner(String number) { List<Banner> bannerList = this.bannerService.getAllBanner(); PageHelper.getPage(bannerList, "banner", null, null, 10, number, this.getRequest(), null); return "admin/listbanner"; } // 按條件查詢數據 (模糊查詢) @RequestMapping("queryBannerByCond.action") public String queryBannerByCond(String cond, String name, String number) { Banner banner = new Banner(); if(cond != null){ if ("bannername".equals(cond)) { banner.setBannername(name); } if ("addtime".equals(cond)) { banner.setAddtime(name); } if ("memo".equals(cond)) { banner.setMemo(name); } } List<String> nameList = new ArrayList<String>(); List<String> valueList = new ArrayList<String>(); nameList.add(cond); valueList.add(name); PageHelper.getPage(this.bannerService.getBannerByLike(banner), "banner", nameList, valueList, 10, number, this.getRequest(), "query"); name = null; cond = null; return "admin/querybanner"; } // 按主鍵查詢數據 @RequestMapping("getBannerById.action") public String getBannerById(String id) { Banner banner = this.bannerService.getBannerById(id); this.getRequest().setAttribute("banner", banner); return "admin/editbanner"; } }
package com.controller; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.entity.Complains; import com.service.ComplainsService; import com.entity.Users; import com.service.UsersService; import com.util.PageHelper; //定義為控制器 @Controller // 設置路徑 @RequestMapping(value = "/complains" , produces = "text/plain;charset=utf-8") public class ComplainsController extends BaseController { // 註入Service 由於標簽的存在 所以不需要getter setter @Autowired private ComplainsService complainsService; @Autowired private UsersService usersService; // 準備添加數據 @RequestMapping("createComplains.action") public String createComplains() { List<Users> usersList = this.usersService.getAllUsers(); this.getRequest().setAttribute("usersList", usersList); return "admin/addcomplains"; } // 添加數據 @RequestMapping("addComplains.action") public String addComplains(Complains complains) { this.complainsService.insertComplains(complains); return "redirect:/complains/createComplains.action"; } // 通過主鍵刪除數據 @RequestMapping("deleteComplains.action") public String deleteComplains(String id) { this.complainsService.deleteComplains(id); return "redirect:/complains/getAllComplains.action"; } // 批量刪除數據 @RequestMapping("deleteComplainsByIds.action") public String deleteComplainsByIds() { String[] ids = this.getRequest().getParameterValues("complainsid"); for (String complainsid : ids) { this.complainsService.deleteComplains(complainsid); } return "redirect:/complains/getAllComplains.action"; } // 更新數據 @RequestMapping("updateComplains.action") public String updateComplains(Complains complains) { this.complainsService.updateComplains(complains); return "redirect:/complains/getAllComplains.action"; } // 更新狀態 @RequestMapping("status.action") public String status(String id) { String status = ""; Complains complains = this.complainsService.getComplainsById(id); if (status.equals(complains.getStatus())) { status = ""; } complains.setStatus(status); this.complainsService.updateComplains(complains); return "redirect:/complains/getAllComplains.action"; } // 顯示全部數據 @RequestMapping("getAllComplains.action") public String getAllComplains(String number) { List<Complains> complainsList = this.complainsService.getAllComplains(); PageHelper.getPage(complainsList, "complains", null, null, 10, number, this.getRequest(), null); return "admin/listcomplains"; } // 按條件查詢數據 (模糊查詢) @RequestMapping("queryComplainsByCond.action") public String queryComplainsByCond(String cond, String name, String number) { Complains complains = new Complains(); if(cond != null){ if ("usersid".equals(cond)) { complains.setUsersid(name); } if ("title".equals(cond)) { complains.setTitle(name); } if ("contents".equals(cond)) { complains.setContents(name); } if ("addtime".equals(cond)) { complains.setAddtime(name); } if ("status".equals(cond)) { complains.setStatus(name); } if ("reps".equals(cond)) { complains.setReps(name); } } List<String> nameList = new ArrayList<String>(); List<String> valueList = new ArrayList<String>(); nameList.add(cond); valueList.add(name); PageHelper.getPage(this.complainsService.getComplainsByLike(complains), "complains", nameList, valueList, 10, number, this.getRequest(), "query"); name = null; cond = null; return "admin/querycomplains"; } // 按主鍵查詢數據 @RequestMapping("getComplainsById.action") public String getComplainsById(String id) { Complains complains = this.complainsService.getComplainsById(id); this.getRequest().setAttribute("complains", complains); List<Users> usersList = this.usersService.getAllUsers(); this.getRequest().setAttribute("usersList", usersList); return "admin/editcomplains"; } }
五,項目總結
本系統功能主要是針對農戶、經銷商買賣雙方進行業務對接,平臺管理員負責基礎數據的管理,是一個B2B的商城平臺,功能比較完整,頁面簡潔大方,適合做畢業設計使用。
到此這篇關於Java通過SSM完成水果商城批發平臺流程的文章就介紹到這瞭,更多相關Java水果商城內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!
推薦閱讀:
- Java 實戰項目之傢政服務平臺系統的實現流程
- 基於spring mvc請求controller訪問方式
- 基於Java SSM實現在線點餐系統
- springboot 實戰:異常與重定向問題
- Java 實戰項目錘煉之網上圖書館管理系統的實現流程