基于SSM的学生二手书籍交易平台的设计与实现

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


目录

一、项目简介

二、系统功能

三、系统项目截图

留言反馈管理

我的订单管理

订单发货

我的收藏

书籍分类管理

留言板管理

四、核心代码

登录相关

文件上传

封装


一、项目简介

随着信息互联网购物的飞速发展,一般企业都去创建属于自己的管理系统。本文介绍了学生二手书籍交易平台的开发全过程。通过分析企业对于学生二手书籍交易平台的需求,创建了一个计算机管理学生二手书籍交易平台的方案。文章介绍了学生二手书籍交易平台的系统分析部分,包括可行性分析等,系统设计部分主要介绍了系统功能设计和数据库设计。

本学生二手书籍交易平台功能有个人中心,用户管理,卖家管理,书籍分类管理,书籍信息管理,留言板管理,管理员管理,系统管理等。因而具有一定的实用性。

本站是一个B/S模式系统,采用SSM框架作为开发技术,MYSQL数据库设计开发,充分保证系统的稳定性。系统具有界面清晰、操作简单,功能齐全的特点,使得学生二手书籍交易平台管理工作系统化、规范化。

关键词:学生二手书籍交易平台;SSM框架;MYSQL数据库


二、系统功能

本系统是基于B/S架构的网站系统,设计的功能结构图如下图所示:



三、系统项目截图

留言反馈管理

学生用户可以发布留言反馈。

我的订单管理

用户登录可以在个人中心查看我的订单信息。

 

订单发货

卖家可以在已支付订单里面进行发货操作。

我的收藏

员工用户登录后,在我的收藏管理里面可以对我的收藏信息进行查看和删除操作。

 

书籍分类管理

管理员可以对书籍分类进行添加修改删除操作。

留言板管理

管理员可以对用户留言信息进行回复和删除操作。

 


四、核心代码

登录相关


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/128259.html

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

相关文章

Nmap-NSE

一.Nmap的脚本引擎类别 参数说明ALL允许所有的脚本Auth认证Default默认的脚本引擎&#xff0c;-sC&#xff1a;equivalent to --script default 或 --script default &#xff0c;执行一些脚本的脚本扫描Discovery发现&#xff0c;获取目标的深度信息External扩展&#xff0c…

说说你在使用React 过程中遇到的常见问题?如何解决?

一、前言 在使用react开发项目过程中&#xff0c;每个人或多或少都会遇到一些"奇怪"的问题&#xff0c;本质上都是我们对其理解的不够透彻 react 系列&#xff0c;33个工作日&#xff0c;33次凌晨还在亮起的台灯&#xff0c;到今天就圆满画上句号了&#xff0c;比心…

OpenAI开发者大会大模型圈开卷AI Agent? 实在智能布局前瞻已下“先手棋”

“平地起惊雷&#xff0c;至今有余音。” 去年的11月&#xff0c;OpenAI发布ChatGPT给科技圈劈下了一道惊雷&#xff0c;引爆了全世界的AI大模型热潮&#xff0c;全球科技巨头公司争先恐后地推出通用大模型&#xff0c;探索产业应用的可能。 短短一年后&#xff0c;北京时间1…

docker可视化

什么是portainer&#xff1f; portainer就是docker图形化界面的管理工具&#xff0c;提供一个后台面板供我们操作 目前先用portainer(先用这个)&#xff0c;以后还会用到Rancher(CI/CD在用) 1.下载portainer 9000是内网端口&#xff0c;8088是外网访问端口 docker run…

C#时间类的使用方法

在C#编程中&#xff0c;日期和时间的处理是常见的任务之一。C#提供了多个类来处理日期、时间和时区的操作&#xff0c;包括DateTime、TimeSpan和DateTimeOffset。 目录 1. DateTime类1.1 创建DateTime对象1.2 获取日期和时间信息1.3 格式化日期和时间1.4 比较日期和时间 2. Tim…

中国集成电路设计业2023年会演讲预告 | 龙智Perforce专家解析半导体设计中的数字资产管理

2023年11月10-11日&#xff08;周五-周六&#xff09;&#xff0c;龙智即将亮相于广州举行的中国集成电路设计业2023年会&#xff08;ICCAD 2023&#xff09;&#xff0c;呈现集成了Perforce与Atlassian产品的芯片开发解决方案&#xff0c;帮助企业实现数智化转型&#xff0c;革…

Vue3 + Naive-ui Data Table 分页页码显示不全

当使用naive-ui 表格并且使用分页组件的时候 需要增加 remote

包教包会:Mysql主从复制搭建

笑小枫的专属目录 一、无聊的理论知识1. 主从复制原理2. 主从复制的工作过程3. MySQL四种同步方式 二、docker下安装、启动mysql1. 安装主库2. 安装从库 三、配置Master(主)四、配置Slave(从)五、链接Master(主)和Slave(从)六、主从复制排错1. 错误&#xff1a;error connectin…

