作者主页:[编程指南针]
作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云优质创作者、51CTO优质创作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助
收藏点赞不迷路 关注作者有好处
文末获取源码
项目编号:BS-SC-054
一,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
后台开发技术: springboot+mybatis+springmvc
前台开发技术: HTML5+CSS+JQUERY+Bootstrap
二,项目简介
本系统主要基于Springboot框架开发实现,实现了一个以农产品为主题的商城系统。在本商城系统中,可以实现在线购买农产品,在线支付,管理个人订单,管理个人收货地址,确认收货等功能。用户浏览商城的农产品产品后可以将农产品商品添加到购物车中,然后下单支付购买。用户登陆后可以在个人中心中管理自己的购物车信息、订单信息、收货地址信息等。同样在商城前端页面中提供了全文搜索功能,用户可以根据农产品的关键字来查询符合自己要的农产品商品。
系统同样提供了强大的后台管理系统,在后台管理模块中可以实现能前台注册用户的管理操作,可以管理所有用户的订单信息,根据订单支付情况进行发货等操作。同样可以管理产品的分类,可以管理商品的信息,以图文的形式来添加商品信息。为了更好了了解商品的销售情况,在后台使用echart实现了商品销售的图形报表和订单的统计报表功能。
系统使用了SpringSecurity框架来管理系统的用户登陆和权限认证操作,以保证系统的安全性。本系统功能完整,页面简洁大方,运行无误,适合做毕业设计使用。
前端页面是产品的重要展示窗口,也是和用户进和交互的主要阵地,前端的页面设计一是要美观大方,二是要功能齐全。现在整个商业形态中都在以用户体验为中心,各家商家为了给用户更好的体验花费不少功夫。本项目的前端用户交互设计以异步请求为主,提高系统的响应时间和用户的体验。在功能设计上主要满足,电子产品分类浏览,添加购物车,产品下单购买,个人订单管理等功能。具体如下图1所示:
图
编辑
图1 前端用户用例图
基于Springboot实现的茶叶商城网站后台数据管理功能,主要完成对前端页面所产生的相关业务数据进行管理。比如对注册用户的管理、茶叶的管理、用户的订单管理、产品分类的管理等等。后台管理可以有效的帮助网站运营者查看相关信息等等,是至关重要的一环。基于Springboot实现的茶叶商城网站后台管理的用例图如下图2所示:
编辑
基于Springboot实现的农产品销售管理系统选择关系型数据库管理数据。系统使用MySQL提供的方法、技术,对已经确定的数据库逻辑结构,以较优的存储结构等进行设计,设计出对应的数据库表。
(1)用户信息表(s_user)的内容是有关用户的信息,包含前端用户信息和后台管理用户信息,通过字段type来进行区别,0表示管理,1表示普通用户,详细内容如表4.1所示。
表4-1 s_user(用户账户表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 用户编号 |
username | varchar | 20 | yes | 登陆名称 |
Password | varchar | 20 | yes | 登陆密码 |
Type | Int | 1 | No | 用户类型 |
(2)商品类型表(s_product_type)的存储的是商品的类型信息,主要包含商品分类的名字以及编号和说明信息,具体内容如表4.2所示。
表4-2 s_product_type(商品分类表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 分类编号 |
product_type_name | varchar | 20 | yes | 分类名称 |
product_type_desc | varchar | 50 | yes | 分类描述 |
product_type_icon | varchar | 100 | No | 分类图标 |
(3)商品信息表(s_product)的存储的是茶叶详细信息,主要包含商品名称、展示图片、销售价格、所属商品分类、商品详情图片、所属品牌以及具体的功能说明信息等,具体内容如表4.3所示。
表4-3 s_product (商品信息表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 茶叶编号 |
product _name | varchar | 20 | yes | 茶叶名称 |
product_image | varchar | 200 | yes | 茶叶图片 |
price | double | 100 | No | 茶叶价格 |
product_type | varchar | 100 | No | 茶叶类型 |
product_desc | varchar | 100 | No | 茶叶详情图 |
create_time | datetime | 0 | No | 添加时间 |
product_brand | varchar | 100 | No | 茶叶品牌 |
product_miaoshu | varchar | 200 | NO | 茶叶描述 |
(4)商品订单表(s_order)的存储的是用户购买商品的订单信息,主要包含订单编号、创建时间、收货地址编号、用户编号和状态等,具体内容如表4.4所示。
表4-4 s_order(商品订单表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 订单编号 |
create_time | datetime | 0 | yes | 下单时间 |
receiving_address | varchar | 50 | yes | 收货地址 |
user_id | varchar | 100 | No | 下单用户 |
status | Int | 11 | NO | 订单状态 |
(5)商品订单明细表(s_order_product)的存储的是用户购买商品的订单明细信息,它关联订单基础信息表,并包含所购商品的编号以及数量等,具体内容如表4.5所示。
表4-5 s_order_product(商品订单明细表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 明细编号 |
order_id | varchar | 32 | yes | 下单编号 |
product_id | varchar | 32 | yes | 产品编号 |
product_num | Int | 11 | NO | 产品数量 |
(6)商品品牌表(s_brand)的存储的是用户购买商品的品牌信息,在发布商品时,要指定它的所属品牌,以便让消费者选择,主要包含品牌名称、品牌类型、品牌图片等,具体内容如表4.6所示。
表4-6 s_brand(商品品牌表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 品牌编号 |
brand_name | varchar | 32 | yes | 品牌名称 |
brand_type | varchar | 32 | yes | 品牌类型 |
brand_img | varchar | 200 | NO | 品牌图片 |
(7)轮播图信息表(s_carousel)的存储的是前端展示的轮播图片信息等,具体内容如表4.7所示。
表4-6 s_carousel(轮播图信息表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 主键编号 |
url | varchar | 100 | yes | 图片地址 |
sequence_num | int | 2 | NO | 序号 |
(8)收货地址信息表(s_receiving_address)的存储的是用户在线下单购买茶叶时指定收货地址信息,每个用户可以指定多个收货信息,也可以设置默认的收货地址等,具体内容包含收货地址、收件人名称,联系人电话,用户编号以及是否为默认地址等,如表4.8所示。
表4-8 s_receiving_address (收货信息表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 地址编号 |
receiving_address | varchar | 100 | yes | 地址信息 |
receiving_person | varchar | 100 | yes | 收货人 |
mobile_phone | bigint | 20 | NO | 联系电话 |
user_id | varchar | 32 | NO | 用户编号 |
is_default | int | 1 | NO | 是否默认 |
(9)搜索历史信息表(s_search_history)的存储的是前端用户搜索的历史信息,根据用户关键词的信息给用户进行相应的进示,主要包含搜索关键词、搜索次数、搜索时间,如表4.9所示。
表4-9 s_search_history(搜索信息表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 主键编号 |
search_words | varchar | 100 | yes | 搜索词 |
num | int | 2 | NO | 次数 |
search_time | datetime | 0 | NO | 搜索时间 |
(10)购物车信息表(s_shop_cart)的存储的是前端用户使用的购物车基本信息,如表4.10所示。
表4-10 s_shop_cart(购物车信息表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 主键编号 |
Cart_id | varchar | 64 | yes | 购物车编号 |
User_id | varchar | 64 | NO | 用户编号 |
(11)购物车明细表(s_shop_cart_product)的存储的是前端用户使用的购物车中的详细信息,如表4.11所示。
表4-11 s_shop_cart_product(购物车详细信息表)
ColumnName | Type | Length | IsNull | Comment |
Id | int | 11 | no | 主键编号 |
shop_cart_id | varchar | 64 | yes | 购物车编号 |
product_id | varchar | 64 | NO | 茶叶编号 |
product_num | int | 6 | NO | 数量 |
三,系统展示
系统前端功能首页
编辑
注册
编辑
登录
编辑
分类查看
编辑
商品详情
编辑
购物车
编辑
收货地址管理
编辑
我的订单
编辑
全文检索
编辑
后台管理功能展示
编辑
轮播图管理
编辑
分类管理
编辑
品牌管理编辑
商品管理
编辑
订单管理
编辑
图形报表统计
编辑
编辑
四,核心代码展示
package com.yw.eshop.controller.admin;
import com.yw.eshop.domain.Brand;
import com.yw.eshop.domain.ProductType;
import com.yw.eshop.service.BrandService;
import com.yw.eshop.service.ProductTypeService;
import com.yw.eshop.utils.PageModel;
import com.yw.eshop.service.BrandService;
import com.yw.eshop.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 品牌管理
*/
@Controller
@RequestMapping("/admin/brand")
public class BrandController {
@Autowired
private BrandService brandService;
@Autowired
private ProductTypeService productTypeService;
@RequestMapping("/list")
public String list( @RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5")Integer pageSize,
Model model){
try {
PageModel<Brand> brandPages = brandService.queryBrandPages(pageNo, pageSize);
model.addAttribute("brandPages", brandPages);
} catch (Exception e) {
e.printStackTrace();
model.addAttribute("errMessage", "查询失败:"+e.getMessage());
return "500";
}
return "admin/brand/list";
}
@RequestMapping("addPage")
public String addPage(Model model){
List<ProductType> productTypes= productTypeService.queryProductTypeAll();
model.addAttribute("productTypes",productTypes);
return "admin/brand/add";
}
@RequestMapping("/add")
private String addBrand(Brand brand,Model model){
try {
int i = brandService.addBrand(brand);
if (i==0){
model.addAttribute("errMessage","服务器繁忙操作失败");
return "500";
}
}catch (Exception e){
model.addAttribute("errMessage",e.getMessage());
return "500";
}
model.addAttribute("url", "admin/brand/list");
return "success";
}
@RequestMapping("updatePage")
public String updatePage(String id,Model model){
Brand brand= brandService.queryBrandById(id);
List<ProductType> productTypes= productTypeService.queryProductTypeAll();
model.addAttribute("productTypes",productTypes);
model.addAttribute("brand",brand);
return "admin/brand/update";
}
@RequestMapping("/update")
private String update(Brand brand,Model model){
try {
int i = brandService.updateBrand(brand);
if (i==0){
model.addAttribute("errMessage","服务器繁忙操作失败");
return "500";
}
}catch (Exception e){
model.addAttribute("errMessage",e.getMessage());
return "500";
}
model.addAttribute("url", "admin/brand/list");
return "success";
}
@RequestMapping("deletePage")
public String deletePage(String id,Model model){
model.addAttribute("id",id);
return "admin/carousel/delete";
}
@RequestMapping("/delete")
public String delete(String id, Model model){
try {
int i = brandService.delete(id);
if (i==0){
model.addAttribute("errMessage","服务器繁忙操作失败");
return "500";
}
}catch (Exception e){
model.addAttribute("errMessage",e.getMessage());
return "500";
}
model.addAttribute("url", "admin/brand/list");
return "success";
}
@RequestMapping("batchDel")
@ResponseBody
public String batchDel(String[] ids) {
System.out.println("进来了");
brandService.batchProductTypeDel(ids);
return "/admin/brand/list";
}
}
package com.yw.eshop.controller.front;
import com.yw.eshop.domain.Order;
import com.yw.eshop.domain.OrderProduct;
import com.yw.eshop.domain.User;
import com.yw.eshop.service.OrderProductService;
import com.yw.eshop.service.OrderService;
import com.yw.eshop.service.OrderProductService;
import com.yw.eshop.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
import java.util.List;
/**
* 前台订单控制器
*/
@Controller
@RequestMapping("front/order")
public class FrontOrderController {
@Autowired
private OrderService orderService;
@Autowired
private OrderProductService orderProductService;
/**
* 前台个人中心订单查询
* @param session
* @param model
* @return
*/
@RequestMapping("index")
private String index(HttpSession session, Model model){
try {
User user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/front/login/loginPage";
} else {
List<Order> list = orderService.queryAllOrder(user.getId());
for (Order order : list) {
List<OrderProduct> orderProducts = orderProductService.queryOrderProByOrderId(order.getId());
order.setList(orderProducts);
}
model.addAttribute("list", list);
return "front/order/order";
}
}catch (Exception e){
e.printStackTrace();
model.addAttribute("errMessage","服务器繁忙"+e.getMessage());
return "500";
}
}
/**
* 前台用户取消订单:条件是未发货状态
* @param id
* @param model
* @return
*/
@RequestMapping("/delete")
@ResponseBody
public String delete(String id, Model model){
model.addAttribute("id", id);
try {
int i = orderService.delete(id);
if (i==0){
model.addAttribute("errMessage","服务器繁忙操作失败");
return "500";
}
}catch (Exception e){
model.addAttribute("errMessage",e.getMessage());
return "500";
}
//return "forward:/front/order/index";
model.addAttribute("url", "/front/order/index");
return "success";
}
/**
* 前台用户确认收货:条件是己发货状态
* @param id
* @param model
* @return
*/
@RequestMapping("/update")
@ResponseBody
public String update(String id,Integer status, Model model){
model.addAttribute("id", id);
try {
int i = orderService.updateStatus(id,status);
if (i==0){
model.addAttribute("errMessage","服务器繁忙操作失败");
return "500";
}
}catch (Exception e){
model.addAttribute("errMessage",e.getMessage());
return "500";
}
//return "forward:/front/order/index";
model.addAttribute("url", "/front/order/index");
return "success";
}
}
五,项目总结
本系统基于Springboot开发框架集成Mybatis框架实现了一个农业商品销售管理系统,前端设计美丽大方,功能实现完整,适合做毕业设计使用。