文章目录
- 汽车商城系统
- 一、系统演示
- 二、项目介绍
- 三、部分功能截图
- 四、部分代码展示
- 五、底部获取项目源码(9.9¥带走)
汽车商城系统
一、系统演示
汽车商城
二、项目介绍
该汽车商城系统主要分为前台和后台两大功能模块,共包含两种角色,分别是:用户、管理员。
1.前台功能模块
前台首页、网站公告、推荐商品、特价商品、全部商品、商品搜索、分类展示、汽车浏览、用户登陆、用户注册、个人中心、修改密码、我的订单、我的收藏、购物车、结算付款、查看订单明细、评论留言等功能
2.后台管理模块
后台系统登陆、管理员信息管理、客户信息管理、供应商信息管理、汽车类型管理、汽车信息管理、入库信息管理、订单信息管理、出库信息管理、评价信息管理、网站公告管理等功能
项目技术
语言:java
框架:Spring、SpringMVC、MyBatis、jsp、jQuery 、Layui
数据库:MySQL
三、部分功能截图
四、部分代码展示
package com.action;
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 AdminAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
private AdminService adminService;
// 管理员登录 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 "admin/index";
} 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());
this.getSession().setAttribute("role", admin.getRole());
} else {
this.getRequest().setAttribute("message", "密码错误");
return "admin/index";
}
}
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 "admin/index";
}
// 准备添加数据
@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);
}
if ("role".equals(cond)) {
admin.setRole(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";
}
public AdminService getAdminService() {
return adminService;
}
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
}
package com.action;
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.util.PageHelper;
import com.util.VeDate;
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/article", produces = "text/plain;charset=utf-8")
public class ArticleAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
private ArticleService articleService;
// 准备添加数据
@RequestMapping("createArticle.action")
public String createArticle() {
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 ("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);
return "admin/editarticle";
}
public ArticleService getArticleService() {
return articleService;
}
public void setArticleService(ArticleService articleService) {
this.articleService = articleService;
}
}
package com.action;
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.Cart;
import com.service.CartService;
import com.entity.Goods;
import com.entity.Users;
import com.service.GoodsService;
import com.service.UsersService;
import com.util.PageHelper;
import com.util.VeDate;
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/cart", produces = "text/plain;charset=utf-8")
public class CartAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
private CartService cartService;
@Autowired
private GoodsService goodsService;
@Autowired
private UsersService usersService;
// 准备添加数据
@RequestMapping("createCart.action")
public String createCart() {
List<Goods> goodsList = this.goodsService.getAllGoods();
this.getRequest().setAttribute("goodsList", goodsList);
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
return "admin/addcart";
}
// 添加数据
@RequestMapping("addCart.action")
public String addCart(Cart cart) {
cart.setAddtime(VeDate.getStringDateShort());
this.cartService.insertCart(cart);
return "redirect:/cart/createCart.action";
}
// 通过主键删除数据
@RequestMapping("deleteCart.action")
public String deleteCart(String id) {
this.cartService.deleteCart(id);
return "redirect:/cart/getAllCart.action";
}
// 批量删除数据
@RequestMapping("deleteCartByIds.action")
public String deleteCartByIds() {
String[] ids = this.getRequest().getParameterValues("cartid");
for (String cartid : ids) {
this.cartService.deleteCart(cartid);
}
return "redirect:/cart/getAllCart.action";
}
// 更新数据
@RequestMapping("updateCart.action")
public String updateCart(Cart cart) {
this.cartService.updateCart(cart);
return "redirect:/cart/getAllCart.action";
}
// 显示全部数据
@RequestMapping("getAllCart.action")
public String getAllCart(String number) {
List<Cart> cartList = this.cartService.getAllCart();
PageHelper.getPage(cartList, "cart", null, null, 10, number, this.getRequest(), null);
return "admin/listcart";
}
// 按条件查询数据 (模糊查询)
@RequestMapping("queryCartByCond.action")
public String queryCartByCond(String cond, String name, String number) {
Cart cart = new Cart();
if (cond != null) {
if ("goodsid".equals(cond)) {
cart.setGoodsid(name);
}
if ("usersid".equals(cond)) {
cart.setUsersid(name);
}
if ("price".equals(cond)) {
cart.setPrice(name);
}
if ("num".equals(cond)) {
cart.setNum(name);
}
if ("addtime".equals(cond)) {
cart.setAddtime(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.cartService.getCartByLike(cart), "cart", nameList, valueList, 10, number, this.getRequest(), "query");
name = null;
cond = null;
return "admin/querycart";
}
// 按主键查询数据
@RequestMapping("getCartById.action")
public String getCartById(String id) {
Cart cart = this.cartService.getCartById(id);
this.getRequest().setAttribute("cart", cart);
List<Goods> goodsList = this.goodsService.getAllGoods();
this.getRequest().setAttribute("goodsList", goodsList);
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
return "admin/editcart";
}
public CartService getCartService() {
return cartService;
}
public void setCartService(CartService cartService) {
this.cartService = cartService;
}
}
package com.action;
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.Instorage;
import com.service.InstorageService;
import com.entity.Goods;
import com.entity.Admin;
import com.service.GoodsService;
import com.service.AdminService;
import com.util.PageHelper;
import com.util.VeDate;
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/instorage", produces = "text/plain;charset=utf-8")
public class InstorageAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
private InstorageService instorageService;
@Autowired
private GoodsService goodsService;
@Autowired
private AdminService adminService;
// 准备添加数据
@RequestMapping("createInstorage.action")
public String createInstorage() {
List<Goods> goodsList = this.goodsService.getAllGoods();
this.getRequest().setAttribute("goodsList", goodsList);
List<Admin> adminList = this.adminService.getAllAdmin();
this.getRequest().setAttribute("adminList", adminList);
return "admin/addinstorage";
}
// 添加数据
@RequestMapping("addInstorage.action")
public String addInstorage(Instorage instorage) {
instorage.setAddtime(VeDate.getStringDateShort());
this.instorageService.insertInstorage(instorage);
Goods goods = this.goodsService.getGoodsById(instorage.getGoodsid());
int n = Integer.parseInt(goods.getStorage()) + Integer.parseInt(instorage.getNum());
goods.setStorage("" + n);
this.goodsService.updateGoods(goods);
return "redirect:/instorage/createInstorage.action";
}
// 通过主键删除数据
@RequestMapping("deleteInstorage.action")
public String deleteInstorage(String id) {
this.instorageService.deleteInstorage(id);
return "redirect:/instorage/getAllInstorage.action";
}
// 批量删除数据
@RequestMapping("deleteInstorageByIds.action")
public String deleteInstorageByIds() {
String[] ids = this.getRequest().getParameterValues("instorageid");
for (String instorageid : ids) {
this.instorageService.deleteInstorage(instorageid);
}
return "redirect:/instorage/getAllInstorage.action";
}
// 更新数据
@RequestMapping("updateInstorage.action")
public String updateInstorage(Instorage instorage) {
this.instorageService.updateInstorage(instorage);
return "redirect:/instorage/getAllInstorage.action";
}
// 显示全部数据
@RequestMapping("getAllInstorage.action")
public String getAllInstorage(String number) {
List<Instorage> instorageList = this.instorageService.getAllInstorage();
PageHelper.getPage(instorageList, "instorage", null, null, 10, number, this.getRequest(), null);
return "admin/listinstorage";
}
// 按条件查询数据 (模糊查询)
@RequestMapping("queryInstorageByCond.action")
public String queryInstorageByCond(String cond, String name, String number) {
Instorage instorage = new Instorage();
if (cond != null) {
if ("goodsid".equals(cond)) {
instorage.setGoodsid(name);
}
if ("num".equals(cond)) {
instorage.setNum(name);
}
if ("adminid".equals(cond)) {
instorage.setAdminid(name);
}
if ("addtime".equals(cond)) {
instorage.setAddtime(name);
}
}
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.instorageService.getInstorageByLike(instorage), "instorage", nameList, valueList, 10, number, this.getRequest(),
"query");
name = null;
cond = null;
return "admin/queryinstorage";
}
// 按主键查询数据
@RequestMapping("getInstorageById.action")
public String getInstorageById(String id) {
Instorage instorage = this.instorageService.getInstorageById(id);
this.getRequest().setAttribute("instorage", instorage);
List<Goods> goodsList = this.goodsService.getAllGoods();
this.getRequest().setAttribute("goodsList", goodsList);
List<Admin> adminList = this.adminService.getAllAdmin();
this.getRequest().setAttribute("adminList", adminList);
return "admin/editinstorage";
}
public InstorageService getInstorageService() {
return instorageService;
}
public void setInstorageService(InstorageService instorageService) {
this.instorageService = instorageService;
}
}
五、底部获取项目源码(9.9¥带走)
有问题,或者需要协助调试运行项目的也可以