计算机毕业设计 基于SpringBoot的社区物资交易互助平台/系统的设计与实现 Java实战项目 附源码+文档+视频讲解

博主介绍:✌从事软件开发10年之余,专注于Java技术领域、Python人工智能及数据挖掘、小程序项目开发和Android项目开发等。CSDN、掘金、华为云、InfoQ、阿里云等平台优质作者✌
🍅文末获取源码联系🍅
👇🏻 精彩专栏推荐订阅👇🏻 不然下次找不到哟
————————————————
计算机毕业设计《1000套》✌

目录

 1、项目介绍及开发技术

1.1 项目介绍

1.2 开发技术

2、系统功能设计结构图

3、功能截图

3.1 前台功能

3.2 后台功能

4、数据库表结构设计

5、关键代码

 5.1 **Controller模块 

5.2 **Service模块 

 5.3 **ServiceImpl模块

 5.4  **Dao模块

6、论文目录结构

7、源码获取


1、项目介绍及开发技术

1.1 项目介绍

随着互联网技术的不断发展,人们的生活方式发生了巨大的变化。在这个信息化时代,人们越来越依赖于网络来获取信息、交流和解决问题。随着城市化进程的加快,越来越多的人涌入城市生活。然而,由于人口密度大、资源有限等原因,社区居民之间的物资交换需求逐渐增加。传统的线下交易方式效率低下,无法满足人们的需求。互联网技术的快速发展为社区物资交易提供了新的可能。通过互联网技术,人们可以实现信息的快速传递和共享,从而降低交易成本、提高交易效率。在这样的背景下,社区物资交易互助平台应运而生,为居民提供了一个便捷、高效的物资交换渠道。

基于Spring Boot的社区物资交易互助平台是一个典型的Web应用程序,它采用了目前流行的微服务架构,具有良好的可扩展性和可维护性。该平台的主要功能包括用户注册与登录、发布物资需求或提供物资、浏览物资列表、在线沟通等。通过这个平台,居民可以方便地找到自己需要的物资,同时也可以将自己的闲置物品提供给需要的人,实现资源的合理利用和共享。

本系统的设计现状和趋势涵盖了需求、结构、数据库等方面的设计,并实现了管理员和用户的特定功能。本文将从系统的设计、描述、实现、分析、测试等方面阐述开发过程。根据现实情况,本系统选择了可行的开发方案,并利用Java编程语言和MySQL数据库等技术实现了系统的全部功能。接下来,对系统进行了测试,以确保其无漏洞,并对用户权限进行了完善。最终,系统达到了相关标准。

1.2 开发技术

Java开发语言、SpringBoot、MyBatisPlus、MySQL数据库、Maven、IDEA开发工具、JDK1.8+、Vue、HTML、CSS、JS。

2、系统功能模块设计

用户:注册登录、首页、论坛、求助留言板、公告信息、物资、个人中心(个人中心、收货地址、物资收藏、物资订单、物资捐赠)。

管理员:登录、首页、个人中心(修改密码、个人信息)、管理员管理、基础数据管理(公告类型管理、物资类型管理、捐赠类型管理)、论坛管理、求助留言板管理、公告信息管理、物资管理(物资管理、物资收藏管理、物资订单管理)、用户管理、轮播图管理。

3、功能截图

3.1 前台功能

登录

首页

论坛 

 求助留言板

 公告信息

 物资

个人中心

3.2 后台功能

登录

首页

个人中心

管理员管理

基础数据管理

论坛管理

求助留言管理

公告信息管理

物资管理

物资捐赠管理

用户管理

轮播图管理

4、数据库表结构设计

