基于SSM的校园二手交易管理系统的设计与实现

news2024/9/20 20:23:01

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


目录

一、项目简介

二、系统功能

三、系统项目截图

管理员功能实现

商家管理

用户管理

公告信息管理

商家功能实现

商品管理

商品评价管理

商品订单管理

用户功能实现

商家信息

商品信息

购物车

确认下单

商品订单

四、核心代码

登录相关

文件上传

封装


一、项目简介

计算机网络发展到现在已经好几十年了,在理论上面已经有了很丰富的基础,并且在现实生活中也到处都在使用,可以说,经过几十年的发展,互联网技术已经把地域信息的隔阂给消除了,让整个世界都可以即时通话和联系,极大的方便了人们的生活。所以说,校园二手交易管理系统用计算机技术来进行设计,不仅在管理方面更加的系统化,操作性强,最重要的是关于数据的保存和使用都能节约大量的时间,该系统非常的好用。

校园二手交易管理系统管理数据的工具是MySQL,编码的语言是Java,运用的框架是SSM框架。该系统可以实现商品管理,商品评价管理,商品收藏管理,商品订单管理,购物车管理,公告管理,商家管理等功能。

校园二手交易管理系统不仅能让操作人员使用更加地方便,并且设计的也很合理,能有效的避免误操作,让数据在录入的环节就符合设计需要,极大的规避了源头性的输入误差,顺利的让数据变得更加可控并且可靠,让出错的几率降到最低。


二、系统功能

对管理员具体功能的设计结果将以图4.1所示的管理员功能结构图来进行体现。管理员对于校园二手交易管理系统操作的功能包括管理商家,管理基础数据,管理用户,管理商品,其中管理商品模块包括管理商品评价,管理商品收藏,管理商品订单等。

 对商家具体功能的设计结果将以图4.2所示的商家功能结构图来进行体现。商家对于校园二手交易管理系统操作的功能包括管理商品信息,回复商品评价,管理商品的订单,查看公告等。

 对用户具体功能的设计结果将以图4.3所示的用户功能结构图来进行体现。用户对于校园二手交易管理系统操作的功能包括购买商品,查看商家,查看公告,管理购物车。

 



三、系统项目截图

管理员功能实现

商家管理

该功能主要用于实现对商家基本信息的管理,商家管理界面的运行效果见图5.1。在此界面,管理员根据商家名称查询商家,可以修改,删除商家资料。

 

用户管理

该功能主要用于实现对用户基本信息的管理,用户管理界面的运行效果见图5.2。在此界面,管理员更改用户头像,电子邮箱等信息,可以帮助用户重置密码,可以删除需要删除的用户。

 

公告信息管理

该功能主要用于实现对公告基本信息的管理,公告信息管理界面的运行效果见图5.3。在此界面,管理员对公告进行增删改查。

 

商家功能实现

商品管理

该功能主要用于实现对商品基本信息的管理,商品管理界面的运行效果见图5.4。在此界面,商家为商品增加库存,为商品减少库存,修改商品,删除商品等。

 

商品评价管理

该功能主要用于实现对商品评价基本信息的管理,商品评价管理界面的运行效果见图5.5。在此界面,商家回复评价商品的用户,查看用户评价商品的内容。

 

商品订单管理

该功能主要用于实现对商品订单基本信息的管理,商品订单管理界面的运行效果见图5.6。在此界面,商家对订单商品发货,查询订单,查看商品订单的详情。

 

用户功能实现

商家信息

商家信息界面的运行效果见图5.7。在此界面,用户查询商家,需要提供商家的名称才可以查询指定的商家信息,用户点击商家的照片就可以查看商家的介绍。

 

商品信息

商品信息界面的运行效果见图5.8。在此界面,用户可以对商品进行的操作包括收藏,查看商品的评论信息,加入购物车,立即购买等。

 

购物车

购物车界面的运行效果见图5.9。在此界面,用户对购物车里面的商品进行移除或改变购物商品的数量,最后下单支付。

 

确认下单

确认下单界面的运行效果见图5.10。在此界面,用户选择收货地址,如果没有合适的收货地址,可以直接添加收货地址,选择支付方式,有线上支付,线下取货两种方式可供选择,用户根据实际情况选择适合的方式进行支付即可,用户在列表详情核对购买的商品就可以提交订单了。

 

商品订单

