Java通过SSM完成水果商城批发平台流程

网友投稿 277 2022-07-23


目录一,项目简介二,环境介绍三,系统展示四,核心代码展示五,项目总结

一,项目简介

项目编号: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 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 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 nameList = new ArrayList();

List valueList = new ArrayList();

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.ahttp://nnotation.RequestMapping;

import com.entity.Article;

import com.service.ArticleService;

import com.entity.Banner;

import com.service.BannerService;

import com.util.PageHelper;

imVVnWkBQport 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() {

VVnWkBQ List 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 Strhttp://ing updateArticle(Article article) {

this.articleService.updateArticle(article);

return "redirect:/article/getAllArticle.action";

}

// 显示全部数据

@RequestMapping("getAllArticle.action")

public String getAllArticle(String number) {

List

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 nameList = new ArrayList();

List valueList = new ArrayList();

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 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 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 nameList = new ArrayList();

List valueList = new ArrayList();

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 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 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 nameList = new ArrayList();

List valueList = new ArrayList();

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 usersList = this.usersService.getAllUsers();

this.getRequest().setAttribute("usersList", usersList);

return "admin/editcomplains";

}

}

五,项目总结

本系统功能主要是针对农户、经销商买卖双方进行业务对接,平台管理员负责基础数据的管理,是一个B2B的商城平台,功能比较完整,页面简洁大方,适合做毕业设计使用。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Spring针对AOP详细讲解
下一篇:使用maven自定义插件开发
相关文章