基于SSM的电商购物网站设计与实现

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:Vue
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


目录

一、项目简介

二、系统功能

三、系统项目截图

用户信息管理

商品类型管理

商品信息管理

用户注册

商品购买与收藏

我的订单

四、核心代码

登录相关

文件上传

封装


一、项目简介

使用旧方法对电商购物信息进行系统化管理已经不再让人们信赖了,把现在的网络信息技术运用在电商购物信息的管理上面可以解决许多信息管理上面的难题,比如处理数据时间很长,数据存在错误不能及时纠正等问题。

这次开发的电商购物网站管理员功能有个人中心,用户管理,商品类型管理,商品信息管理,留言板管理,系统管理,订单管理等。用户可以注册登录,查看商品,购买商品,留言等操作。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择B/S模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行电商购物网站程序的开发,在数据库的选择上面,选择功能强大的MySQL数据库进行数据的存放操作。

电商购物网站被人们投放于现在的生活中进行使用,该款管理类软件就可以让管理人员处理信息的时间介于十几秒之间。在这十几秒内就能完成信息的编辑等操作。有了这样的管理软件,电商购物信息的管理就离无纸化办公的目标更贴近了。


二、系统功能



三、系统项目截图

用户信息管理

管理员可以修改,删除用户信息。下图就是用户信息管理页面。

商品类型管理

管理员可以对商品类型信息进行添加,修改,删除,查询操作。下图就是商品类型信息管理页面。

商品信息管理

管理员可以对商品信息进行添加,修改,删除,查询操作。下图就是商品信息管理页面。

 

用户注册

用户需要注册才可以登录。下图就是用户注册页面。

 

商品购买与收藏

用户可以对商品进行购买与收藏。下图就是商品购买与收藏页面。

 

我的订单

用户购买后会产生订单,在我的订单里查看。下图就是我的订单页面。

 


四、核心代码

登录相关


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

文件上传

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

封装

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/199848.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

贵州乾辰谷材 以科技创新引领绝缘材料领域的新发展

贵州乾辰谷材科技有限公司&#xff0c;这家于2018年10月18日成立的贵州本地企业&#xff0c;已经在绝缘材料领域崭露头角。乾辰谷材不仅在成立短短几年内实现了快速成长&#xff0c;更以其科技创新能力和卓越产品性能赢得了业界和用户的广泛赞誉。 乾辰谷材的创始人王金斗先生&…

社区团购小程序源码系统 带会员功能+会员积分+会员分组+会员等级 附带部署与搭建的完整教程

社区团购小程序源码系统是一种基于微信小程序的电商系统&#xff0c;它通过社交电商模式&#xff0c;将社区居民、商家和平台紧密结合&#xff0c;实现便捷的线上购物和线下社区服务。该系统支持会员功能、会员积分、会员分组和会员等级等功能&#xff0c;为用户提供更加个性化…

SeaTunnel引擎下的SQL Server CDC解决方案:构建高效数据管道

在快速发展的数据驱动时代&#xff0c;实时数据处理已经成为企业决策和运营的关键因素。特别是在处理来自各种数据源的信息时&#xff0c;如何确保数据的及时、准确和高效同步变得尤为重要。本文着重介绍了如何利用 SqlServer CDC 源连接器在 SeaTunnel 框架下实现 SQL Server …

Spring Boot进行单元测试,一个思路解决重启低效难题!

所谓单元测试就是对功能最小粒度的测试&#xff0c;落实到JAVA中就是对单个方法的测试。 junit可以完成单个方法的测试&#xff0c;但是对于Spring体系下的web应用的单元测试是无能为力的。因为spring体系下的web应用都采用了MVC三层架构&#xff0c;依托于IOC&#xff0c;层级…

【AIGC】关于Prompt你必须知道的特性

代码和数据:https://github.com/tonyzhaozh/few-shot-learning 一、实践验证的大模型的特性 1. 大模型的偏差 示例&#xff1a;&#xff08;文本的情感分析&#xff1a;一句话->P(积极&#xff09;或者N&#xff08;消极) Input: I hate this movie. Sentiment: Negativ…

线下渠道应该如何控价

品牌渠道中的问题&#xff0c;大多跟价格有关&#xff0c;比如低价、窜货、假货&#xff0c;治理好这些价格问题&#xff0c;也就是在解决渠道中的低价问题&#xff0c;所以要先了解价格&#xff0c;再进行治理&#xff0c;这样的流程化操作&#xff0c;可以使品牌管控好渠道价…

unity的多语言配置工具

demo下载:https://github.com/JSumC/LanguageExcel using System; using System.Collections.Generic; using System.IO; using System.Linq; using OfficeOpenXml; using UnityEngine; using UnityEngine.UI; namespace LanguageExcel {public class LETool : MonoBehaviour{…

cpu飙升问题排查以及解决