商品订单界面的运行效果见图5.11。在此界面,用户可以对订单商品进行退款,收货,评价等操作。

 


四、核心代码

登录相关


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;
	}
}

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

使用HttpSession和过滤器实现一个简单的用户登录认证的功能

这篇文章分享一下怎么通过session结合过滤器来实现控制登录访问的功能&#xff0c;涉及的代码非常简单&#xff0c;通过session保存用户登录的信息&#xff0c;如果没有用户登录的话&#xff0c;会在过滤器中处理&#xff0c;重定向回登录页面。 创建一个springboot项目&#…

BSP视频教程第29期:J1939协议栈CAN总线专题,源码框架,执行流程和应用实战解析,面向车通讯,充电桩,模组通信等(2024-01-08)

视频教程汇总帖&#xff1a;【学以致用&#xff0c;授人以渔】2024视频教程汇总&#xff0c;DSP第12期&#xff0c;ThreadX第9期&#xff0c;BSP驱动第29期&#xff0c;USB实战第5期&#xff0c;GUI实战第3期&#xff08;2024-01-08&#xff09; - STM32F429 - 硬汉嵌入式论坛 …

书生·浦语大模型全链路开源体系 学习笔记 第二课

基础作业&#xff1a; 使用 InternLM-Chat-7B 模型生成 300 字的小故事&#xff08;需截图&#xff09;。熟悉 hugging face 下载功能&#xff0c;使用 huggingface_hub python 包&#xff0c;下载 InternLM-20B 的 config.json 文件到本地&#xff08;需截图下载过程&#xf…

Typecho 最新XC主题 去除域名授权全解密源码

Typecho 最新XC主题 去除域名授权全解密源码 这是一款多样式主题&#xff0c;首页支持六种主题样式&#xff0c;支持Pjax优化访问速度&#xff0c;多种单页&#xff0c;如友链、说说等。评论支持表情&#xff0c;自定义编辑器&#xff0c;支持其他样式功能。该主题功能性挺高&…

【数值分析】最佳平方逼近,最佳逼近

最佳平方逼近 ∑ k 0 n W k ( f ( x k ) − ϕ ( x k ) ) 2 min ⁡ \sum_{k0}^{ n}W_k (f(x_k)-\phi (x_k))^2\min k0∑n​Wk​(f(xk​)−ϕ(xk​))2min → 节点非常多时 ∫ a b ρ ( x ) ( f ( x ) − ϕ ( x ) ) 2 d x min ⁡ \xrightarrow[]{\text{节点非常多时}} \int_…

vue3 内置组件

文章目录 前言一、过渡效果相关的组件1、Transition2、TransitionGroup 二、状态缓存组件&#xff08;KeepAlive&#xff09;三、传送组件&#xff08;Teleport &#xff09;四、异步依赖处理组件&#xff08;Suspense&#xff09; 前言 在vue3中 其提供了5个内置组件 Transiti…

【HarmonyOS4.0】第二篇-鸿蒙开发介绍

一、鸿蒙开发介绍 1.1.为什么要学习鸿蒙&#xff1f; 2019年HarmonyOS正式面世&#xff0c;至今鸿蒙已成长了4年&#xff0c;截至2023年8月&#xff0c;鸿蒙生态设备数量超过7亿台&#xff0c;已有220万开发者投入到鸿蒙生态的开发。根据Counterpoint最新数据&#xff0c;202…

【数据库基础】Mysql与Redis的区别

看到一篇不错的关于“Mysql与Redis的区别”的文章&#xff0c;转过来记录下~ 文章目录 一、数据库类型二、运行机制三、什么是缓存数据库呢&#xff1f;四、优缺点比较五、区别总结六、数据可以全部直接用Redis储存吗&#xff1f;参考资料 一、数据库类型 Redis&#xff1a;NOS…

uni-app如何生成骨架屏

骨架屏是页面的一个空白版本&#xff0c;通常会在页面完全渲染之前&#xff0c;通过一些灰色的区块大致勾勒出轮廓&#xff0c;待数据加载完成后&#xff0c;再替换成真实的内容。 参考效果 骨架屏作用是缓解用户等待时的焦虑情绪&#xff0c;属于用户体验优化方案。 生成骨…

Vue、uniApp、微信小程序、Html5等实现数缓存

