博主介绍:✌从事软件开发10年之余,专注于Java技术领域、Python人工智能及数据挖掘、小程序项目开发和Android项目开发等。CSDN、掘金、华为云、InfoQ、阿里云等平台优质作者✌
🍅文末获取源码联系🍅
👇🏻 精彩专栏推荐订阅👇🏻 不然下次找不到哟
————————————————
计算机毕业设计《1000套》✌
目录
1、项目介绍及开发技术
1.1 项目介绍
1.2 开发技术
2、系统功能模块设计
3、功能截图
4、数据库表结构设计
5、关键代码
5.1 垃圾Controller模块
5.2 垃圾Service模块
5.3 垃圾ServiceImpl模块
5.4 垃圾Dao模块
6、论文目录结构
7、源码获取
1、项目介绍及开发技术
1.1 项目介绍
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本城市垃圾分类管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此城市垃圾分类管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了用户在线选择试题并完成答题,在线查看考核分数。管理员管理字典管理、论坛管理、公告管理、垃圾管理、垃圾收藏管理、垃圾留言管理、留言板管理、用户管理、政策管理、管理员管理等功能。城市垃圾分类管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
1.2 开发技术
Java开发语言、SpringBoot、MyBatisPlus、MySQL数据库、Maven、IDEA开发工具、JDK1.8+、Vue、HTML、CSS、JS。
2、系统功能模块设计
用户:注册登录、首页、论坛、公告、垃圾、留言板、政策、个人中心(个人信息、垃圾收藏)
管理员:登录、首页、个人中心(修改密码、个人信息)、管理员管理、基础数据管理(帖子类型管理、公告类型管理、所属分类管理、政策类型管理、)、论坛管理、公告管理、垃圾管理、留言板管理、用户管理、政策管理、轮播图信息。
3、功能截图
垃圾列表:查看垃圾、新增垃圾、修改垃圾、删除垃圾等。
公告信息管理: 新增公告,修改公告,删除公告操作。下图就是公告信息管理页面。
公告类型管理: 可以添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。
4、数据库表结构设计
CREATE DATABASE /*!32312 IF NOT EXISTS*/`chengshilajifenleiguanlixitong` /*!40100 DEFAULT CHARACTER SET utf8 */;USE `chengshilajifenleiguanlixitong`;/*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,'轮播图1111','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=20 DEFAULT CHARSET=utf8 COMMENT='字典';/*Data for the table `dictionary` */insert into /*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` text COMMENT '发布内容',`super_ids` int(11) DEFAULT NULL COMMENT '父id',`forum_types` int(11) DEFAULT NULL COMMENT '帖子类型 Search111 ',`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_types`,`forum_state_types`,`insert_time`,`update_time`,`create_time`) values (1,'帖子标题1',1,NULL,'发布内容1',303,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(2,'帖子标题2',1,NULL,'发布内容2',186,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(3,'帖子标题3',3,NULL,'发布内容3',294,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(4,'帖子标题4',3,NULL,'发布内容4',311,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(5,'帖子标题5',3,NULL,'发布内容5',309,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(6,'帖子标题6',1,NULL,'发布内容6',264,2,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(7,'帖子标题7',1,NULL,'发布内容7',239,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(8,'帖子标题8',1,NULL,'发布内容8',59,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(9,'帖子标题9',1,NULL,'发布内容9',148,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(10,'帖子标题10',2,NULL,'发布内容10',140,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(11,'帖子标题11',3,NULL,'发布内容11',132,2,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(12,'帖子标题12',2,NULL,'发布内容12',416,2,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(13,'帖子标题13',1,NULL,'发布内容13',178,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(14,'帖子标题14',3,NULL,'发布内容14',483,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49','2023-03-14 17:05:49'),(15,NULL,4,NULL,'fgdgsg范德萨范德萨个',14,NULL,2,'2023-03-14 17:19:15',NULL,'2023-03-14 17:19:15'),(16,NULL,NULL,1,'灌灌灌灌',14,NULL,2,'2023-03-14 17:20:23',NULL,'2023-03-14 17:20:23');/*Table structure for table `gonggao` */DROP TABLE IF EXISTS `gonggao`;CREATE TABLE `gonggao` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`gonggao_name` varchar(200) DEFAULT NULL COMMENT '公告名称 Search111 ',`gonggao_photo` varchar(200) DEFAULT NULL COMMENT '公告图片 ',`gonggao_types` int(11) NOT NULL COMMENT '公告类型 Search111 ',`insert_time` timestamp NULL DEFAULT NULL COMMENT '公告发布时间 ',`gonggao_content` text 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 `gonggao` */insert into `gonggao`(`id`,`gonggao_name`,`gonggao_photo`,`gonggao_types`,`insert_time`,`gonggao_content`,`create_time`) values (1,'公告名称1','upload/gonggao1.jpg',1,'2023-03-14 17:05:49','公告详情1','2023-03-14 17:05:49'),(2,'公告名称2','upload/gonggao2.jpg',2,'2023-03-14 17:05:49','公告详情2','2023-03-14 17:05:49'),(3,'公告名称3','upload/gonggao3.jpg',2,'2023-03-14 17:05:49','公告详情3','2023-03-14 17:05:49'),(4,'公告名称4','upload/gonggao4.jpg',2,'2023-03-14 17:05:49','公告详情4','2023-03-14 17:05:49'),(5,'公告名称5','upload/gonggao5.jpg',1,'2023-03-14 17:05:49','公告详情5','2023-03-14 17:05:49'),(6,'公告名称6','upload/gonggao6.jpg',1,'2023-03-14 17:05:49','公告详情6','2023-03-14 17:05:49'),(7,'公告名称7','upload/gonggao7.jpg',2,'2023-03-14 17:05:49','公告详情7','2023-03-14 17:05:49'),(8,'公告名称8','upload/gonggao8.jpg',2,'2023-03-14 17:05:49','公告详情8','2023-03-14 17:05:49'),(9,'公告名称9','upload/gonggao9.jpg',1,'2023-03-14 17:05:49','公告详情9','2023-03-14 17:05:49'),(10,'公告名称10','upload/gonggao10.jpg',2,'2023-03-14 17:05:49','公告详情10','2023-03-14 17:05:49'),(11,'公告名称11','upload/gonggao11.jpg',2,'2023-03-14 17:05:49','公告详情11','2023-03-14 17:05:49'),(12,'公告名称12','upload/gonggao12.jpg',1,'2023-03-14 17:05:49','公告详情12','2023-03-14 17:05:49'),(13,'公告名称13','upload/gonggao13.jpg',1,'2023-03-14 17:05:49','公告详情13','2023-03-14 17:05:49'),(14,'公告名称14','upload/gonggao14.jpg',2,'2023-03-14 17:05:49','<p>公告详情14广告费撒打发</p>','2023-03-14 17:05:49');/*Table structure for table `laji` */DROP TABLE IF EXISTS `laji`;CREATE TABLE `laji` () ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='垃圾';/*Data for the table `laji` */insert into /*Table structure for table `laji_collection` */DROP TABLE IF EXISTS `laji_collection`;CREATE TABLE `laji_collection` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`laji_id` int(11) DEFAULT NULL COMMENT '垃圾',`yonghu_id` int(11) DEFAULT NULL COMMENT '用户',`laji_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=16 DEFAULT CHARSET=utf8 COMMENT='垃圾收藏';/*Data for the table `laji_collection` */insert into `laji_collection`(`id`,`laji_id`,`yonghu_id`,`laji_collection_types`,`insert_time`,`create_time`) values (1,1,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(2,2,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(3,3,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(4,4,2,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(5,5,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(6,6,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(7,7,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(8,8,2,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(9,9,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(10,10,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(11,11,1,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(12,12,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(13,13,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(14,14,3,1,'2023-03-14 17:05:49','2023-03-14 17:05:49'),(15,14,4,1,'2023-03-14 17:19:44','2023-03-14 17:19:44');/*Table structure for table `laji_liuyan` */DROP TABLE IF EXISTS `laji_liuyan`;CREATE TABLE `laji_liuyan` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`laji_id` int(11) DEFAULT NULL COMMENT '垃圾',`yonghu_id` int(11) DEFAULT NULL COMMENT '用户',`laji_liuyan_text` text COMMENT '留言内容',`insert_time` timestamp NULL DEFAULT NULL COMMENT '留言时间',`reply_text` text COMMENT '回复内容',`update_time` timestamp NULL DEFAULT NULL COMMENT '回复时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='垃圾留言';/*Data for the table `laji_liuyan` */insert into `laji_liuyan`(`id`,`laji_id`,`yonghu_id`,`laji_liuyan_text`,`insert_time`,`reply_text`,`update_time`,`create_time`) values (1,1,2,'留言内容1','2023-03-14 17:05:49','回复信息1','2023-03-14 17:05:49','2023-03-14 17:05:49'),(2,2,2,'留言内容2','2023-03-14 17:05:49','回复信息2','2023-03-14 17:05:49','2023-03-14 17:05:49'),(3,3,1,'留言内容3','2023-03-14 17:05:49','回复信息3','2023-03-14 17:05:49','2023-03-14 17:05:49'),(4,4,1,'留言内容4','2023-03-14 17:05:49','回复信息4','2023-03-14 17:05:49','2023-03-14 17:05:49'),(5,5,3,'留言内容5','2023-03-14 17:05:49','回复信息5','2023-03-14 17:05:49','2023-03-14 17:05:49'),(6,6,2,'留言内容6','2023-03-14 17:05:49','回复信息6','2023-03-14 17:05:49','2023-03-14 17:05:49'),(7,7,3,'留言内容7','2023-03-14 17:05:49','回复信息7','2023-03-14 17:05:49','2023-03-14 17:05:49'),(8,8,3,'留言内容8','2023-03-14 17:05:49','回复信息8','2023-03-14 17:05:49','2023-03-14 17:05:49'),(9,9,3,'留言内容9','2023-03-14 17:05:49','回复信息9','2023-03-14 17:05:49','2023-03-14 17:05:49'),(10,10,2,'留言内容10','2023-03-14 17:05:49','回复信息10','2023-03-14 17:05:49','2023-03-14 17:05:49'),(11,11,1,'留言内容11','2023-03-14 17:05:49','回复信息11','2023-03-14 17:05:49','2023-03-14 17:05:49'),(12,12,1,'留言内容12','2023-03-14 17:05:49','回复信息12','2023-03-14 17:05:49','2023-03-14 17:05:49'),(13,13,2,'留言内容13','2023-03-14 17:05:49','回复信息13','2023-03-14 17:05:49','2023-03-14 17:05:49'),(14,14,1,'留言内容14','2023-03-14 17:05:49','回复信息14','2023-03-14 17:05:49','2023-03-14 17:05:49'),(15,3,4,'个哈哈哈','2023-03-14 17:19:24','灌灌灌灌','2023-03-14 17:20:45','2023-03-14 17:19:24');/*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` text COMMENT '留言内容',`insert_time` timestamp NULL DEFAULT NULL COMMENT '留言时间',`reply_text` text 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,3,'留言标题1','留言内容1','2023-03-14 17:05:49','回复信息1','2023-03-14 17:05:49','2023-03-14 17:05:49'),(2,2,'留言标题2','留言内容2','2023-03-14 17:05:49','回复信息2','2023-03-14 17:05:49','2023-03-14 17:05:49'),(3,3,'留言标题3','留言内容3','2023-03-14 17:05:49','回复信息3','2023-03-14 17:05:49','2023-03-14 17:05:49'),(4,2,'留言标题4','留言内容4','2023-03-14 17:05:49','回复信息4','2023-03-14 17:05:49','2023-03-14 17:05:49'),(5,1,'留言标题5','留言内容5','2023-03-14 17:05:49','回复信息5','2023-03-14 17:05:49','2023-03-14 17:05:49'),(6,1,'留言标题6','留言内容6','2023-03-14 17:05:49','回复信息6','2023-03-14 17:05:49','2023-03-14 17:05:49'),(7,1,'留言标题7','留言内容7','2023-03-14 17:05:49','回复信息7','2023-03-14 17:05:49','2023-03-14 17:05:49'),(8,2,'留言标题8','留言内容8','2023-03-14 17:05:49','回复信息8','2023-03-14 17:05:49','2023-03-14 17:05:49'),(9,1,'留言标题9','留言内容9','2023-03-14 17:05:49','回复信息9','2023-03-14 17:05:49','2023-03-14 17:05:49'),(10,3,'留言标题10','留言内容10','2023-03-14 17:05:49','回复信息10','2023-03-14 17:05:49','2023-03-14 17:05:49'),(11,3,'留言标题11','留言内容11','2023-03-14 17:05:49','回复信息11','2023-03-14 17:05:49','2023-03-14 17:05:49'),(12,3,'留言标题12','留言内容12','2023-03-14 17:05:49','回复信息12','2023-03-14 17:05:49','2023-03-14 17:05:49'),(13,3,'留言标题13','留言内容13','2023-03-14 17:05:49','回复信息13','2023-03-14 17:05:49','2023-03-14 17:05:49'),(14,3,'留言标题14','留言内容14','2023-03-14 17:05:49','回复信息14','2023-03-14 17:05:49','2023-03-14 17:05:49'),(15,4,'标题111','是方法是分散发送','2023-03-14 17:19:32','给对方如好得很','2023-03-14 17:20:50','2023-03-14 17:19:32');/*Table structure for table `token` */DROP TABLE IF EXISTS `token`;CREATE TABLE `token` (/*Data for the table `token` */insert into `token`(`id`,`userid`,`username`,`tablename`,`role`,`token`,`addtime`,`expiratedtime`) values (1,1,'admin','users','管理员','rxb3hyhhpc5zy8qvd9l5x7tth20vpasx','2023-03-14 17:15:07','2023-03-14 18:20:06'),(2,1,'a1','yonghu','用户','4q00pp0h7g3s0aha1whnzm0lzanyktw3','2023-03-14 17:17:08','2023-03-14 18:17:09'),(3,4,'a5','yonghu','用户','z2lwrmjoqh359c1arz0rruzf30dnrfj4','2023-03-14 17:18:50','2023-03-14 18:18:50');/*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-14 17:04:49');/*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 '性别',`yonghu_email` varchar(200) DEFAULT NULL COMMENT '用户邮箱',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 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`,`create_time`) values (1,'a1','123456','用户姓名1','17703786901','410224199010102001','upload/yonghu1.jpg',2,'1@qq.com','2023-03-14 17:05:49'),(2,'a2','123456','用户姓名2','17703786902','410224199010102002','upload/yonghu2.jpg',1,'2@qq.com','2023-03-14 17:05:49'),(3,'a3','123456','用户姓名3','17703786903','410224199010102003','upload/yonghu3.jpg',2,'3@qq.com','2023-03-14 17:05:49'),(4,'a5','123456','张5','17788889999','411222555599996661','upload/1678785534988.jpg',2,'5@qq.com','2023-03-14 17:18:44');/*Table structure for table `zhengce` */DROP TABLE IF EXISTS `zhengce`;CREATE TABLE `zhengce` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`zhengce_name` varchar(200) DEFAULT NULL COMMENT '政策名称 Search111 ',`zhengce_photo` varchar(200) DEFAULT NULL COMMENT '政策图片 ',`zhengce_types` int(11) NOT NULL COMMENT '政策类型 Search111 ',`insert_time` timestamp NULL DEFAULT NULL COMMENT '政策发布时间 ',`zhengce_content` text 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 `zhengce` */insert into `zhengce`(`id`,`zhengce_name`,`zhengce_photo`,`zhengce_types`,`insert_time`,`zhengce_content`,`create_time`) values (1,'政策名称1','upload/zhengce1.jpg',1,'2023-03-14 17:05:49','政策详情1','2023-03-14 17:05:49'),(2,'政策名称2','upload/zhengce2.jpg',1,'2023-03-14 17:05:49','政策详情2','2023-03-14 17:05:49'),(3,'政策名称3','upload/zhengce3.jpg',1,'2023-03-14 17:05:49','政策详情3','2023-03-14 17:05:49'),(4,'政策名称4','upload/zhengce4.jpg',1,'2023-03-14 17:05:49','政策详情4','2023-03-14 17:05:49'),(5,'政策名称5','upload/zhengce5.jpg',1,'2023-03-14 17:05:49','政策详情5','2023-03-14 17:05:49'),(6,'政策名称6','upload/zhengce6.jpg',2,'2023-03-14 17:05:49','政策详情6','2023-03-14 17:05:49'),(7,'政策名称7','upload/zhengce7.jpg',1,'2023-03-14 17:05:49','政策详情7','2023-03-14 17:05:49'),(8,'政策名称8','upload/zhengce8.jpg',1,'2023-03-14 17:05:49','政策详情8','2023-03-14 17:05:49'),(9,'政策名称9','upload/zhengce9.jpg',2,'2023-03-14 17:05:49','政策详情9','2023-03-14 17:05:49'),(10,'政策名称10','upload/zhengce10.jpg',2,'2023-03-14 17:05:49','政策详情10','2023-03-14 17:05:49'),(11,'政策名称11','upload/zhengce11.jpg',2,'2023-03-14 17:05:49','政策详情11','2023-03-14 17:05:49'),(12,'政策名称12','upload/zhengce12.jpg',1,'2023-03-14 17:05:49','政策详情12','2023-03-14 17:05:49'),(13,'政策名称13','upload/zhengce13.jpg',2,'2023-03-14 17:05:49','政策详情13','2023-03-14 17:05:49'),(14,'政策名称14','upload/zhengce14.jpg',1,'2023-03-14 17:05:49','政策详情14','2023-03-14 17:05:49');/*!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模块
/*** 垃圾* 后端接口* @author 学长编程* @email*WeChat jsjbysj88
*/
@RestController
@Controller
@RequestMapping("/laji")
public class LajiController {private static final Logger logger = LoggerFactory.getLogger(LajiController.class);private static final String TABLE_NAME = "laji";@Autowiredprivate LajiService lajiService;@Autowiredprivate TokenService tokenService;@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate ForumService forumService;//论坛@Autowiredprivate GonggaoService gonggaoService;//公告@Autowiredprivate LajiCollectionService lajiCollectionService;//垃圾收藏@Autowiredprivate LajiLiuyanService lajiLiuyanService;//垃圾留言@Autowiredprivate LiuyanService liuyanService;//留言板@Autowiredprivate YonghuService yonghuService;//用户@Autowiredprivate ZhengceService zhengceService;//政策@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("lajiDeleteStart",1);params.put("lajiDeleteEnd",1);CommonUtil.checkMap(params);PageUtils page = lajiService.queryPage(params);//字典表数据转换List<LajiView> list =(List<LajiView>)page.getList();for(LajiView 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);LajiEntity laji = lajiService.selectById(id);if(laji !=null){//entity转viewLajiView view = new LajiView();BeanUtils.copyProperties( laji , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody LajiEntity laji, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,laji:{}",this.getClass().getName(),laji.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");Wrapper<LajiEntity> queryWrapper = new EntityWrapper<LajiEntity>().eq("laji_name", laji.getLajiName()).eq("laji_types", laji.getLajiTypes()).eq("shangxia_types", laji.getShangxiaTypes()).eq("laji_delete", laji.getLajiDelete());logger.info("sql语句:"+queryWrapper.getSqlSegment());LajiEntity lajiEntity = lajiService.selectOne(queryWrapper);if(lajiEntity==null){laji.setLajiClicknum(1);laji.setShangxiaTypes(1);laji.setLajiDelete(1);laji.setInsertTime(new Date());laji.setCreateTime(new Date());lajiService.insert(laji);return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody LajiEntity laji, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,laji:{}",this.getClass().getName(),laji.toString());LajiEntity oldLajiEntity = lajiService.selectById(laji.getId());//查询原先数据String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");if("".equals(laji.getLajiPhoto()) || "null".equals(laji.getLajiPhoto())){laji.setLajiPhoto(null);}lajiService.updateById(laji);//根据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<LajiEntity> oldLajiList =lajiService.selectBatchIds(Arrays.asList(ids));//要删除的数据ArrayList<LajiEntity> list = new ArrayList<>();for(Integer id:ids){LajiEntity lajiEntity = new LajiEntity();lajiEntity.setId(id);lajiEntity.setLajiDelete(2);list.add(lajiEntity);}if(list != null && list.size() >0){lajiService.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<LajiEntity> lajiList = 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){//循环LajiEntity lajiEntity = new LajiEntity();
// lajiEntity.setLajiName(data.get(0)); //垃圾名称 要改的
// lajiEntity.setLajiUuidNumber(data.get(0)); //垃圾编号 要改的
// lajiEntity.setLajiPhoto("");//详情和图片
// lajiEntity.setLajiTypes(Integer.valueOf(data.get(0))); //所属分类 要改的
// lajiEntity.setLajiClicknum(Integer.valueOf(data.get(0))); //词条热度 要改的
// lajiEntity.setLajiContent("");//详情和图片
// lajiEntity.setShangxiaTypes(Integer.valueOf(data.get(0))); //是否上架 要改的
// lajiEntity.setLajiDelete(1);//逻辑删除字段
// lajiEntity.setInsertTime(date);//时间
// lajiEntity.setCreateTime(date);//时间lajiList.add(lajiEntity);//把要查询是否重复的字段放入map中//垃圾编号if(seachFields.containsKey("lajiUuidNumber")){List<String> lajiUuidNumber = seachFields.get("lajiUuidNumber");lajiUuidNumber.add(data.get(0));//要改的}else{List<String> lajiUuidNumber = new ArrayList<>();lajiUuidNumber.add(data.get(0));//要改的seachFields.put("lajiUuidNumber",lajiUuidNumber);}}//查询是否重复//垃圾编号List<LajiEntity> lajiEntities_lajiUuidNumber = lajiService.selectList(new EntityWrapper<LajiEntity>().in("laji_uuid_number", seachFields.get("lajiUuidNumber")).eq("laji_delete", 1));if(lajiEntities_lajiUuidNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(LajiEntity s:lajiEntities_lajiUuidNumber){repeatFields.add(s.getLajiUuidNumber());}return R.error(511,"数据库的该表中的 [垃圾编号] 字段已经存在 存在数据为:"+repeatFields.toString());}lajiService.insertBatch(lajiList);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<LajiView> returnLajiViewList = new ArrayList<>();//查看收藏Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));PageUtils pageUtils = lajiCollectionService.queryPage(params1);List<LajiCollectionView> collectionViewsList =(List<LajiCollectionView>)pageUtils.getList();Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型listfor(LajiCollectionView collectionView:collectionViewsList){Integer lajiTypes = collectionView.getLajiTypes();if(typeMap.containsKey(lajiTypes)){typeMap.put(lajiTypes,typeMap.get(lajiTypes)+1);}else{typeMap.put(lajiTypes,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("lajiTypes",type);PageUtils pageUtils1 = lajiService.queryPage(params2);List<LajiView> lajiViewList =(List<LajiView>)pageUtils1.getList();returnLajiViewList.addAll(lajiViewList);if(returnLajiViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环}//正常查询出来商品,用于补全推荐缺少的数据PageUtils page = lajiService.queryPage(params);if(returnLajiViewList.size()<limit){//返回数量还是小于要求数量int toAddNum = limit - returnLajiViewList.size();//要添加的数量List<LajiView> lajiViewList =(List<LajiView>)page.getList();for(LajiView lajiView:lajiViewList){Boolean addFlag = true;for(LajiView returnLajiView:returnLajiViewList){if(returnLajiView.getId().intValue() ==lajiView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品}if(addFlag){toAddNum=toAddNum-1;returnLajiViewList.add(lajiView);if(toAddNum==0) break;//够数量了}}}else {returnLajiViewList = returnLajiViewList.subList(0, limit);}for(LajiView c:returnLajiViewList)dictionaryService.dictionaryConvert(c, request);page.setList(returnLajiViewList);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 = lajiService.queryPage(params);//字典表数据转换List<LajiView> list =(List<LajiView>)page.getList();for(LajiView 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);LajiEntity laji = lajiService.selectById(id);if(laji !=null){//点击数量加1laji.setLajiClicknum(laji.getLajiClicknum()+1);lajiService.updateById(laji);//entity转viewLajiView view = new LajiView();BeanUtils.copyProperties( laji , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody LajiEntity laji, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,laji:{}",this.getClass().getName(),laji.toString());Wrapper<LajiEntity> queryWrapper = new EntityWrapper<LajiEntity>().eq("laji_name", laji.getLajiName()).eq("laji_uuid_number", laji.getLajiUuidNumber()).eq("laji_types", laji.getLajiTypes()).eq("laji_clicknum", laji.getLajiClicknum()).eq("shangxia_types", laji.getShangxiaTypes()).eq("laji_delete", laji.getLajiDelete())
// .notIn("laji_types", new Integer[]{102});logger.info("sql语句:"+queryWrapper.getSqlSegment());LajiEntity lajiEntity = lajiService.selectOne(queryWrapper);if(lajiEntity==null){laji.setLajiClicknum(1);laji.setLajiDelete(1);laji.setInsertTime(new Date());laji.setCreateTime(new Date());lajiService.insert(laji);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.LajiEntity;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import java.util.List;/*** 垃圾 服务类*/
public interface LajiService extends IService<LajiEntity> {/*** @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.LajiDao;
import com.entity.LajiEntity;
import com.service.LajiService;
import com.entity.view.LajiView;/*** 垃圾 服务实现类*/
@Service("lajiService")
@Transactional
public class LajiServiceImpl extends ServiceImpl<LajiDao, LajiEntity> implements LajiService {@Overridepublic PageUtils queryPage(Map<String,Object> params) {Page<LajiView> page =new Query<LajiView>(params).getPage();page.setRecords(baseMapper.selectListView(page,params));return new PageUtils(page);}}
5.4 垃圾Dao模块
package com.dao;import com.entity.LajiEntity;
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.LajiView;/*** 垃圾 Dao 接口** @author */
public interface LajiDao extends BaseMapper<LajiEntity> {List<LajiView> selectListView(Pagination page,@Param("params")Map<String,Object> params);}
6、论文目录结构
7、源码获取
感谢大家的阅读,如有不懂的问题可以评论区交流或私聊!
喜欢文章可以点赞、收藏、关注、评论啦
→获取源码请私信←