博主主页:猫头鹰源码
博主简介:Java领域优质创作者、CSDN博客专家、公司架构师、全网粉丝5万+、专注Java技术领域和毕业设计项目实战
主要内容:毕业设计(Javaweb项目|小程序等)、简历模板、学习资料、面试题库、技术咨询
文末联系获取
项目介绍:
该系统创作于2022年2月,包含详细数据库设计。基于SSM整合,数据层为MyBatis,mysql数据库,支持支付宝沙箱支付功能,具有完整的业务逻辑,适合选题:商城、化妆品商城、网上购物、网购、在线购物等。
项目功能:
用户:登陆注册、商品详情、分类查看、筛选商品、加入购物车、支付宝沙箱支付、收藏、评价、我的订单、地址维护
管理员:登陆、用户管理、分类管理、商品管理、订单维护、快递管理、评价管理、修改密码
具备完整的商城业务逻辑。
数据库表结构文档:
系统包含技术:
后端:SSM
前端:bootstrap,js,css等
开发工具:idea
数据库:mysql 5.7
JDK版本:jdk1.8
tomcat版本:tomcat8
部分截图说明:
下面是用户首页
分类查看商品信息
点击某个商品,可以查看详情,也可以评论,收藏
点击加入购物车,可以购买
然后可以下单,下单后,可以支付
下面是用户管理
商品管理,可以新增商品
快递管理,下单时候用到
订单管理,可以看到不同状态的订单
部分代码:
后台商品的管理
@RequestMapping("/showjson")
@ResponseBody
public Msg getAllGoods(@RequestParam(value = "page", defaultValue = "1") Integer pn, HttpServletResponse response, Model model, HttpSession session) {
Admin admin = (Admin) session.getAttribute("admin");
if (admin == null) {
return Msg.fail("请先登录");
}
//一页显示几个数据
PageHelper.startPage(pn, 10);
List<Goods> employees = goodsService.selectByExample1(new GoodsExample());
List<Category> categories = cateService.selectByExample(new CategoryExample());
for(int i=0;i<employees.size();i++){
int finalI = i;
List<Category> filter = categories.stream().filter(a->a.getCateid().equals(employees.get(finalI).getCategory())).collect(Collectors.toList());
if(filter!=null && filter.size()==1){
employees.get(i).setCatename(filter.get(0).getCatename());
}
}
//显示几个页号
PageInfo page = new PageInfo(employees, 5);
model.addAttribute("pageInfo", page);
return Msg.success("查询成功!").add("pageInfo", page);
}
/**
* @Description: 管理员查询所有商品
* @Param: [pn, response, model, session]
* @return: java.lang.String
* @Author: Mr.Wang
* @Date: 2021/3/14
*/
@RequestMapping("/show")
public String goodsManage(@RequestParam(value = "page", defaultValue = "1") Integer pn, HttpServletResponse response, Model model, HttpSession session) throws IOException {
Admin admin = (Admin) session.getAttribute("admin");
if (admin == null) {
return "redirect:/admin/login";
}
List<Category> categoryList = cateService.selectByExample(new CategoryExample());
model.addAttribute("categoryList", categoryList);
return "adminAllGoods";
}
/**
* @Description: 管理员查询所有评论
* @Param: [pn, response, model, session]
* @return: java.lang.String
* @Author: Mr.Wang
* @Date: 2021/3/14
*/
@RequestMapping("/message")
public String message(@RequestParam(value = "page", defaultValue = "1") Integer pn, HttpServletResponse response, Model model, HttpSession session) throws IOException {
Admin admin = (Admin) session.getAttribute("admin");
if (admin == null) {
return "redirect:/admin/login";
}
List<Category> categoryList = cateService.selectByExample(new CategoryExample());
model.addAttribute("categoryList", categoryList);
return "adminAllComment";
}
/**
* @Description: 评论
* @Param: [pn, response, model, session]
* @return: com.zhang.ssmschoolshop.util.Msg
* @Author: Mr.Wang
* @Date: 2021/3/14
*/
@RequestMapping("/commentJson")
@ResponseBody
public Msg commentJson(@RequestParam(value = "page", defaultValue = "1") Integer pn, HttpServletResponse response, Model model, HttpSession session) {
Admin admin = (Admin) session.getAttribute("admin");
if (admin == null) {
return Msg.fail("请先登录");
}
//一页显示几个数据
CommentExample commentExample = new CommentExample();
PageHelper.startPage(pn, 10);
List<Comment> commentList = commentService.selectByExample(commentExample);
UserExample userExample = new UserExample();
List<User> userList = userService.selectByExample(userExample);
GoodsExample goodsExample = new GoodsExample();
List<Goods> goodsList = goodsService.selectByExample(goodsExample);
List<CommentVo> list = new ArrayList<>();
for(int i = 0;i<commentList.size();i++){
CommentVo commentVo = new CommentVo();
commentVo.setCommentid(commentList.get(i).getCommentid());
commentVo.setContent(commentList.get(i).getContent());
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
commentVo.setCommenttime(sdf.format(commentList.get(i).getCommenttime()));
for(int j = 0;j<userList.size();j++){
if(commentList.get(i).getUserid().equals(userList.get(j).getUserid())){
commentVo.setUserName(userList.get(j).getUsername());
}
}
for(int n = 0;n<goodsList.size();n++){
if(commentList.get(i).getGoodsid().equals(goodsList.get(n).getGoodsid())){
commentVo.setShopName(goodsList.get(n).getGoodsname());
}
}
if(commentList.get(i).getPoint()==1){
commentVo.setLevel("一星");
}else if(commentList.get(i).getPoint()==2){
commentVo.setLevel("二星");
}else if(commentList.get(i).getPoint()==3){
commentVo.setLevel("三星");
}else if(commentList.get(i).getPoint()==4){
commentVo.setLevel("四星");
}else if(commentList.get(i).getPoint()==5){
commentVo.setLevel("五星");
}
list.add(commentVo);
}
//显示几个页号
PageInfo page = new PageInfo(list, 5);
model.addAttribute("pageInfo", page);
return Msg.success("查询成功!").add("pageInfo", page);
}
登录功能
@RequestMapping("/login")
public String adminLogin() {
return "adminLogin";
}
@RequestMapping("/confirmLogin")
public String confirmLogin(Admin admin, Model model, HttpServletRequest request) {
Admin selectAdmin = adminService.selectByName(admin);
if (selectAdmin == null) {
model.addAttribute("errorMsg", "用户名或密码错误");
return "adminLogin";
} else {
HttpSession session = request.getSession();
session.setAttribute("admin", selectAdmin);
return "redirect:/admin/user/show";
}
}
@RequestMapping("/logout")
public String adminLogout(HttpServletRequest request) {
HttpSession session = request.getSession();
session.removeAttribute("admin");
return "redirect:/admin/login";
}
前台商品详情展示
/**
* @Description: 商品详情
* @Param: [goodsid, model, session]
* @return: java.lang.String
* @Author: Mr.Wang
* @Date: 2021/3/14
*/
@RequestMapping(value = "/detail",method = RequestMethod.GET)
public String detailGoods(Integer goodsid, Model model, HttpSession session) {
if(goodsid == null) {
return "redirect:/main";
}
User user = (User) session.getAttribute("user");
//要传回的数据存在HashMap中
Map<String,Object> goodsInfo = new HashMap<String,Object>();
//查询商品的基本信息
Goods goods = goodsService.selectById(goodsid);
if (user == null) {
goods.setFav(false);
} else {
Favorite favorite = goodsService.selectFavByKey(new FavoriteKey(user.getUserid(), goodsid));
if (favorite == null) {
goods.setFav(false);
} else {
goods.setFav(true);
}
}
//查询商品类别
Category category = cateService.selectById(goods.getCategory());
//商品图片
List<ImagePath> imagePath = goodsService.findImagePath(goodsid);
//商品评论
//返回数据
goodsInfo.put("goods", goods);
goodsInfo.put("cate", category);
goodsInfo.put("image", imagePath);
model.addAttribute("goodsInfo",goodsInfo);
//评论信息
CommentExample commentExample=new CommentExample();
commentExample.or().andGoodsidEqualTo(goods.getGoodsid());
List<Comment> commentList=commentService.selectByExample(commentExample);
for (Integer i=0;i<commentList.size();i++)
{
Comment comment=commentList.get(i);
User commentUser=userService.selectByPrimaryKey(comment.getUserid());
comment.setUserName(commentUser.getUsername());
commentList.set(i,comment);
}
CategoryExample categoryExample = new CategoryExample();
categoryExample.setOrderByClause("cateId");
List<Category> categories = cateService.selectByExample(categoryExample);
model.addAttribute("categorys", categories);
model.addAttribute("commentList",commentList);
return "detail";
}
以上就是部分功能展示,从整体上来看,本系统功能是十分完整的,界面设计简洁大方,交互友好,数据库设计也很合理,规模适中,代码工整,清晰,适合学习使用。
好了,今天就到这儿吧,小伙伴们点赞、收藏、评论,一键三连走起呀,下期见~~