1、查看内存占用排行 top -c 2、查看服务器内存使用情况 free -h 3、查看文件夹磁盘空间大小 Linux 查看各文件夹大小命令du -h --max-depth1 (1)查看文件目录一级目录磁盘空间 du -h --max-depth1 (2&#xff09;查看指定文件目录 du sh home --max-depth2 4、Linux下…

苹果手机怎么卸载微信?记得掌握这两种方法!

微信是一款社交应用程序&#xff0c;在聊天过程中&#xff0c;我们会经常发送和接收各种形式的信息。随着时间的推移&#xff0c;微信缓存的文件会越来越多&#xff0c;占用的存储空间也会逐渐增加。 卸载微信可以释放手机内存&#xff0c;提高手机的运行速度。那么&#xff0…

揭秘Git高手的10个秘密武器:让你的工作效率飙升!

Git和GitHub是每个软件工程师都必须了解的最基本的工具。它们是开发人员日常工作不可或缺的一部分&#xff0c;每天都要与之互动。 精通Git不仅能简化你的日常操作&#xff0c;还能显著提高生产力。在这篇文章中&#xff0c;我们将探讨一组能够极大提升生产力的命令。 随着对…

运维笔记111

运维笔记 Navicat中查询指定字段名所在的表名tomcat设置JVM的初始堆内存修改catalina.sh文件修改完保存并关闭tomcat启动tomcat 查询数据库连接数查询是否存在死锁 Navicat中查询指定字段名所在的表名 SELECT * FROM information_schema.COLUMNS WHERE COLUMN_NAME‘替换成你要…

基于加拿大降水分析 (CaPA) 系统的北美区域确定性降水数据集

区域确定性降水分析 (RDPA) 基于加拿大降水分析 (CaPA) 系统的区域确定性降水分析 (RDPA) 的域与业务区域模式相对应&#xff0c;即区域确定性预报系统 (RDPS-LAM3D)&#xff0c;但太平洋地区除外其中 RDPA 域的西边边界相对于区域模型域稍微向东移动。RDPA 分析的分辨率与运行…

宋仕强论道之华强北的商业配套(十三)

宋仕强论道之华强北的商业配套&#xff08;十三&#xff09;&#xff1a;金航标电子萨科微半导体总经理宋仕强先生发布“宋仕强论道”系列视频&#xff0c;分享多年学习、生活和工作经验和感悟&#xff0c;甚至涵盖了文学、艺术、哲学、宗教。这段时间发表的是对华强北&#xf…

如何与LEONI建立EDI连接?

莱尼LEONI是一家为汽车及其他行业提供能源数据管理产品、解决方案及服务的全球供应商。供应链范围从研发生产标准化电缆、特种电缆和数据电缆到高度复杂的布线系统和相关组件。本文将介绍如何与莱尼LEONI建立EDI连接。 什么是EDI&#xff1f; EDI全称Electronic Data Interch…

LeetCode.24两两交换链表中的节点

LeetCode.24两两交换链表中的节点 1.问题描述2.解题思路3.代码 1.问题描述 给你一个链表&#xff0c;两两交换其中相邻的节点&#xff0c;并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题&#xff08;即&#xff0c;只能进行节点交换&#xff09;。 示…

孩子写作业用的护眼灯哪种好?适合考研的护眼台灯推荐

随着现在小孩子的近视率越来越高&#xff0c;全国中小学生近视比率占大多数&#xff0c;许多家长也开始为孩子的健康成长而担忧&#xff0c;这时很多家长就会选择护眼台灯来为孩子保驾护航。但面对市面上五花八门的台灯品牌&#xff0c;各式各样的台灯许多家长却乱了阵脚&#…

vue elementUI 自定义框组织树,选择select下拉组织树横行滑动条出现方法

背景&#xff1a;最近公司开发需要使用到组织树进行组织结构的选择&#xff0c;在开发途中遇到两个次组织树已超过外框&#xff0c;但超出部分不显示横向滑动条。 自定义组织树框代码如下&#xff1a; <el-row><el-col :span"20" style"padding: 0px…

【前端】three.js

文章目录 概述three.js-master目录结构Threejs 的基本要素场景相机透视相机正交相机 网格2d3d 灯光AmbientLight(环境光)平行光&#xff08;DirectionalLight&#xff09;点光源&#xff08;PointLight&#xff09;聚光灯&#xff08;SpotLight&#xff09; 渲染器 Threejs 的实…

Scrum敏捷开发流程及支撑工具

Scrum是一种敏捷开发框架&#xff0c;用于管理复杂的项目。以下这些步骤构成了Scrum敏捷开发流程的核心。通过不断迭代、灵活应对变化和持续反馈&#xff0c;Scrum框架帮助团队快速交付高质量的产品。 以下是Scrum敏捷开发流程的基本步骤&#xff1a; 产品Backlog创建&#xf…

Python 图形用户界面详解(GUI,Tkinter)

文章目录 1 概述1.1 TK&#xff1a;窗口1.2 官方文档 2 组件2.1 Label&#xff1a;标签2.2 Button&#xff1a;按钮2.3 Entry&#xff1a;输入2.4 Text&#xff1a;文本2.5 Radiobutton&#xff1a;单选框2.6 Checkbutton&#xff1a;复选框2.7 Canvas&#xff1a;画布2.10 Men…