软文推广优化技巧:如何写出有创意的文案

今天媒介盒子要给大家分享的干货内容就是&#xff1a;如何写出有创意的文案。 时代背景会改变&#xff0c;大众的趣味焦点也会转移&#xff0c;同样再好的文案也会失效&#xff0c;但文案背后的触发机制不会变。下面是能够使广告文案起作用的关键因素&#xff1a; 一、 研究产…

【Android】TabLayout设置使用自定义的样式的图片显示问题

序言 TabLayout我们经常使用&#xff0c;用来和ViewPager2进行组合使用&#xff0c;做多Fragment切换页面效果。 TabLayout我们经常看到的的显示效果是上面文字&#xff0c;下面一个线段&#xff0c;在各大浏览器/新闻类APP可以看到&#xff0c;这个效果也是对TabLayout配置参…

C# .NET Core API 注入Swagger

C# .NET Core API 注入Swagger 环境 Windows 10Visual Studio 2019(2017就有可以集中发布到publish目录的功能了吧)C#.NET Core 可跨平台发布代码,超级奈斯NuGet 套件管理dll将方法封装(据说可以提高效率,就像是我们用的dll那种感觉)Swagger 让接口可视化编写时间2020-12-09 …

灵活运用Vue指令:探究v-if和v-for的使用技巧和注意事项

&#x1f3ac; 江城开朗的豌豆&#xff1a;个人主页 &#x1f525; 个人专栏 :《 VUE 》 《 javaScript 》 &#x1f4dd; 个人网站 :《 江城开朗的豌豆&#x1fadb; 》 ⛺️ 生活的理想&#xff0c;就是为了理想的生活 ! 目录 ⭐ 专栏简介 &#x1f4d8; 文章引言 一、作…

【虹科干货】Lambda数据架构和Kappa数据架构——构建现代数据架构

如何更好地构建我们的数据处理架构&#xff0c;如何对IT系统中的遗留问题进行现代化改造并将其转变为现代数据架构&#xff1f;该怎么为你的需求匹配最适合的架构设计呢&#xff0c;本文将分析两种最流行的基于速度的数据架构&#xff0c;为你提供一些思路。 文章速览&#xf…

电商大促演变:拼多多百亿补贴的消费升级体验

出品| 大力财经 文 | 魏力 拼多多已经够便宜了&#xff0c;双十一还能怎么玩&#xff1f;作为一个曾经被认为是深耕五环外消费者的电商平台&#xff0c;这几年拼多多从五环外杀到市中心&#xff0c;现在的国人&#xff0c;不管是中产&#xff0c;还是职场小白&#xff0c;人人…

四川思维跳动商务信息咨询有限公司是真的吗?

随着数字时代的到来&#xff0c;短视频平台抖音已经成为亿万用户每日必刷的社交媒体。不少有远见的公司也意识到了这个平台的巨大潜力&#xff0c;纷纷投身其中&#xff0c;寻求新的商业机会。四川思维跳动商务信息咨询有限公司就是这样一家企业&#xff0c;他们提供的抖音电商…

C++结构体定义 创建 赋值 结构体数组

结构体是什么&#xff1f; struct是自定义数据类型&#xff0c;是一些类型集合组成的一个类型。结构体的定义方式 #include<iostream> using namespace std;struct Student {string name;int age;int score; };创建结构体变量并赋值 方式一&#xff0c;先创建结构体变…

完整版付费进群带定位源码

看到别人发那些不是挂羊头卖狗肉&#xff0c;要么就是发的缺少文件引流的。恶心的一P 这源码是我付费花钱买的分享给大家&#xff0c;功能完整。 搭建教程 nginx1.2 php5.6--7.2均可 最好是7.2 第一步上传文件程序到网站根目录解压 第二步导入数据库&#xff08;shujuk…

偶数科技亮相2023中国程序员节——数据库技术高峰论坛

2023年10月24日&#xff0c;由中国软件行业协会主办的“中国程序员节”在北京、深圳、宁波多地同时召开&#xff0c;其中数据库技术高峰论坛在北京举办&#xff0c;偶数科技亮相本次论坛并分享了题为《大模型、实时需求推动湖仓平台走向开放》的主题演讲。 国际局势复杂、科技竞…

C语言中指针的用法以及相应的作用

目录 什么是指针&#xff1f; 指针的基本操作 &#xff08;1&#xff09;变量地址引用&#xff1a; &#xff08;2&#xff09;动态内存分配&#xff1a; &#xff08;3&#xff09;数组和字符串操作&#xff1a; &#xff08;4&#xff09;函数参数传递&#xff1a; &a…

Android Mvp案例解析

目录 后端数据接口数据格式 App客户端布局逻辑主界面布局 M&#xff08;Model&#xff09;V&#xff08;View&#xff09;P&#xff08;Presenter&#xff09;OkhttpRetrofitRxJava网络http请求 Mvp架构-初学者MVP架构的契约者 后端数据接口 接口地址&#xff1a;https://apis.…