基于SSM的校内互助交易平台设计

news2024/9/27 12:09:40

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


目录

一、项目简介

二、系统功能

管理员模块的实现

学生信息管理

发布者信息管理

任务分类管理

发布者模块的实现

资源信息管理

任务信息管理

学生模块的实现

资源购买管理

任务领取管理

三、核心代码

登录相关

文件上传

封装


一、项目简介

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

本校内互助交易平台有有管理员,学生,发布者。管理员功能有个人中心,学生管理,发布者管理,校园资讯管理,资源信息管理,任务信息管理,资源分类管理,任务分类管理,留言板管理,校园论坛,系统管理等。发布者功能有个人中心,资源信息管理,任务信息管理,资源购买管理,任务领取管理。学生功能有个人中心,资源购买管理,任务领取管理。因而具有一定的实用性。

本站是一个B/S模式系统,采用SSM框架作为开发技术,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;
	}
}

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

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

相关文章

idea开发jface、swt环境搭建

背景 jface、swt很难找到合适的maven仓库来下载配套的版本idea对eclipse套件不友好eclipse的windowbuilder固然很好&#xff0c; 但本人更喜欢idea编程&#xff0c; 互相取长补短 下载套件 进入swt下载界面 以当前最新的4.29为例&#xff0c; 点击&#xff1a; 找到全部并…

02-微服务的拆分规则和基于RestTemplate的远程调用

微服务的拆分与远程调用 创建父工程 任何分布式架构都离不开服务的拆分, 微服务也是一样 , 微服务的拆分遵守三个原则 微服务需要根据业务模块拆分,不同微服务不要重复开发相同业务每个微服务都有自己独立的数据库, 不要直接访问其他微服务的数据库微服务可以将自己的业务暴…

第28期 | GPTSecurity周报

GPTSecurity是一个涵盖了前沿学术研究和实践经验分享的社区&#xff0c;集成了生成预训练Transformer&#xff08;GPT&#xff09;、人工智能生成内容&#xff08;AIGC&#xff09;以及大型语言模型&#xff08;LLM&#xff09;等安全领域应用的知识。在这里&#xff0c;您可以…

多样式按钮

代码&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"viewport" content"widthdevice-…

使用 ClickHouse 做日志分析

原作&#xff1a;Monika Singh & Pradeep Chhetri 这是我们在 Monitorama 2022 上发表的演讲的改编稿。您可以在此处找到包含演讲者笔记的幻灯片和此处的视频。 当 Cloudflare 的请求抛出错误时&#xff0c;信息会记录在我们的 requests_error 管道中。错误日志用于帮助解…

OpenHarmony 4.1计划明年Q1发布, 5.0预计Q3发布

据HarmonyOS官方组织透露&#xff0c;OpenHarmony 4.0 版本已于 10 月 26 日正式发布&#xff0c;开发套件同步升级到 API 10。开放原子开源基金会现更新了 OpenHarmony 4.1&5.0 版本路线图。据介绍&#xff0c;OpenHarmony 4.1 Beta 版本预计将于年底完成测试并发布&#…

如何用 GPTs 帮你写科研项目申请书?

&#xff08;注&#xff1a;本文为小报童精选文章&#xff0c;已订阅小报童或加入知识星球「玉树芝兰」用户请勿重复付费&#xff09; 需求 学生们往往会觉得&#xff0c;写开题报告是个苦差事。但他们或许不知道&#xff0c;老师们写起科研项目申请书&#xff0c;压力远比他们…

RK3568平台开发系列讲解(Linux系统篇)kernel config 配置解析

🚀返回专栏总目录 文章目录 一、图形化界面的操作二、Kconfig 语法简介三、.config 配置文件介绍四、deconfig 配置文件沉淀、分享、成长,让自己和他人都能有所收获!😄 📢 Linux 内核可以通过输入“make menuconfig”来打开图形化配置界面,menuconfig 是一套图形化的配…

Kafka 控制器(controller)

Kafka 控制器&#xff08;controller&#xff09; 在kafka集群中 会存在一个或者多个broker&#xff08;一个服务器就是一个broker&#xff09;&#xff0c;其中有一个broker会被选举为控制器 kafka controller &#xff0c;负责管理整个集群中所有副本、分区的状态&#xff0…

2021秋招-数据结构-栈、队列、数组、列表