/*
SQLyog Ultimate v11.3 (64 bit)
MySQL - 5.7.32-log : Database - shequwuzijiaoyipingtai
*********************************************************************
*//*!40101 SET NAMES utf8 */;/*!40101 SET SQL_MODE=''*/;/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`shequwuzijiaoyipingtai` /*!40100 DEFAULT CHARACTER SET utf8 */;USE `shequwuzijiaoyipingtai`;/*Table structure for table `address` */DROP TABLE IF EXISTS `address`;CREATE TABLE `address` (`id` int(20) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`yonghu_id` int(20) NOT NULL COMMENT '创建用户',`address_name` varchar(200) NOT NULL COMMENT '收货人 ',`address_phone` varchar(200) NOT NULL COMMENT '电话 ',`address_dizhi` varchar(200) NOT NULL COMMENT '地址 ',`isdefault_types` int(11) NOT NULL COMMENT '是否默认地址 ',`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间 show3',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='收货地址';/*Data for the table `address` */insert  into `address`(`id`,`yonghu_id`,`address_name`,`address_phone`,`address_dizhi`,`isdefault_types`,`insert_time`,`update_time`,`create_time`) values (1,2,'收货人1','17703786901','地址1',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(2,1,'收货人2','17703786902','地址2',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(3,3,'收货人3','17703786903','地址3',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(4,1,'收货人4','17703786904','地址4',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(5,3,'收货人5','17703786905','地址5',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(6,2,'收货人6','17703786906','地址6',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(7,3,'收货人7','17703786907','地址7',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(8,2,'收货人8','17703786908','地址8',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(9,1,'收货人9','17703786909','地址9',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(10,2,'收货人10','17703786910','地址10',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(11,3,'收货人11','17703786911','地址11',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(12,1,'收货人12','17703786912','地址12',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(13,1,'收货人13','17703786913','地址13',2,'2023-03-21 10:29:31','2023-03-21 10:55:28','2023-03-21 10:29:31'),(14,1,'收货人14','17703786914','地址14',1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31');/*Table structure for table `config` */DROP TABLE IF EXISTS `config`;CREATE TABLE `config` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`name` varchar(100) DEFAULT NULL COMMENT '配置参数名称',`value` varchar(100) DEFAULT NULL COMMENT '配置参数值',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='配置文件';/*Data for the table `config` */insert  into `config`(`id`,`name`,`value`) values (1,'轮播图1','upload/config1.jpg'),(2,'轮播图2','upload/config2.jpg'),(3,'轮播图3','upload/config3.jpg');/*Table structure for table `dictionary` */DROP TABLE IF EXISTS `dictionary`;CREATE TABLE `dictionary` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`dic_code` varchar(200) DEFAULT NULL COMMENT '字段',`dic_name` varchar(200) DEFAULT NULL COMMENT '字段名',`code_index` int(11) DEFAULT NULL COMMENT '编码',`index_name` varchar(200) DEFAULT NULL COMMENT '编码名字  Search111 ',`super_id` int(11) DEFAULT NULL COMMENT '父字段id',`beizhu` varchar(200) DEFAULT NULL COMMENT '备注',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8 COMMENT='字典';/*Data for the table `dictionary` */insert  into `dictionary`(`id`,`dic_code`,`dic_name`,`code_index`,`index_name`,`super_id`,`beizhu`,`create_time`) values (38,'shangxia_types','上下架',1,'上架',NULL,NULL,'2023-03-21 10:29:19'),(39,'shangxia_types','上下架',2,'下架',NULL,NULL,'2023-03-21 10:29:19'),(40,'wuzi_types','物资类型',1,'物资类型1',NULL,NULL,'2023-03-21 10:29:19'),(41,'wuzi_types','物资类型',2,'物资类型2',NULL,NULL,'2023-03-21 10:29:19'),(42,'wuzi_types','物资类型',3,'物资类型3',NULL,NULL,'2023-03-21 10:29:19'),(43,'wuzi_collection_types','收藏表类型',1,'收藏',NULL,NULL,'2023-03-21 10:29:19'),(44,'wuzi_order_types','订单类型',101,'已支付',NULL,NULL,'2023-03-21 10:29:19'),(45,'wuzi_order_types','订单类型',102,'已退款',NULL,NULL,'2023-03-21 10:29:19'),(46,'wuzi_order_types','订单类型',103,'已派送',NULL,NULL,'2023-03-21 10:29:19'),(47,'wuzi_order_types','订单类型',104,'已收货',NULL,NULL,'2023-03-21 10:29:19'),(48,'wuzi_order_payment_types','订单支付类型',1,'余额',NULL,NULL,'2023-03-21 10:29:19'),(49,'isdefault_types','是否默认地址',1,'否',NULL,NULL,'2023-03-21 10:29:19'),(50,'isdefault_types','是否默认地址',2,'是',NULL,NULL,'2023-03-21 10:29:19'),(51,'wuzijuanzeng_types','捐赠类型',1,'捐赠类型1',NULL,NULL,'2023-03-21 10:29:19'),(52,'wuzijuanzeng_types','捐赠类型',2,'捐赠类型2',NULL,NULL,'2023-03-21 10:29:19'),(53,'news_types','公告类型',1,'公告类型1',NULL,NULL,'2023-03-21 10:29:19'),(54,'news_types','公告类型',2,'公告类型2',NULL,NULL,'2023-03-21 10:29:19'),(55,'sex_types','性别类型',1,'男',NULL,NULL,'2023-03-21 10:29:19'),(56,'sex_types','性别类型',2,'女',NULL,NULL,'2023-03-21 10:29:19'),(57,'forum_state_types','帖子状态',1,'发帖',NULL,NULL,'2023-03-21 10:29:19'),(58,'forum_state_types','帖子状态',2,'回帖',NULL,NULL,'2023-03-21 10:29:19');/*Table structure for table `forum` */DROP TABLE IF EXISTS `forum`;CREATE TABLE `forum` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`forum_name` varchar(200) DEFAULT NULL COMMENT '帖子标题  Search111 ',`yonghu_id` int(11) DEFAULT NULL COMMENT '用户',`users_id` int(11) DEFAULT NULL COMMENT '管理员',`forum_content` longtext COMMENT '发布内容',`super_ids` int(11) DEFAULT NULL COMMENT '父id',`forum_state_types` int(11) DEFAULT NULL COMMENT '帖子状态',`insert_time` timestamp NULL DEFAULT NULL COMMENT '发帖时间',`update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show2',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='论坛';/*Data for the table `forum` */insert  into `forum`(`id`,`forum_name`,`yonghu_id`,`users_id`,`forum_content`,`super_ids`,`forum_state_types`,`insert_time`,`update_time`,`create_time`) values (1,'帖子标题1',2,NULL,'发布内容1',383,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(2,'帖子标题2',1,NULL,'发布内容2',472,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(3,'帖子标题3',1,NULL,'发布内容3',254,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(4,'帖子标题4',3,NULL,'发布内容4',30,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(5,'帖子标题5',3,NULL,'发布内容5',174,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(6,'帖子标题6',1,NULL,'发布内容6',169,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(7,'帖子标题7',2,NULL,'发布内容7',487,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(8,'帖子标题8',1,NULL,'发布内容8',30,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(9,'帖子标题9',1,NULL,'发布内容9',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(10,'帖子标题10',1,NULL,'发布内容10',10,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(11,'帖子标题11',2,NULL,'发布内容11',353,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(12,'帖子标题12',2,NULL,'发布内容12',121,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(13,'帖子标题13',3,NULL,'发布内容13',65,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(14,'帖子标题14',2,NULL,'发布内容14',209,1,'2023-03-21 10:29:31','2023-03-21 10:29:31','2023-03-21 10:29:31'),(15,NULL,1,NULL,'论坛讨论11111',14,2,'2023-03-21 10:56:39',NULL,'2023-03-21 10:56:39'),(16,NULL,NULL,1,'123123',14,2,'2023-03-21 10:57:27',NULL,'2023-03-21 10:57:27');/*Table structure for table `liuyan` */DROP TABLE IF EXISTS `liuyan`;CREATE TABLE `liuyan` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`yonghu_id` int(11) DEFAULT NULL COMMENT '用户',`liuyan_name` varchar(200) DEFAULT NULL COMMENT '留言标题  Search111 ',`liuyan_text` longtext COMMENT '留言内容',`insert_time` timestamp NULL DEFAULT NULL COMMENT '留言时间',`reply_text` longtext COMMENT '回复内容',`update_time` timestamp NULL DEFAULT NULL COMMENT '回复时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show2 nameShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='求助留言板';/*Data for the table `liuyan` */insert  into `liuyan`(`id`,`yonghu_id`,`liuyan_name`,`liuyan_text`,`insert_time`,`reply_text`,`update_time`,`create_time`) values (1,1,'留言标题1','留言内容1','2023-03-21 10:29:31','回复信息1','2023-03-21 10:29:31','2023-03-21 10:29:31'),(2,3,'留言标题2','留言内容2','2023-03-21 10:29:31','回复信息2','2023-03-21 10:29:31','2023-03-21 10:29:31'),(3,3,'留言标题3','留言内容3','2023-03-21 10:29:31','回复信息3','2023-03-21 10:29:31','2023-03-21 10:29:31'),(4,1,'留言标题4','留言内容4','2023-03-21 10:29:31','回复信息4','2023-03-21 10:29:31','2023-03-21 10:29:31'),(5,3,'留言标题5','留言内容5','2023-03-21 10:29:31','回复信息5','2023-03-21 10:29:31','2023-03-21 10:29:31'),(6,3,'留言标题6','留言内容6','2023-03-21 10:29:31','回复信息6','2023-03-21 10:29:31','2023-03-21 10:29:31'),(7,2,'留言标题7','留言内容7','2023-03-21 10:29:31','回复信息7','2023-03-21 10:29:31','2023-03-21 10:29:31'),(8,3,'留言标题8','留言内容8','2023-03-21 10:29:31','回复信息8','2023-03-21 10:29:31','2023-03-21 10:29:31'),(9,3,'留言标题9','留言内容9','2023-03-21 10:29:31','回复信息9','2023-03-21 10:29:31','2023-03-21 10:29:31'),(10,2,'留言标题10','留言内容10','2023-03-21 10:29:31','回复信息10','2023-03-21 10:29:31','2023-03-21 10:29:31'),(11,1,'留言标题11','留言内容11','2023-03-21 10:29:31','回复信息11','2023-03-21 10:29:31','2023-03-21 10:29:31'),(12,1,'留言标题12','留言内容12','2023-03-21 10:29:31','回复信息12','2023-03-21 10:29:31','2023-03-21 10:29:31'),(13,3,'留言标题13','留言内容13','2023-03-21 10:29:31','回复信息13','2023-03-21 10:29:31','2023-03-21 10:29:31'),(14,1,'留言标题14','留言内容14','2023-03-21 10:29:31','回复信息14','2023-03-21 10:29:31','2023-03-21 10:29:31'),(15,1,'3546','12312','2023-03-21 10:56:26','12312123','2023-03-21 10:57:34','2023-03-21 10:56:26');/*Table structure for table `news` */DROP TABLE IF EXISTS `news`;CREATE TABLE `news` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`news_name` varchar(200) DEFAULT NULL COMMENT '公告标题  Search111 ',`news_types` int(11) DEFAULT NULL COMMENT '公告类型  Search111 ',`news_photo` varchar(200) DEFAULT NULL COMMENT '公告图片',`insert_time` timestamp NULL DEFAULT NULL COMMENT '添加时间',`news_content` longtext COMMENT '公告详情',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show1 show2 nameShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='公告信息';/*Data for the table `news` */insert  into `news`(`id`,`news_name`,`news_types`,`news_photo`,`insert_time`,`news_content`,`create_time`) values (1,'公告标题1',1,'upload/news1.jpg','2023-03-21 10:29:31','公告详情1','2023-03-21 10:29:31'),(2,'公告标题2',1,'upload/news2.jpg','2023-03-21 10:29:31','公告详情2','2023-03-21 10:29:31'),(3,'公告标题3',1,'upload/news3.jpg','2023-03-21 10:29:31','公告详情3','2023-03-21 10:29:31'),(4,'公告标题4',2,'upload/news4.jpg','2023-03-21 10:29:31','公告详情4','2023-03-21 10:29:31'),(5,'公告标题5',1,'upload/news5.jpg','2023-03-21 10:29:31','公告详情5','2023-03-21 10:29:31'),(6,'公告标题6',1,'upload/news6.jpg','2023-03-21 10:29:31','公告详情6','2023-03-21 10:29:31'),(7,'公告标题7',2,'upload/news7.jpg','2023-03-21 10:29:31','公告详情7','2023-03-21 10:29:31'),(8,'公告标题8',1,'upload/news8.jpg','2023-03-21 10:29:31','公告详情8','2023-03-21 10:29:31'),(9,'公告标题9',1,'upload/news9.jpg','2023-03-21 10:29:31','公告详情9','2023-03-21 10:29:31'),(10,'公告标题10',2,'upload/news10.jpg','2023-03-21 10:29:31','公告详情10','2023-03-21 10:29:31'),(11,'公告标题11',1,'upload/news11.jpg','2023-03-21 10:29:31','公告详情11','2023-03-21 10:29:31'),(12,'公告标题12',1,'upload/news12.jpg','2023-03-21 10:29:31','公告详情12','2023-03-21 10:29:31'),(13,'公告标题13',2,'upload/news13.jpg','2023-03-21 10:29:31','公告详情13','2023-03-21 10:29:31'),(14,'公告标题14',2,'upload/news14.jpg','2023-03-21 10:29:31','公告详情14','2023-03-21 10:29:31');/*Table structure for table `token` */DROP TABLE IF EXISTS `token`;CREATE TABLE `token` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`userid` bigint(20) NOT NULL COMMENT '用户id',`username` varchar(100) NOT NULL COMMENT '用户名',`tablename` varchar(100) DEFAULT NULL COMMENT '表名',`role` varchar(100) DEFAULT NULL COMMENT '角色',`token` varchar(200) NOT NULL COMMENT '密码',`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',`expiratedtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '过期时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='token表';/*Data for the table `token` */insert  into `token`(`id`,`userid`,`username`,`tablename`,`role`,`token`,`addtime`,`expiratedtime`) values (1,1,'admin','users','管理员','jjhb31mjf6ha4fkt8dfqn26fjju5jkb5','2023-03-21 10:33:32','2023-03-21 11:56:56'),(2,1,'a1','yonghu','用户','8erk329bwmbg8dymjfm5us2ckyib4yny','2023-03-21 10:34:45','2023-03-21 11:55:03');/*Table structure for table `users` */DROP TABLE IF EXISTS `users`;CREATE TABLE `users` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`username` varchar(100) NOT NULL COMMENT '用户名',`password` varchar(100) NOT NULL COMMENT '密码',`role` varchar(100) DEFAULT '管理员' COMMENT '角色',`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='管理员';/*Data for the table `users` */insert  into `users`(`id`,`username`,`password`,`role`,`addtime`) values (1,'admin','admin','管理员','2023-03-21 10:29:19');/*Table structure for table `wuzi` */DROP TABLE IF EXISTS `wuzi`;CREATE TABLE `wuzi` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`wuzi_uuid_number` varchar(200) DEFAULT NULL COMMENT '物资编号',`wuzi_name` varchar(200) DEFAULT NULL COMMENT '物资名称  Search111 ',`wuzi_photo` varchar(200) DEFAULT NULL COMMENT '物资照片',`wuzi_types` int(11) DEFAULT NULL COMMENT '物资类型 Search111',`wuzi_kucun_number` int(11) DEFAULT NULL COMMENT '物资库存',`wuzi_old_money` decimal(10,2) DEFAULT NULL COMMENT '原价 ',`wuzi_new_money` decimal(10,2) DEFAULT NULL COMMENT '现价',`wuzi_clicknum` int(11) DEFAULT NULL COMMENT '物资热度',`wuzi_content` longtext COMMENT '物资介绍 ',`shangxia_types` int(11) DEFAULT NULL COMMENT '是否上架 ',`wuzi_delete` int(11) DEFAULT NULL COMMENT '逻辑删除',`insert_time` timestamp NULL DEFAULT NULL COMMENT '录入时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间  show1 show2 photoShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='物资';/*Data for the table `wuzi` */insert  into `wuzi`(`id`,`wuzi_uuid_number`,`wuzi_name`,`wuzi_photo`,`wuzi_types`,`wuzi_kucun_number`,`wuzi_old_money`,`wuzi_new_money`,`wuzi_clicknum`,`wuzi_content`,`shangxia_types`,`wuzi_delete`,`insert_time`,`create_time`) values (1,'1679365771292','物资名称1','upload/wuzi1.jpg',1,101,'514.91','89.31',120,'物资介绍1',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(2,'1679365771360','物资名称2','upload/wuzi2.jpg',3,102,'550.38','228.32',16,'物资介绍2',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(3,'1679365771311','物资名称3','upload/wuzi3.jpg',2,103,'782.00','206.73',212,'物资介绍3',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(4,'1679365771283','物资名称4','upload/wuzi4.jpg',2,104,'585.60','163.70',325,'物资介绍4',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(5,'1679365771320','物资名称5','upload/wuzi5.jpg',1,105,'999.73','370.18',333,'物资介绍5',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(6,'1679365771351','物资名称6','upload/wuzi6.jpg',2,106,'589.15','101.18',336,'物资介绍6',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(7,'1679365771283','物资名称7','upload/wuzi7.jpg',1,107,'693.98','245.87',281,'物资介绍7',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(8,'1679365771328','物资名称8','upload/wuzi8.jpg',2,108,'712.87','255.94',74,'物资介绍8',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(9,'1679365771353','物资名称9','upload/wuzi9.jpg',3,109,'797.51','10.87',327,'物资介绍9',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(10,'1679365771325','物资名称10','upload/wuzi10.jpg',2,1010,'824.80','325.91',307,'物资介绍10',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(11,'1679365771347','物资名称11','upload/wuzi11.jpg',1,1011,'587.45','150.93',213,'物资介绍11',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(12,'1679365771317','物资名称12','upload/wuzi12.jpg',1,1010,'954.64','63.52',486,'物资介绍12',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(13,'1679365771282','物资名称13','upload/wuzi13.jpg',1,1013,'707.69','314.98',355,'物资介绍13',1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(14,'1679365771302','物资名称14','upload/wuzi14.jpg',1,1014,'674.28','290.95',135,'物资介绍14',2,1,'2023-03-21 10:29:31','2023-03-21 10:29:31');/*Table structure for table `wuzi_collection` */DROP TABLE IF EXISTS `wuzi_collection`;CREATE TABLE `wuzi_collection` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`wuzi_id` int(11) DEFAULT NULL COMMENT '物资',`yonghu_id` int(11) DEFAULT NULL COMMENT '用户',`wuzi_collection_types` int(11) DEFAULT NULL COMMENT '类型',`insert_time` timestamp NULL DEFAULT NULL COMMENT '收藏时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 photoShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='物资收藏';/*Data for the table `wuzi_collection` */insert  into `wuzi_collection`(`id`,`wuzi_id`,`yonghu_id`,`wuzi_collection_types`,`insert_time`,`create_time`) values (1,1,3,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(2,2,2,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(3,3,3,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(4,4,1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(5,5,3,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(6,6,2,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(7,7,2,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(8,8,3,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(9,9,2,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(10,10,1,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(11,11,3,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(12,12,3,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(13,13,2,1,'2023-03-21 10:29:31','2023-03-21 10:29:31'),(14,14,3,1,'2023-03-21 10:29:31','2023-03-21 10:29:31');/*Table structure for table `wuzi_order` */DROP TABLE IF EXISTS `wuzi_order`;CREATE TABLE `wuzi_order` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`wuzi_order_uuid_number` varchar(200) DEFAULT NULL COMMENT '订单号 Search111 ',`address_id` int(11) DEFAULT NULL COMMENT '收货地址 ',`wuzi_id` int(11) DEFAULT NULL COMMENT '物资',`yonghu_id` int(11) DEFAULT NULL COMMENT '用户',`buy_number` int(11) DEFAULT NULL COMMENT '购买数量',`wuzi_order_true_price` decimal(10,2) DEFAULT NULL COMMENT '实付价格',`wuzi_order_types` int(11) DEFAULT NULL COMMENT '订单类型 Search111 ',`wuzi_order_payment_types` int(11) DEFAULT NULL COMMENT '支付类型',`insert_time` timestamp NULL DEFAULT NULL COMMENT '订单创建时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 listShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='物资订单';/*Data for the table `wuzi_order` */insert  into `wuzi_order`(`id`,`wuzi_order_uuid_number`,`address_id`,`wuzi_id`,`yonghu_id`,`buy_number`,`wuzi_order_true_price`,`wuzi_order_types`,`wuzi_order_payment_types`,`insert_time`,`create_time`) values (1,'1679367307706',12,12,1,2,'127.04',104,1,'2023-03-21 10:55:08','2023-03-21 10:55:08');/*Table structure for table `wuzijuanzeng` */DROP TABLE IF EXISTS `wuzijuanzeng`;CREATE TABLE `wuzijuanzeng` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`wuzijuanzeng_name` varchar(200) DEFAULT NULL COMMENT '捐赠标题  Search111 ',`wuzijuanzeng_types` int(11) DEFAULT NULL COMMENT '捐赠类型  Search111 ',`yonghu_id` int(20) NOT NULL COMMENT '捐赠用户',`wuzijuanzeng_numb` int(11) DEFAULT NULL COMMENT '捐赠数量',`insert_time` timestamp NULL DEFAULT NULL COMMENT '添加时间',`wuzijuanzeng_content` longtext COMMENT '捐赠详情',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 listShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='物资捐赠';/*Data for the table `wuzijuanzeng` */insert  into `wuzijuanzeng`(`id`,`wuzijuanzeng_name`,`wuzijuanzeng_types`,`yonghu_id`,`wuzijuanzeng_numb`,`insert_time`,`wuzijuanzeng_content`,`create_time`) values (1,'捐赠标题1',1,3,149,'2023-03-21 10:29:31','捐赠详情1','2023-03-21 10:29:31'),(2,'捐赠标题2',1,3,67,'2023-03-21 10:29:31','捐赠详情2','2023-03-21 10:29:31'),(3,'捐赠标题3',2,2,364,'2023-03-21 10:29:31','捐赠详情3','2023-03-21 10:29:31'),(4,'捐赠标题4',1,1,137,'2023-03-21 10:29:31','捐赠详情4','2023-03-21 10:29:31'),(5,'捐赠标题5',2,1,484,'2023-03-21 10:29:31','捐赠详情5','2023-03-21 10:29:31'),(6,'捐赠标题6',2,2,60,'2023-03-21 10:29:31','捐赠详情6','2023-03-21 10:29:31'),(7,'捐赠标题7',2,3,85,'2023-03-21 10:29:31','捐赠详情7','2023-03-21 10:29:31'),(8,'捐赠标题8',2,1,201,'2023-03-21 10:29:31','捐赠详情8','2023-03-21 10:29:31'),(9,'捐赠标题9',2,2,500,'2023-03-21 10:29:31','捐赠详情9','2023-03-21 10:29:31'),(10,'捐赠标题10',1,3,470,'2023-03-21 10:29:31','捐赠详情10','2023-03-21 10:29:31'),(11,'捐赠标题11',1,3,87,'2023-03-21 10:29:31','捐赠详情11','2023-03-21 10:29:31'),(12,'捐赠标题12',2,1,485,'2023-03-21 10:29:31','捐赠详情12','2023-03-21 10:29:31'),(13,'捐赠标题13',2,1,273,'2023-03-21 10:29:31','捐赠详情13','2023-03-21 10:29:31'),(14,'捐赠标题14',1,1,399,'2023-03-21 10:29:31','捐赠详情14','2023-03-21 10:29:31'),(16,'xxx捐赠蔬菜1吨',2,1,1,'2023-03-21 10:56:08','1','2023-03-21 10:56:08');/*Table structure for table `yonghu` */DROP TABLE IF EXISTS `yonghu`;CREATE TABLE `yonghu` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`username` varchar(200) DEFAULT NULL COMMENT '账户',`password` varchar(200) DEFAULT NULL COMMENT '密码',`yonghu_name` varchar(200) DEFAULT NULL COMMENT '用户姓名 Search111 ',`yonghu_phone` varchar(200) DEFAULT NULL COMMENT '联系方式',`yonghu_id_number` varchar(200) DEFAULT NULL COMMENT '身份证号',`yonghu_photo` varchar(200) DEFAULT NULL COMMENT '用户头像',`sex_types` int(11) DEFAULT NULL COMMENT '性别 Search111',`yonghu_email` varchar(200) DEFAULT NULL COMMENT '电子邮箱',`new_money` decimal(10,2) DEFAULT NULL COMMENT '余额 ',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='用户';/*Data for the table `yonghu` */insert  into `yonghu`(`id`,`username`,`password`,`yonghu_name`,`yonghu_phone`,`yonghu_id_number`,`yonghu_photo`,`sex_types`,`yonghu_email`,`new_money`,`create_time`) values (1,'a1','123456','用户姓名1','17703786901','410224199010102001','upload/yonghu1.jpg',2,'1@qq.com','100060.66','2023-03-21 10:29:31'),(2,'a2','123456','用户姓名2','17703786902','410224199010102002','upload/yonghu2.jpg',2,'2@qq.com','215.00','2023-03-21 10:29:31'),(3,'a3','123456','用户姓名3','17703786903','410224199010102003','upload/yonghu3.jpg',2,'3@qq.com','108.99','2023-03-21 10:29:31');/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

5、关键代码

5.1 物资管理Controller模块 


package com.controller;import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;/*** 物资* 后端接口* @author* @email
*/
@RestController
@Controller
@RequestMapping("/wuzi")
public class WuziController {private static final Logger logger = LoggerFactory.getLogger(WuziController.class);private static final String TABLE_NAME = "wuzi";@Autowiredprivate WuziService wuziService;@Autowiredprivate TokenService tokenService;@Autowiredprivate AddressService addressService;//收货地址@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate ForumService forumService;//论坛@Autowiredprivate LiuyanService liuyanService;//求助留言板@Autowiredprivate NewsService newsService;//公告信息@Autowiredprivate WuziCollectionService wuziCollectionService;//物资收藏@Autowiredprivate WuziOrderService wuziOrderService;//物资订单@Autowiredprivate WuzijuanzengService wuzijuanzengService;//物资捐赠@Autowiredprivate YonghuService yonghuService;//用户@Autowiredprivate UsersService usersService;//管理员/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永不会进入");else if("用户".equals(role))params.put("yonghuId",request.getSession().getAttribute("userId"));params.put("wuziDeleteStart",1);params.put("wuziDeleteEnd",1);CommonUtil.checkMap(params);PageUtils page = wuziService.queryPage(params);//字典表数据转换List<WuziView> list =(List<WuziView>)page.getList();for(WuziView c:list){//修改对应字典表字段dictionaryService.dictionaryConvert(c, request);}return R.ok().put("data", page);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);WuziEntity wuzi = wuziService.selectById(id);if(wuzi !=null){//entity转viewWuziView view = new WuziView();BeanUtils.copyProperties( wuzi , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody WuziEntity wuzi, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,wuzi:{}",this.getClass().getName(),wuzi.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");Wrapper<WuziEntity> queryWrapper = new EntityWrapper<WuziEntity>().eq("wuzi_name", wuzi.getWuziName()).eq("wuzi_types", wuzi.getWuziTypes()).eq("wuzi_kucun_number", wuzi.getWuziKucunNumber()).eq("shangxia_types", wuzi.getShangxiaTypes()).eq("wuzi_delete", wuzi.getWuziDelete());logger.info("sql语句:"+queryWrapper.getSqlSegment());WuziEntity wuziEntity = wuziService.selectOne(queryWrapper);if(wuziEntity==null){wuzi.setWuziClicknum(1);wuzi.setShangxiaTypes(1);wuzi.setWuziDelete(1);wuzi.setInsertTime(new Date());wuzi.setCreateTime(new Date());wuziService.insert(wuzi);return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody WuziEntity wuzi, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,wuzi:{}",this.getClass().getName(),wuzi.toString());WuziEntity oldWuziEntity = wuziService.selectById(wuzi.getId());//查询原先数据String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");if("".equals(wuzi.getWuziPhoto()) || "null".equals(wuzi.getWuziPhoto())){wuzi.setWuziPhoto(null);}wuziService.updateById(wuzi);//根据id更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids, HttpServletRequest request){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());List<WuziEntity> oldWuziList =wuziService.selectBatchIds(Arrays.asList(ids));//要删除的数据ArrayList<WuziEntity> list = new ArrayList<>();for(Integer id:ids){WuziEntity wuziEntity = new WuziEntity();wuziEntity.setId(id);wuziEntity.setWuziDelete(2);list.add(wuziEntity);}if(list != null && list.size() >0){wuziService.updateBatchById(list);}return R.ok();}/*** 批量上传*/@RequestMapping("/batchInsert")public R save( String fileName, HttpServletRequest request){logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");try {List<WuziEntity> wuziList = new ArrayList<>();//上传的东西Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段Date date = new Date();int lastIndexOf = fileName.lastIndexOf(".");if(lastIndexOf == -1){return R.error(511,"该文件没有后缀");}else{String suffix = fileName.substring(lastIndexOf);if(!".xls".equals(suffix)){return R.error(511,"只支持后缀为xls的excel文件");}else{URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径File file = new File(resource.getFile());if(!file.exists()){return R.error(511,"找不到上传文件,请联系管理员");}else{List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件dataList.remove(0);//删除第一行,因为第一行是提示for(List<String> data:dataList){//循环WuziEntity wuziEntity = new WuziEntity();
//                            wuziEntity.setWuziUuidNumber(data.get(0));                    //物资编号 要改的
//                            wuziEntity.setWuziName(data.get(0));                    //物资名称 要改的
//                            wuziEntity.setWuziPhoto("");//详情和图片
//                            wuziEntity.setWuziTypes(Integer.valueOf(data.get(0)));   //物资类型 要改的
//                            wuziEntity.setWuziKucunNumber(Integer.valueOf(data.get(0)));   //物资库存 要改的
//                            wuziEntity.setWuziOldMoney(data.get(0));                    //原价 要改的
//                            wuziEntity.setWuziNewMoney(data.get(0));                    //现价 要改的
//                            wuziEntity.setWuziClicknum(Integer.valueOf(data.get(0)));   //物资热度 要改的
//                            wuziEntity.setWuziContent("");//详情和图片
//                            wuziEntity.setShangxiaTypes(Integer.valueOf(data.get(0)));   //是否上架 要改的
//                            wuziEntity.setWuziDelete(1);//逻辑删除字段
//                            wuziEntity.setInsertTime(date);//时间
//                            wuziEntity.setCreateTime(date);//时间wuziList.add(wuziEntity);//把要查询是否重复的字段放入map中//物资编号if(seachFields.containsKey("wuziUuidNumber")){List<String> wuziUuidNumber = seachFields.get("wuziUuidNumber");wuziUuidNumber.add(data.get(0));//要改的}else{List<String> wuziUuidNumber = new ArrayList<>();wuziUuidNumber.add(data.get(0));//要改的seachFields.put("wuziUuidNumber",wuziUuidNumber);}}//查询是否重复//物资编号List<WuziEntity> wuziEntities_wuziUuidNumber = wuziService.selectList(new EntityWrapper<WuziEntity>().in("wuzi_uuid_number", seachFields.get("wuziUuidNumber")).eq("wuzi_delete", 1));if(wuziEntities_wuziUuidNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(WuziEntity s:wuziEntities_wuziUuidNumber){repeatFields.add(s.getWuziUuidNumber());}return R.error(511,"数据库的该表中的 [物资编号] 字段已经存在 存在数据为:"+repeatFields.toString());}wuziService.insertBatch(wuziList);return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入数据异常,请联系管理员");}}/*** 个性推荐*/@IgnoreAuth@RequestMapping("/gexingtuijian")public R gexingtuijian(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("gexingtuijian方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));CommonUtil.checkMap(params);List<WuziView> returnWuziViewList = new ArrayList<>();//查询订单Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));PageUtils pageUtils = wuziOrderService.queryPage(params1);List<WuziOrderView> orderViewsList =(List<WuziOrderView>)pageUtils.getList();Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型listfor(WuziOrderView orderView:orderViewsList){Integer wuziTypes = orderView.getWuziTypes();if(typeMap.containsKey(wuziTypes)){typeMap.put(wuziTypes,typeMap.get(wuziTypes)+1);}else{typeMap.put(wuziTypes,1);}}List<Integer> typeList = new ArrayList<>();//排序后的有序的类型 按最多到最少typeMap.entrySet().stream().sorted((o1, o2) -> o2.getValue() - o1.getValue()).forEach(e -> typeList.add(e.getKey()));//排序Integer limit = Integer.valueOf(String.valueOf(params.get("limit")));for(Integer type:typeList){Map<String, Object> params2 = new HashMap<>(params);params2.put("wuziTypes",type);PageUtils pageUtils1 = wuziService.queryPage(params2);List<WuziView> wuziViewList =(List<WuziView>)pageUtils1.getList();returnWuziViewList.addAll(wuziViewList);if(returnWuziViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环}//正常查询出来商品,用于补全推荐缺少的数据PageUtils page = wuziService.queryPage(params);if(returnWuziViewList.size()<limit){//返回数量还是小于要求数量int toAddNum = limit - returnWuziViewList.size();//要添加的数量List<WuziView> wuziViewList =(List<WuziView>)page.getList();for(WuziView wuziView:wuziViewList){Boolean addFlag = true;for(WuziView returnWuziView:returnWuziViewList){if(returnWuziView.getId().intValue() ==wuziView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品}if(addFlag){toAddNum=toAddNum-1;returnWuziViewList.add(wuziView);if(toAddNum==0) break;//够数量了}}}else {returnWuziViewList = returnWuziViewList.subList(0, limit);}for(WuziView c:returnWuziViewList)dictionaryService.dictionaryConvert(c, request);page.setList(returnWuziViewList);return R.ok().put("data", page);}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));CommonUtil.checkMap(params);PageUtils page = wuziService.queryPage(params);//字典表数据转换List<WuziView> list =(List<WuziView>)page.getList();for(WuziView c:list)dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段return R.ok().put("data", page);}/*** 前端详情*/@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);WuziEntity wuzi = wuziService.selectById(id);if(wuzi !=null){//点击数量加1wuzi.setWuziClicknum(wuzi.getWuziClicknum()+1);wuziService.updateById(wuzi);//entity转viewWuziView view = new WuziView();BeanUtils.copyProperties( wuzi , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody WuziEntity wuzi, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,wuzi:{}",this.getClass().getName(),wuzi.toString());Wrapper<WuziEntity> queryWrapper = new EntityWrapper<WuziEntity>().eq("wuzi_uuid_number", wuzi.getWuziUuidNumber()).eq("wuzi_name", wuzi.getWuziName()).eq("wuzi_types", wuzi.getWuziTypes()).eq("wuzi_kucun_number", wuzi.getWuziKucunNumber()).eq("wuzi_clicknum", wuzi.getWuziClicknum()).eq("shangxia_types", wuzi.getShangxiaTypes()).eq("wuzi_delete", wuzi.getWuziDelete())
//            .notIn("wuzi_types", new Integer[]{102});logger.info("sql语句:"+queryWrapper.getSqlSegment());WuziEntity wuziEntity = wuziService.selectOne(queryWrapper);if(wuziEntity==null){wuzi.setWuziClicknum(1);wuzi.setWuziDelete(1);wuzi.setInsertTime(new Date());wuzi.setCreateTime(new Date());wuziService.insert(wuzi);return R.ok();}else {return R.error(511,"表中有相同数据");}}}

5.2 物资管理Service模块 

package com.service;import com.baomidou.mybatisplus.service.IService;
import com.utils.PageUtils;
import com.entity.WuziCollectionEntity;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import java.util.List;/*** 物资收藏 服务类*/
public interface WuziCollectionService extends IService<WuziCollectionEntity> {/*** @param params 查询参数* @return 带分页的查询出来的数据*/PageUtils queryPage(Map<String, Object> params);}

5.3 物资管理ServiceImpl模块

package com.service.impl;import com.utils.StringUtil;
import com.service.DictionaryService;
import com.utils.ClazzDiff;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.*;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.dao.WuziDao;
import com.entity.WuziEntity;
import com.service.WuziService;
import com.entity.view.WuziView;/*** 物资 服务实现类*/
@Service("wuziService")
@Transactional
public class WuziServiceImpl extends ServiceImpl<WuziDao, WuziEntity> implements WuziService {@Overridepublic PageUtils queryPage(Map<String,Object> params) {Page<WuziView> page =new Query<WuziView>(params).getPage();page.setRecords(baseMapper.selectListView(page,params));return new PageUtils(page);}
}

5.4 物资管理Dao模块

package com.dao;import com.entity.WuziEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;import org.apache.ibatis.annotations.Param;
import com.entity.view.WuziView;/*** 物资 Dao 接口** @author */
public interface WuziDao extends BaseMapper<WuziEntity> {List<WuziView> selectListView(Pagination page,@Param("params")Map<String,Object> params);}

6、论文目录结构

7、源码获取

感谢大家的阅读,如有不懂的问题可以评论区交流或私聊!

喜欢文章可以点赞、收藏、关注、评论

获取源码请私信

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

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux 时区设置

对于服务器来说&#xff0c;linux的时区影响着运行之上的数据库和后端程序的时区 应该和数据库和后端及其他程序的时区保持一致 其他相关时区的设置 pgsql时区设置&#xff1a; php时区设置&#xff1a; 1.显示当前的时间和时区 date结果类似下面&#xff0c;图中显示的是ut…

Mybatis Plus分页实现逻辑整理(结合芋道整合进行解析)

Mybatis Plus分页实现逻辑整理&#xff08;结合芋道整合进行解析&#xff09; 我希望如春天般的你&#xff0c;身着白色的婚纱&#xff0c;向我奔赴而来&#xff0c;我愿意用全世界最温情的目光&#xff0c;朝着你的方向望去——姗姗来迟。 1.背景介绍 https://baomidou.com/p…

【监控系统】日志可视化监控体系ELK搭建

1.ELK架构是什么 ELK是ElasticsearchLogstashKibana的简称。 Elasticsearch是一个开源的分布式搜索和分析引擎&#xff0c;可以用于全文检索、结构化检索和分析&#xff0c;它构建在Lucene搜索引擎库之上&#xff0c;是当前使用较为广泛的开源搜索引擎之一。 Logstash是一个…

风电场数字孪生-升压站BIM三维模型-obj格式

简介&#xff1a; 风电场中的升压站三维模型&#xff0c;obj格式&#xff0c;采用BIM技术建模&#xff0c;可应用于风电场三维数字孪生领域&#xff0c;用于对升压站进行漫游浏览&#xff1b;三维可视化场景应用&#xff1b;风电场三维设计模型。 下载地址 风电场数字孪生-升…

【hive-解决】HiveAccessControlException Permission denied: CREATEFUNCTION

文章目录 一.任务描述二. 解决 一.任务描述 Error while compiling statement: FAILED: HiveAccessControlException Permission denied: Principal [nameroot, typeUSER] does not have following privileges for operation CREATEFUNCTION [ADMIN PRIVILEGE on INPUT, ADMIN…

ajax,axios,fetch

文章目录 ajax工作原理ajax发请求四个步骤创建xmlhttprequest对象设置请求方式设置回调函数发送请求 自封装ajax axiosaxios 特性如何用配置拦截器 fetch三者区别 ajax 工作原理 Ajax的工作原理相当于在用户和服务器之间加了—个中间层(AJAX引擎)&#xff0c;使用户操作与服务…

【Linux】:进程间通信和日志模拟

进程间通信 一.基本概念二.简单的通信-管道(匿名管道)1.建立通信信道2.通信接口 三.命名管道三.模拟命名管道通信&#xff08;加上日志&#xff09;1.完整代码2.基本使用 一.基本概念 是什么 两个或多个进程实现数据层面的交互。 因为进程独立性的存在&#xff0c;导致进程间…

Deep Learning for Monocular Depth Estimation: A Review.基于深度学习的深度估计

传统的深度估计方法通常是使用双目相机&#xff0c;计算两个2D图像的视差&#xff0c;然后通过立体匹配和三角剖分得到深度图。然而&#xff0c;双目深度估计方法至少需要两个固定的摄像机&#xff0c;当场景的纹理较少或者没有纹理的时候&#xff0c;很难从图像中捕捉足够的特…

[JDK工具-3] javac编译器生成class文件 java执行器运行class文件

位置&#xff1a;jdk\bin 语法&#xff1a;javac 源文件 -d class文件输出路径 -encoding utf-8 javac HelloWorld.java -d D:\project1\java8\java8\xin-javademo\src\main\java\com\xin\demo\hutooldemo\ -encoding utf-8 语法&#xff1a;java 类文件完全限定名&#xff08;…

pyinstaller 打包pyqt6等ui文件为exe可执行程序的方法

刚开始使用auto-py-to-exe打包pyqt6的程序&#xff0c;折腾好半天都会出错&#xff0c;关键打包出来的exe单文件有快100兆了&#xff0c;真大啊&#xff01; auto-py-to-exe有图形界面&#xff0c;看起来比较直观。 还有中文语言&#xff0c;对使用者比较友善&#xff0c;可以…

2023年【T电梯修理】考试题及T电梯修理考试报名

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 T电梯修理考试题是安全生产模拟考试一点通总题库中生成的一套T电梯修理考试报名&#xff0c;安全生产模拟考试一点通上T电梯修理作业手机同步练习。2023年【T电梯修理】考试题及T电梯修理考试报名 1、【多选题】GB/T1…

轻量封装WebGPU渲染系统示例<35>- HDR环境数据应用到PBR渲染材质

当前示例源码github地址: https://github.com/vilyLei/voxwebgpu/blob/feature/rendering/src/voxgpu/sample/BasePbrMaterialTest.ts 当前示例运行效果: 微调参数之后的效果: 此示例基于此渲染系统实现&#xff0c;当前示例TypeScript源码如下: export class BasePbrMateri…

【GUI】-- 11 贪吃蛇小游戏之绘制静态的小蛇

GUI编程 04 贪吃蛇小游戏 4.2 第二步&#xff1a;绘制静态的小蛇 现在绘制静态的小蛇(即小蛇初始位置)&#xff0c;并且完善游戏默认初始状态。这一步还在GamePanel类中实现。 首先&#xff0c;定义了小蛇的数据结构&#xff0c; //定义蛇的数据结构int length; //小蛇总长…

ky10 server aarch64 离线安装openssl3.1.4

离线程序 https://gitcode.net/zengliguang/ky10_aarch64_openssl_install.git 输入下面命令执行离线安装脚本 source openssl_offline_install.sh 安装完成

SMART PLC累计流量功能块(梯形积分法+浮点数累加精度控制)

S7-200SMART PLC数值积分器相关知识请参考下面文章链接: SMART PLC数值积分器功能块(矩形+梯形积分法完整源代码)-CSDN博客文章浏览阅读153次。PLC的数值积分器算法也可以参考下面文章链接:PLC算法系列之数值积分器(Integrator)-CSDN博客数值积分和微分在工程上的重要意义不…

3D应用开发引擎HOOPS如何促进AEC数字化架构革新?

随着科技的不断发展&#xff0c;建筑、工程和施工&#xff08;AEC&#xff09;行业正在掀起令人瞩目的数字化转型浪潮。在这一变革的过程中&#xff0c;Tech Soft 3D的HOOPS SDK&#xff08;软件开发工具包&#xff09;正扮演着关键的角色&#xff0c;为构建世界一流的AEC和BIM…

AMEYA360:蔡司扫描电镜Sigma系列:扫描电子显微镜的用途原来这么多

扫描电子显微镜是一种全自动的、非破坏性的显微分析系统&#xff0c;可针对无机材料和部分有机材料&#xff0c;迅速提供在统计学上可靠且可重复的矿物学、岩相学和冶金学数据&#xff0c;在采矿业&#xff0c;可用于矿产勘查、矿石表征和选矿工艺优化&#xff0c;在石油和天然…

RabbitMQ 基础操作

概念 从计算机术语层面来说&#xff0c;RabbitMQ 模型更像是一种交换机模型。 Queue 队列 Queue&#xff1a;队列&#xff0c;是RabbitMQ 的内部对象&#xff0c;用于存储消息。 RabbitMQ 中消息只能存储在队列中&#xff0c;这一点和Kafka相反。Kafka将消息存储在topic&am…

Python与ArcGIS系列(九)自定义python地理处理工具

目录 0 简述1 创建自定义地理处理工具2 创建python工具箱0 简述 在arcgis中可以进行自定义工具箱,将脚本嵌入到自定义的可交互窗口工具中。本篇将介绍如何利用arcpy实现创建自定义地理处理工具以及创建python工具箱。 1 创建自定义地理处理工具 在arctoolbox中的自定义工具箱…

【经验之谈·高频PCB电路设计常见的66个问题】

文章目录 1、如何选择PCB 板材&#xff1f;2、如何避免高频干扰&#xff1f;3、在高速设计中&#xff0c;如何解决信号的完整性问题&#xff1f;4、差分布线方式是如何实现的&#xff1f;5、对于只有一个输出端的时钟信号线&#xff0c;如何实现差分布线&#xff1f;6、接收端差…