此文章带你实现前端缓存&#xff0c;利用时间戳封装一个类似于Redis可以添加过期时间的缓存工具 不仅可以实现对缓存数据设置过期时间&#xff0c;还可以自定义是否需要对缓存数据进行加密处理 工具介绍说明 对缓存数据进行非对称加密处理 对必要数据进行缓存&#xff0c;并…

docker/华为云cce 部署nacos 2.3.0 集群模式

镜像地址 https://hub.docker.com/r/nacos/nacos-server 版本 nacos/nacos-server:v2.3.0-slim 关键环境变量 使用mysql数据源 变量值备注MODEcluster启用集群模式MYSQL_SERVICE_DB_NAME数据库名MYSQL_SERVICE_USER数据库用户名MYSQL_SERVICE_PASSWORD数据库密码SPRING_D…

线扫相机品牌汇总(国外+国内)

线扫相机品牌汇总(国外+国内) 行者 ​ 热爱生活 22 人赞同了该文章 线扫相机也叫做线阵相机,和面阵相机一样,都是重要的工业相机。 线扫相机正如其名字那样,拍照时像扫描一样,相机和被拍照物体有相对匀速运动。 Perhaps the most common example of line scan imagin…

【代码随想录算法训练营-第七天】【哈希表】454,383,15,18

454. 四数相加 II 第一遍 思路 想不出来&#xff0c;除了暴力解法&#xff0c;完全想不出来其他解法&#xff0c;看答案思路了…学习了两个新的方法&#xff1a; getOrDefault&#xff1a;返回指定键对应的值&#xff0c;如果不存在&#xff0c;则返回默认值containsKey&…

java Servlet体育馆运营管理系统myeclipse开发mysql数据库网页mvc模式java编程计算机网页设计

一、源码特点 JSP 体育馆运营管理系统是一套完善的java web信息管理系统&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统采用serlvetdaobean&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用 B/S模式开发。 java Servlet体育馆运营管理系…

Spring 动态数据源事务处理

在一般的 Spring 应用中,如果底层数据库访问采用的是 MyBatis,那么在大多数情况下,只使用一个单独的数据源,Spring 的事务管理在大多数情况下都是有效的。然而,在一些复杂的业务场景下,如需要在某一时刻访问不同的数据库,由于 Spring 对于事务管理实现的方式,可能不能达…

基于YOLOv8全系列【n/s/m/l/x】开发构建道路交通场景下CCTSDB2021交通标识检测识别系统

交通标志检测是交通标志识别系统中的一项重要任务。与其他国家的交通标志相比&#xff0c;中国的交通标志有其独特的特点。卷积神经网络&#xff08;CNN&#xff09;在计算机视觉任务中取得了突破性进展&#xff0c;在交通标志分类方面取得了巨大的成功。CCTSDB 数据集是由长沙…

SkyWalking介绍和Docker环境下部署

一、Skywalking概述 1、Skywalking介绍 Skywalking是分布式系统的应用程序性能监视工具&#xff0c;专为微服务&#xff0c;云原生架构和基于容器&#xff08;Docker&#xff0c;K8S,Mesos&#xff09;架构而设计&#xff0c;它是一款优秀的APM&#xff08;Application Perfo…

CentOS 7 安装私有平台OpenNebula

目录 一、配置yum源 二、配置数据库MySQL 2.1 安装MySQL 2.2 修改MySQL密码 2.3 创建项目用户和库 三、安装配置前端包 四、设置oneadmin账号密码 五、验证安装 5.1 命令行验证安装 5.2 数据存放位置 5.3 端口介绍 5.4 命令介绍 六、访问 6.1 设置语言 6.2 创建主…

【Python学习】Python学习8-Number

目录 【Python学习】Python学习8-Number 前言在变量赋值时被创建Python支持四种不同的数据类型整型(Int)长整型(long integers&#xff09;浮点型(loating point real values)复数(complex numbers) Python Number 类型转换Python math 模块、cmath 模块Python数学函数Python随…

每日一题——LeetCode1021删除最外层括号1047消除字符串相邻重复字符串

这两道题基本上来说是差不多的&#xff0c;一个匹配并删除字符串中的( ) 一个匹配并删除字符串中相邻重复的元素&#xff0c;其实都是用到栈这种数据结构&#xff0c;通过匹配不同的条件使用入栈出栈操作保存或删除目标元素来实现。 1021.删除最外层括号 var removeOuterParent…