栈、队列、数组、列表 实现方式 队列 class Queue:def __init__(self):self.items []def enqueue(self, item):self.items.append(item)def dequeue(self):return self.items.pop(0)def empty(self):return self.size() 0def size(self):return len(self.items)应用: 约瑟…

shell 脚本语句

目录 条件语句 test 命令 比较整数数值 字符串比较 命令举 条件逻辑测试操作 组合写法 举例 双中括号 ​编辑 ( ) / { } if 语句的结构 case 语句 脚本举例 识别 yes 和 no 脚本 检查磁盘使用情况脚本 新建用户以及随机设置用户密码的脚本 补充命令 [RANDOM…

Python+Qt虹膜检测识别

程序示例精选 PythonQt虹膜检测识别 如需安装运行环境或远程调试&#xff0c;见文章底部个人QQ名片&#xff0c;由专业技术人员远程协助&#xff01; 前言 这篇博客针对《PythonQt虹膜检测识别》编写代码&#xff0c;代码整洁&#xff0c;规则&#xff0c;易读。 学习与应用推…

【C++进阶之路】第十一篇:C++的IO流

文章目录 1. C语言的输入与输出2. 流是什么3. CIO流3.1 C标准IO流3.2 C文件IO流 4.stringstream的简单介绍 1. C语言的输入与输出 C语言中我们用到的最频繁的输入输出方式就是scanf ()与printf()。 scanf(): 从标准输入设备(键盘)读取数据&#xff0c;并将值存放在变量中。prin…

京东数据分析(京东数据采集):2023年10月京东平板电视行业品牌销售排行榜

鲸参谋监测的京东平台10月份平板电视市场销售数据已出炉&#xff01; 根据鲸参谋电商数据分析平台的相关数据显示&#xff0c;10月份&#xff0c;京东平台上平板电视的销量将近77万&#xff0c;环比增长约23%&#xff0c;同比则下降约30%&#xff1b;销售额为21亿&#xff0c;环…

大数据Doris(二十七):Routine Load数据导入演示

文章目录 Routine Load数据导入演示 一、启动kafka集群(三台节点都启动) 二、创建topic

「MACOS限定」 如何将文件上传到GitHub仓库

介绍 本期讲解&#xff1a;如何在苹果电脑上上传文件到github远程仓库 注&#xff1a;写的很详细 方便我的朋友可以看懂操作步骤 第一步 在电脑上创建一个新目录&#xff08;文件夹&#xff09; 注&#xff1a;创建GitHub账号、新建github仓库、git下载的步骤这里就不过多赘…

数据库基本操作--------高级MySQL语句

一、高级SQL语句 1、SELECT ----显示表格中一个或数个栏位的所有资料 语法&#xff1a;SELECT “栏位” FROM “表名”; SELECT Store_Name FROM Store_Info; 2、DISTINCT ----不显示重复的资料 语法&#xff1a;SELECT DISTINCT “栏位” FROM “表名”; SELECT DISTINCT Sto…

Docker快速搭建RTMP服务(tiangolo/nginx-rtmp:Docker + Nginx+ nginx-rtmp-module)

Linux Docker快速搭建多媒体/视频流的 RTMP 服务 第一步 安装Docker 点击这里查看 第二步 拉取并运行镜像 tiangolo/nginx-rtmp/ docker pull tiangolo/nginx-rtmp docker run -d -p 1935:1935 --name nginx-rtmp tiangolo/nginx-rtmpOBS客户端测试 OBS客户端设置直播的推…

【python笔记】客户运营 - cohort分析

一、数据 本文涉及数据下载链接。 二、数据预处理 2.1 读取数据 import pandas as pddf pd.read_csv(your_path/Year 2010-2011.csv, encodingISO-8859-1) df.head()2.2 检查数据 检查空值情况 df.isna().sum() # 结果 Invoice 0 StockCode 0 De…

LeetCode 热题100——栈与队列专题(三)

一、有效的括号 20.有效的括号&#xff08;题目链接&#xff09; 思路&#xff1a; 1&#xff09;括号的顺序匹配&#xff1a;用栈实现&#xff0c;遇到左括号入&#xff0c;遇到右括号出&#xff08;保证所出的左括号与右括号对应&#xff09;&#xff0c;否则顺序不匹配。 2…