计算机毕业设计 基于SSM的果蔬作物疾病防治系统的设计与实现 Java实战项目 附源码+文档+视频讲解

发布时间:2024年01月03日

博主介绍:?从事软件开发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 项目介绍

信息数据从传统到当代,是一直在变革当中,突如其来的互联网让传统的信息管理看到了革命性的曙光,因为传统信息管理从时效性,还是安全性,还是可操作性等各个方面来讲,遇到了互联网时代才发现能补上自古以来的短板,有效的提升管理的效率和业务水平。传统的管理模式,时间越久管理的内容越多,也需要更多的人来对数据进行整理,并且数据的汇总查询方面效率也是极其的低下,并且数据安全方面永远不会保证安全性能。结合数据内容管理的种种缺点,在互联网时代都可以得到有效的补充。结合先进的互联网技术,开发符合需求的软件,让数据内容管理不管是从录入的及时性,查看的及时性还是汇总分析的及时性,都能让正确率达到最高,管理更加的科学和便捷。本次开发的果蔬作物疾病防治系统实现了字典管理、论坛管理、公告管理、果蔬百科管理、果蔬百科收藏管理、果蔬百科留言管理、用户管理、预警管理、专家管理、专家咨询管理、管理员管理等功能。系统用到了关系型数据库中王者MySql作为系统的数据库,有效的对数据进行安全的存储,有效的备份,对数据可靠性方面得到了保证。并且程序也具备程序需求的所有功能,使得操作性还是安全性都大大提高,让果蔬作物疾病防治系统更能从理念走到现实,确确实实的让人们提升信息处理效率。

1.2 开发技术

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

2、系统功能设计结构图

3、功能截图

果蔬百科:管理员可以查看果蔬百科、新增果蔬百科、修改果蔬百科、删除果蔬百科等。

公告信息:?管理员可以对公告信息进行管理,可以新增公告信息,修改公告信息,删除无效的公告信息。

公告类型:?在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。

4、数据库表结构设计

CREATE DATABASE /*!32312 IF NOT EXISTS*/`guoshuzuowujibingfangzhi` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `guoshuzuowujibingfangzhi`;

/*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=28 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 (1,'sex_types','性别类型',1,'男',NULL,NULL,'2023-03-15 10:49:28'),(2,'sex_types','性别类型',2,'女',NULL,NULL,'2023-03-15 10:49:28'),(3,'gonggao_types','公告类型',1,'公告类型1',NULL,NULL,'2023-03-15 10:49:28'),(4,'gonggao_types','公告类型',2,'公告类型2',NULL,NULL,'2023-03-15 10:49:28'),(5,'forum_types','帖子类型',1,'帖子类型1',NULL,NULL,'2023-03-15 10:49:28'),(6,'forum_types','帖子类型',2,'帖子类型2',NULL,NULL,'2023-03-15 10:49:28'),(7,'forum_types','帖子类型',3,'帖子类型3',NULL,NULL,'2023-03-15 10:49:28'),(8,'forum_state_types','帖子状态',1,'发帖',NULL,NULL,'2023-03-15 10:49:28'),(9,'forum_state_types','帖子状态',2,'回帖',NULL,NULL,'2023-03-15 10:49:28'),(10,'yujing_types','预警类型',1,'预警类型1',NULL,NULL,'2023-03-15 10:49:28'),(11,'yujing_types','预警类型',2,'预警类型2',NULL,NULL,'2023-03-15 10:49:28'),(12,'shangxia_types','上下架',1,'上架',NULL,NULL,'2023-03-15 10:49:28'),(13,'shangxia_types','上下架',2,'下架',NULL,NULL,'2023-03-15 10:49:28'),(14,'guoshu_types','果蔬类型',1,'果蔬类型1',NULL,NULL,'2023-03-15 10:49:28'),(15,'guoshu_types','果蔬类型',2,'果蔬类型2',NULL,NULL,'2023-03-15 10:49:28'),(16,'guoshu_erji_types','二级类型',1,'果蔬类型11',1,NULL,'2023-03-15 10:49:28'),(17,'guoshu_erji_types','二级类型',2,'果蔬类型12',1,NULL,'2023-03-15 10:49:28'),(18,'guoshu_erji_types','二级类型',3,'果蔬类型21',2,NULL,'2023-03-15 10:49:28'),(19,'guoshu_erji_types','二级类型',4,'果蔬类型222',2,NULL,'2023-03-15 10:49:28'),(20,'guoshu_collection_types','收藏表类型',1,'收藏',NULL,NULL,'2023-03-15 10:49:28'),(21,'yanjiufangxiang_types','研究方向',1,'研究方向1',NULL,NULL,'2023-03-15 10:49:28'),(22,'yanjiufangxiang_types','研究方向',2,'研究方向2',NULL,NULL,'2023-03-15 10:49:29'),(23,'zhuanjia_chat_types','数据类型',1,'问题',NULL,NULL,'2023-03-15 10:49:29'),(24,'zhuanjia_chat_types','数据类型',2,'回复',NULL,NULL,'2023-03-15 10:49:29'),(25,'zhuangtai_types','状态',1,'未回复',NULL,NULL,'2023-03-15 10:49:29'),(26,'zhuangtai_types','状态',2,'已回复',NULL,NULL,'2023-03-15 10:49:29'),(27,'guoshu_erji_types','二级类型',5,'二级111',2,'','2023-03-15 11:30:28');

/*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 '用户',
  `zhuanjia_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=6 DEFAULT CHARSET=utf8 COMMENT='论坛';

/*Data for the table `forum` */

insert  into `forum`(`id`,`forum_name`,`yonghu_id`,`zhuanjia_id`,`users_id`,`forum_content`,`super_ids`,`forum_types`,`forum_state_types`,`insert_time`,`update_time`,`create_time`) values (1,'帖子1',1,NULL,NULL,'<p>该活动反倒是感受到固定死</p>',NULL,2,1,'2023-03-15 11:19:13',NULL,'2023-03-15 11:19:13'),(2,NULL,1,NULL,NULL,'斤斤计较',1,NULL,2,'2023-03-15 11:19:19',NULL,'2023-03-15 11:19:19'),(3,NULL,4,NULL,NULL,'和哼哼唧唧',1,NULL,2,'2023-03-15 11:29:06',NULL,'2023-03-15 11:29:06'),(4,NULL,NULL,NULL,1,'高公公',1,NULL,2,'2023-03-15 11:30:42',NULL,'2023-03-15 11:30:42'),(5,NULL,NULL,1,NULL,'很好',1,NULL,2,'2023-03-15 11:31:51',NULL,'2023-03-15 11:31:51');

/*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-15 10:49:31','公告详情1','2023-03-15 10:49:31'),(2,'公告名称2','upload/gonggao2.jpg',2,'2023-03-15 10:49:31','公告详情2','2023-03-15 10:49:31'),(3,'公告名称3','upload/gonggao3.jpg',1,'2023-03-15 10:49:31','公告详情3','2023-03-15 10:49:31'),(4,'公告名称4','upload/gonggao4.jpg',2,'2023-03-15 10:49:31','公告详情4','2023-03-15 10:49:31'),(5,'公告名称5','upload/gonggao5.jpg',1,'2023-03-15 10:49:31','公告详情5','2023-03-15 10:49:31'),(6,'公告名称6','upload/gonggao6.jpg',2,'2023-03-15 10:49:31','公告详情6','2023-03-15 10:49:31'),(7,'公告名称7','upload/gonggao7.jpg',1,'2023-03-15 10:49:31','公告详情7','2023-03-15 10:49:31'),(8,'公告名称8','upload/gonggao8.jpg',1,'2023-03-15 10:49:31','公告详情8','2023-03-15 10:49:31'),(9,'公告名称9','upload/gonggao9.jpg',1,'2023-03-15 10:49:31','公告详情9','2023-03-15 10:49:31'),(10,'公告名称10','upload/gonggao10.jpg',1,'2023-03-15 10:49:31','公告详情10','2023-03-15 10:49:31'),(11,'公告名称11','upload/gonggao11.jpg',2,'2023-03-15 10:49:31','公告详情11','2023-03-15 10:49:31'),(12,'公告名称12','upload/gonggao12.jpg',1,'2023-03-15 10:49:31','公告详情12','2023-03-15 10:49:31'),(13,'公告名称13','upload/gonggao13.jpg',2,'2023-03-15 10:49:31','公告详情13','2023-03-15 10:49:31'),(14,'公告名称14','upload/gonggao14.jpg',2,'2023-03-15 10:49:31','公告详情14','2023-03-15 10:49:31');

/*Table structure for table `guoshu` */

DROP TABLE IF EXISTS `guoshu`;

CREATE TABLE `guoshu` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',
  `guoshu_name` varchar(200) DEFAULT NULL COMMENT '果蔬名称  Search111 ',
  `guoshu_uuid_number` varchar(200) DEFAULT NULL COMMENT '果蔬编号',
  `guoshu_photo` varchar(200) DEFAULT NULL COMMENT '果蔬照片',
  `guoshu_types` int(11) DEFAULT NULL COMMENT '果蔬类型 Search111',
  `guoshu_erji_types` int(11) DEFAULT NULL COMMENT '二级类型 Search111',
  `guoshu_chandi` varchar(200) DEFAULT NULL COMMENT '果蔬产地 Search111',
  `guoshu_qihou` varchar(200) DEFAULT NULL COMMENT '气候 Search111',
  `guoshu_jijie` varchar(200) DEFAULT NULL COMMENT '季节 Search111',
  `guoshu_clicknum` int(11) DEFAULT NULL COMMENT '果蔬热度',
  `guoshu_content` text COMMENT '果蔬介绍',
  `guoshu_bingchonghai_content` text COMMENT '常见病虫害 Search111',
  `shangxia_types` int(11) DEFAULT NULL COMMENT '是否上架 ',
  `guoshu_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 `guoshu` */

insert  into `guoshu`(`id`,`guoshu_name`,`guoshu_uuid_number`,`guoshu_photo`,`guoshu_types`,`guoshu_erji_types`,`guoshu_chandi`,`guoshu_qihou`,`guoshu_jijie`,`guoshu_clicknum`,`guoshu_content`,`guoshu_bingchonghai_content`,`shangxia_types`,`guoshu_delete`,`insert_time`,`create_time`) values (1,'果蔬名称1','1678848571186','upload/guoshu1.jpg',1,1,'果蔬产地1','气候1','季节1',191,'果蔬介绍1','常见病虫害1',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(2,'果蔬名称2','1678848571189','upload/guoshu2.jpg',1,1,'果蔬产地2','气候2','季节2',305,'果蔬介绍2','常见病虫害2',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(3,'果蔬名称3','1678848571213','upload/guoshu3.jpg',1,1,'果蔬产地3','气候3','季节3',24,'果蔬介绍3','常见病虫害3',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(4,'果蔬名称4','1678848571190','upload/guoshu4.jpg',1,2,'果蔬产地4','气候4','季节4',50,'果蔬介绍4','常见病虫害4',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(5,'果蔬名称5','1678848571214','upload/guoshu5.jpg',1,2,'果蔬产地5','气候5','季节5',324,'果蔬介绍5','常见病虫害5',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(6,'果蔬名称6','1678848571257','upload/guoshu6.jpg',1,2,'果蔬产地6','气候6','季节6',478,'果蔬介绍6','常见病虫害6',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(7,'果蔬名称7','1678848571209','upload/guoshu7.jpg',2,3,'果蔬产地7','气候7','季节7',56,'果蔬介绍7','常见病虫害7',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(8,'果蔬名称8','1678848571188','upload/guoshu8.jpg',2,3,'果蔬产地8','气候8','季节8',369,'果蔬介绍8','常见病虫害8',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(9,'果蔬名称9','1678848571263','upload/guoshu9.jpg',2,3,'果蔬产地9','气候9','季节9',238,'果蔬介绍9','常见病虫害9',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(10,'果蔬名称10','1678848571223','upload/guoshu10.jpg',2,3,'果蔬产地10','气候10','季节10',236,'果蔬介绍10','常见病虫害10',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(11,'果蔬名称11','1678848571282','upload/guoshu11.jpg',2,4,'果蔬产地11','气候11','季节11',335,'果蔬介绍11','常见病虫害11',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(12,'果蔬名称12','1678848571203','upload/guoshu12.jpg',2,4,'果蔬产地12','气候12','季节12',281,'果蔬介绍12','常见病虫害12',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(13,'果蔬名称13','1678848571284','upload/guoshu13.jpg',2,4,'果蔬产地13','气候13','季节13',283,'果蔬介绍13','常见病虫害13',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(14,'果蔬名称14','1678848571286','upload/guoshu14.jpg',1,1,'果蔬产地14','气候14','季节14',17,'<p>果蔬介绍14</p>','<p>常见病虫害14广东佛山</p>',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31');

/*Table structure for table `guoshu_collection` */

DROP TABLE IF EXISTS `guoshu_collection`;

CREATE TABLE `guoshu_collection` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `guoshu_id` int(11) DEFAULT NULL COMMENT '果蔬百科',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '用户',
  `guoshu_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 `guoshu_collection` */

insert  into `guoshu_collection`(`id`,`guoshu_id`,`yonghu_id`,`guoshu_collection_types`,`insert_time`,`create_time`) values (1,1,1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(2,2,3,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(3,3,3,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(4,4,2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(5,5,2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(6,6,2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(7,7,1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(8,8,3,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(9,9,1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(10,10,1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(11,11,1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(12,12,2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(13,13,3,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(14,14,2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(15,11,4,1,'2023-03-15 11:29:14','2023-03-15 11:29:14');

/*Table structure for table `guoshu_liuyan` */

DROP TABLE IF EXISTS `guoshu_liuyan`;

CREATE TABLE `guoshu_liuyan` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `guoshu_id` int(11) DEFAULT NULL COMMENT '果蔬百科',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '用户',
  `guoshu_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 `guoshu_liuyan` */

insert  into `guoshu_liuyan`(`id`,`guoshu_id`,`yonghu_id`,`guoshu_liuyan_text`,`insert_time`,`reply_text`,`update_time`,`create_time`) values (1,1,1,'留言内容1','2023-03-15 10:49:31','回复信息1','2023-03-15 10:49:31','2023-03-15 10:49:31'),(2,2,3,'留言内容2','2023-03-15 10:49:31','回复信息2','2023-03-15 10:49:31','2023-03-15 10:49:31'),(3,3,3,'留言内容3','2023-03-15 10:49:31','回复信息3','2023-03-15 10:49:31','2023-03-15 10:49:31'),(4,4,3,'留言内容4','2023-03-15 10:49:31','回复信息4','2023-03-15 10:49:31','2023-03-15 10:49:31'),(5,5,3,'留言内容5','2023-03-15 10:49:31','回复信息5','2023-03-15 10:49:31','2023-03-15 10:49:31'),(6,6,1,'留言内容6','2023-03-15 10:49:31','回复信息6','2023-03-15 10:49:31','2023-03-15 10:49:31'),(7,7,2,'留言内容7','2023-03-15 10:49:31','回复信息7','2023-03-15 10:49:31','2023-03-15 10:49:31'),(8,8,1,'留言内容8','2023-03-15 10:49:31','回复信息8','2023-03-15 10:49:31','2023-03-15 10:49:31'),(9,9,1,'留言内容9','2023-03-15 10:49:31','回复信息9','2023-03-15 10:49:31','2023-03-15 10:49:31'),(10,10,1,'留言内容10','2023-03-15 10:49:31','回复信息10','2023-03-15 10:49:31','2023-03-15 10:49:31'),(11,11,3,'留言内容11','2023-03-15 10:49:31','回复信息11','2023-03-15 10:49:31','2023-03-15 10:49:31'),(12,12,3,'留言内容12','2023-03-15 10:49:31','回复信息12','2023-03-15 10:49:31','2023-03-15 10:49:31'),(13,13,1,'留言内容13','2023-03-15 10:49:31','回复信息13','2023-03-15 10:49:31','2023-03-15 10:49:31'),(14,14,1,'留言内容14','2023-03-15 10:49:31','回复信息14','2023-03-15 10:49:31','2023-03-15 10:49:31'),(15,11,4,'活动范德萨范德萨第三个号','2023-03-15 11:29:21','个哈哈哈','2023-03-15 11:31:11','2023-03-15 11:29:21');

/*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=6 DEFAULT CHARSET=utf8 COMMENT='token表';

/*Data for the table `token` */

insert  into `token`(`id`,`userid`,`username`,`tablename`,`role`,`token`,`addtime`,`expiratedtime`) values (1,1,'a1','yonghu','用户','o3o89altx268h95xj5wfxpxtpzeyjkut','2023-03-15 10:49:44','2023-03-15 11:49:44'),(2,1,'admin','users','管理员','rmpssmmt7hc36ik6bverl8ynxkvdqenf','2023-03-15 11:06:59','2023-03-15 12:35:31'),(3,1,'a1','zhuanjia','专家','jaik4aj8mtieu8tzifl5d5g7opw01kgl','2023-03-15 11:15:33','2023-03-15 12:31:35'),(4,4,'a5','yonghu','用户','ute9dry1jkz8ipra3z7xoytxq05wb1ic','2023-03-15 11:28:06','2023-03-15 12:28:06'),(5,2,'a2','zhuanjia','专家','mneui8ahyamuzmm244o5w7c9vyuy8z1p','2023-03-15 11:28:35','2023-03-15 12:28:35');

/*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-15 10:49:27');

/*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',1,'1@qq.com','2023-03-15 10:49:31'),(2,'a2','123456','用户姓名2','17703786902','410224199010102002','upload/yonghu2.jpg',1,'2@qq.com','2023-03-15 10:49:31'),(3,'a3','123456','用户姓名3','17703786903','410224199010102003','upload/yonghu3.jpg',2,'3@qq.com','2023-03-15 10:49:31'),(4,'a5','123456','张5','17788889999','111111222233332222','upload/1678850989428.jpg',2,'5@qq.com','2023-03-15 11:28:01');

/*Table structure for table `yujing` */

DROP TABLE IF EXISTS `yujing`;

CREATE TABLE `yujing` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',
  `yujing_name` varchar(200) DEFAULT NULL COMMENT '预警名称 Search111  ',
  `yujing_photo` varchar(200) DEFAULT NULL COMMENT '预警图片 ',
  `yujing_types` int(11) NOT NULL COMMENT '预警类型 Search111 ',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '预警发布时间 ',
  `yujing_content` text COMMENT '预警内容 ',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show2 nameShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='预警';

/*Data for the table `yujing` */

insert  into `yujing`(`id`,`yujing_name`,`yujing_photo`,`yujing_types`,`insert_time`,`yujing_content`,`create_time`) values (1,'预警名称1','upload/yujing1.jpg',1,'2023-03-15 10:49:31','预警内容1','2023-03-15 10:49:31'),(2,'预警名称2','upload/yujing2.jpg',2,'2023-03-15 10:49:31','预警内容2','2023-03-15 10:49:31'),(3,'预警名称3','upload/yujing3.jpg',1,'2023-03-15 10:49:31','预警内容3','2023-03-15 10:49:31'),(4,'预警名称4','upload/yujing4.jpg',2,'2023-03-15 10:49:31','预警内容4','2023-03-15 10:49:31'),(5,'预警名称5','upload/yujing5.jpg',2,'2023-03-15 10:49:31','预警内容5','2023-03-15 10:49:31'),(6,'预警名称6','upload/yujing6.jpg',2,'2023-03-15 10:49:31','预警内容6','2023-03-15 10:49:31'),(7,'预警名称7','upload/yujing7.jpg',2,'2023-03-15 10:49:31','预警内容7','2023-03-15 10:49:31'),(8,'预警名称8','upload/yujing8.jpg',1,'2023-03-15 10:49:31','预警内容8','2023-03-15 10:49:31'),(9,'预警名称9','upload/yujing9.jpg',1,'2023-03-15 10:49:31','预警内容9','2023-03-15 10:49:31'),(10,'预警名称10','upload/yujing10.jpg',1,'2023-03-15 10:49:31','预警内容10','2023-03-15 10:49:31'),(11,'预警名称11','upload/yujing11.jpg',2,'2023-03-15 10:49:31','预警内容11','2023-03-15 10:49:31'),(12,'预警名称12','upload/yujing12.jpg',2,'2023-03-15 10:49:31','预警内容12','2023-03-15 10:49:31'),(13,'预警名称13','upload/yujing13.jpg',2,'2023-03-15 10:49:31','预警内容13','2023-03-15 10:49:31'),(14,'预警名称14','upload/yujing14.jpg',2,'2023-03-15 10:49:31','预警内容14','2023-03-15 10:49:31');

/*Table structure for table `zhuanjia` */

DROP TABLE IF EXISTS `zhuanjia`;

CREATE TABLE `zhuanjia` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `username` varchar(200) DEFAULT NULL COMMENT '账户',
  `password` varchar(200) DEFAULT NULL COMMENT '密码',
  `zhuanjia_name` varchar(200) DEFAULT NULL COMMENT '专家姓名 Search111 ',
  `zhuanjia_phone` varchar(200) DEFAULT NULL COMMENT '专家手机号',
  `zhuanjia_id_number` varchar(200) DEFAULT NULL COMMENT '专家身份证号',
  `zhuanjia_photo` varchar(200) DEFAULT NULL COMMENT '专家头像',
  `sex_types` int(11) DEFAULT NULL COMMENT '性别',
  `yanjiufangxiang_types` int(11) DEFAULT NULL COMMENT '研究方向 Search111 ',
  `zhuanjia_email` varchar(200) DEFAULT NULL COMMENT '专家邮箱',
  `zhuanjia_content` text COMMENT '专家介绍',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show1 show2 photoShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='专家';

/*Data for the table `zhuanjia` */

insert  into `zhuanjia`(`id`,`username`,`password`,`zhuanjia_name`,`zhuanjia_phone`,`zhuanjia_id_number`,`zhuanjia_photo`,`sex_types`,`yanjiufangxiang_types`,`zhuanjia_email`,`zhuanjia_content`,`create_time`) values (1,'a1','123456','专家姓名1','17703786901','410224199010102001','upload/zhuanjia1.jpg',2,1,'1@qq.com','<p>专家介绍1固定士大夫第三个</p>','2023-03-15 10:49:31'),(2,'a2','123456','专家姓名2','17703786902','410224199010102002','upload/zhuanjia2.jpg',1,1,'2@qq.com','专家介绍2','2023-03-15 10:49:31'),(3,'a3','123456','专家姓名3','17703786903','410224199010102003','upload/zhuanjia3.jpg',1,2,'3@qq.com','专家介绍3','2023-03-15 10:49:31');

/*Table structure for table `zhuanjia_chat` */

DROP TABLE IF EXISTS `zhuanjia_chat`;

CREATE TABLE `zhuanjia_chat` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '提问人',
  `zhuanjia_id` int(11) DEFAULT NULL COMMENT '回答人',
  `zhuanjia_chat_issue_text` text COMMENT '问题',
  `zhuanjia_chat_issue_photo` varchar(200) DEFAULT NULL COMMENT '问题图片 ',
  `issue_time` timestamp NULL DEFAULT NULL COMMENT '问题时间',
  `zhuanjia_chat_reply_text` text COMMENT '回复',
  `zhuanjia_chat_reply_photo` varchar(200) DEFAULT NULL COMMENT '回复图片 ',
  `reply_time` timestamp NULL DEFAULT NULL COMMENT '回复时间',
  `zhuangtai_types` int(255) DEFAULT NULL COMMENT '状态',
  `zhuanjia_chat_types` int(11) DEFAULT NULL COMMENT '数据类型',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '提问时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8 COMMENT='专家咨询';

/*Data for the table `zhuanjia_chat` */

insert  into `zhuanjia_chat`(`id`,`yonghu_id`,`zhuanjia_id`,`zhuanjia_chat_issue_text`,`zhuanjia_chat_issue_photo`,`issue_time`,`zhuanjia_chat_reply_text`,`zhuanjia_chat_reply_photo`,`reply_time`,`zhuangtai_types`,`zhuanjia_chat_types`,`insert_time`,`create_time`) values (1,2,2,'问题1','upload/zhuanjia_chat_issue1.jpg','2023-03-15 10:49:31','回复1','upload/zhuanjia_chat_reply1.jpg','2023-03-15 10:49:31',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(2,3,2,'问题2','upload/zhuanjia_chat_issue2.jpg','2023-03-15 10:49:31','回复2','upload/zhuanjia_chat_reply2.jpg','2023-03-15 10:49:31',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(3,1,1,'问题3','upload/zhuanjia_chat_issue3.jpg','2023-03-15 10:49:31','回复3','upload/zhuanjia_chat_reply3.jpg','2023-03-15 10:49:31',1,2,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(4,2,1,'问题4','upload/zhuanjia_chat_issue4.jpg','2023-03-15 10:49:31','回复4','upload/zhuanjia_chat_reply4.jpg','2023-03-15 10:49:31',2,2,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(5,3,3,'问题5','upload/zhuanjia_chat_issue5.jpg','2023-03-15 10:49:31','回复5','upload/zhuanjia_chat_reply5.jpg','2023-03-15 10:49:31',2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(6,1,2,'问题6','upload/zhuanjia_chat_issue6.jpg','2023-03-15 10:49:31','回复6','upload/zhuanjia_chat_reply6.jpg','2023-03-15 10:49:31',1,2,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(7,3,2,'问题7','upload/zhuanjia_chat_issue7.jpg','2023-03-15 10:49:31','回复7','upload/zhuanjia_chat_reply7.jpg','2023-03-15 10:49:31',2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(8,1,2,'问题8','upload/zhuanjia_chat_issue8.jpg','2023-03-15 10:49:31','回复8','upload/zhuanjia_chat_reply8.jpg','2023-03-15 10:49:31',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(9,1,2,'问题9','upload/zhuanjia_chat_issue9.jpg','2023-03-15 10:49:31','回复9','upload/zhuanjia_chat_reply9.jpg','2023-03-15 10:49:31',1,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(10,2,2,'问题10','upload/zhuanjia_chat_issue10.jpg','2023-03-15 10:49:31','回复10','upload/zhuanjia_chat_reply10.jpg','2023-03-15 10:49:31',2,2,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(11,3,2,'问题11','upload/zhuanjia_chat_issue11.jpg','2023-03-15 10:49:31','回复11','upload/zhuanjia_chat_reply11.jpg','2023-03-15 10:49:31',1,2,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(12,3,1,'问题12','upload/zhuanjia_chat_issue12.jpg','2023-03-15 10:49:31','回复12','upload/zhuanjia_chat_reply12.jpg','2023-03-15 10:49:31',1,2,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(13,3,2,'问题13','upload/zhuanjia_chat_issue13.jpg','2023-03-15 10:49:31','回复13','upload/zhuanjia_chat_reply13.jpg','2023-03-15 10:49:31',2,2,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(14,3,2,'问题14','upload/zhuanjia_chat_issue14.jpg','2023-03-15 10:49:31','回复14','upload/zhuanjia_chat_reply14.jpg','2023-03-15 10:49:31',2,1,'2023-03-15 10:49:31','2023-03-15 10:49:31'),(15,1,1,'哈哈哈','upload/1678848633437.jpg','2023-03-15 10:50:38',NULL,NULL,NULL,1,1,'2023-03-15 10:50:39','2023-03-15 10:50:39'),(16,1,1,'个哈哈哈或','upload/1678848652352.jpg','2023-03-15 10:51:07',NULL,NULL,NULL,2,1,'2023-03-15 10:51:07','2023-03-15 10:51:07'),(17,1,1,'123','upload/1678848984193.jpg','2023-03-15 10:56:37',NULL,NULL,NULL,1,1,'2023-03-15 10:56:37','2023-03-15 10:56:37'),(18,1,1,'123',NULL,'2023-03-15 10:58:54',NULL,NULL,NULL,1,1,'2023-03-15 10:58:54','2023-03-15 10:58:54'),(19,1,1,'123123123',NULL,'2023-03-15 10:59:02',NULL,NULL,NULL,1,1,'2023-03-15 10:59:03','2023-03-15 10:59:03'),(20,1,1,'12312','upload/1678849228368.jpg','2023-03-15 11:00:34',NULL,NULL,NULL,1,1,'2023-03-15 11:00:35','2023-03-15 11:00:35'),(21,1,1,'ghh','upload/1678849520374.jpg','2023-03-15 11:05:34',NULL,NULL,NULL,1,1,'2023-03-15 11:05:34','2023-03-15 11:05:34'),(22,1,1,'烦都烦死','upload/1678849539248.jpg','2023-03-15 11:05:54',NULL,NULL,NULL,2,1,'2023-03-15 11:05:54','2023-03-15 11:05:54'),(23,1,1,'高公公','upload/1678849560674.jpg','2023-03-15 11:06:07',NULL,NULL,NULL,2,1,'2023-03-15 11:06:08','2023-03-15 11:06:08'),(24,1,1,'是是是','upload/1678849572044.jpg','2023-03-15 11:06:14',NULL,NULL,NULL,2,1,'2023-03-15 11:06:14','2023-03-15 11:06:14'),(25,1,1,'哈哈哈','upload/1678849599600.jpg','2023-03-15 11:06:53',NULL,NULL,NULL,2,1,'2023-03-15 11:06:53','2023-03-15 11:06:53'),(26,1,NULL,NULL,NULL,NULL,'沟沟壑壑',NULL,'2023-03-15 11:12:13',NULL,2,'2023-03-15 11:12:13','2023-03-15 11:12:13'),(27,1,NULL,NULL,NULL,NULL,'1111','','2023-03-15 11:12:21',NULL,2,'2023-03-15 11:12:21','2023-03-15 11:12:21'),(28,1,NULL,NULL,NULL,NULL,'个哈哈哈或','','2023-03-15 11:14:55',NULL,2,'2023-03-15 11:14:55','2023-03-15 11:14:55'),(29,1,NULL,NULL,NULL,NULL,'哈哈哈','','2023-03-15 11:15:16',NULL,2,'2023-03-15 11:15:17','2023-03-15 11:15:17'),(30,1,1,NULL,NULL,NULL,'哈哈哈',NULL,'2023-03-15 11:15:43',NULL,2,'2023-03-15 11:15:46','2023-03-15 11:15:46'),(31,1,1,NULL,NULL,NULL,'哈哈哈',NULL,'2023-03-15 11:17:40',NULL,2,'2023-03-15 11:17:40','2023-03-15 11:17:40'),(32,1,1,NULL,NULL,NULL,'坎坎坷坷','','2023-03-15 11:17:45',NULL,2,'2023-03-15 11:17:45','2023-03-15 11:17:45'),(33,1,1,NULL,NULL,NULL,'健康',NULL,'2023-03-15 11:18:42',NULL,2,'2023-03-15 11:18:42','2023-03-15 11:18:42'),(34,4,2,'gggg ','upload/1678850896099.jpg','2023-03-15 11:28:19',NULL,NULL,NULL,1,1,'2023-03-15 11:28:19','2023-03-15 11:28:19'),(35,4,2,'hfgfsg法大使馆第三个',NULL,'2023-03-15 11:28:23',NULL,NULL,NULL,2,1,'2023-03-15 11:28:23','2023-03-15 11:28:23'),(36,4,2,NULL,NULL,NULL,'刚刚好很好',NULL,'2023-03-15 11:28:43',NULL,2,'2023-03-15 11:28:43','2023-03-15 11:28:43'),(37,1,1,NULL,NULL,NULL,'回复等多个',NULL,'2023-03-15 11:32:12',NULL,2,'2023-03-15 11:32:12','2023-03-15 11:32:12');

/*!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("/guoshu")
public class GuoshuController {
    private static final Logger logger = LoggerFactory.getLogger(GuoshuController.class);

    private static final String TABLE_NAME = "guoshu";

    @Autowired
    private GuoshuService guoshuService;

    @Autowired
    private TokenService tokenService;

    @Autowired
    private DictionaryService dictionaryService;//字典
    @Autowired
    private ForumService forumService;//论坛
    @Autowired
    private GonggaoService gonggaoService;//公告
    @Autowired
    private GuoshuCollectionService guoshuCollectionService;//果蔬百科收藏
    @Autowired
    private GuoshuLiuyanService guoshuLiuyanService;//果蔬百科留言
    @Autowired
    private YonghuService yonghuService;//用户
    @Autowired
    private YujingService yujingService;//预警
    @Autowired
    private ZhuanjiaService zhuanjiaService;//专家
    @Autowired
    private ZhuanjiaChatService zhuanjiaChatService;//专家咨询
    @Autowired
    private 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"));
        else if("专家".equals(role))
            params.put("zhuanjiaId",request.getSession().getAttribute("userId"));
        params.put("guoshuDeleteStart",1);params.put("guoshuDeleteEnd",1);
        CommonUtil.checkMap(params);
        PageUtils page = guoshuService.queryPage(params);

        //字典表数据转换
        List<GuoshuView> list =(List<GuoshuView>)page.getList();
        for(GuoshuView 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);
        GuoshuEntity guoshu = guoshuService.selectById(id);
        if(guoshu !=null){
            //entity转view
            GuoshuView view = new GuoshuView();
            BeanUtils.copyProperties( guoshu , view );//把实体数据重构到view中
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody GuoshuEntity guoshu, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,guoshu:{}",this.getClass().getName(),guoshu.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");

        Wrapper<GuoshuEntity> queryWrapper = new EntityWrapper<GuoshuEntity>()
            .eq("guoshu_name", guoshu.getGuoshuName())
            .eq("guoshu_types", guoshu.getGuoshuTypes())
            .eq("guoshu_erji_types", guoshu.getGuoshuErjiTypes())
            .eq("guoshu_chandi", guoshu.getGuoshuChandi())
            .eq("guoshu_qihou", guoshu.getGuoshuQihou())
            .eq("guoshu_jijie", guoshu.getGuoshuJijie())
            .eq("shangxia_types", guoshu.getShangxiaTypes())
            .eq("guoshu_delete", guoshu.getGuoshuDelete())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        GuoshuEntity guoshuEntity = guoshuService.selectOne(queryWrapper);
        if(guoshuEntity==null){
            guoshu.setGuoshuClicknum(1);
            guoshu.setShangxiaTypes(1);
            guoshu.setGuoshuDelete(1);
            guoshu.setInsertTime(new Date());
            guoshu.setCreateTime(new Date());
            guoshuService.insert(guoshu);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody GuoshuEntity guoshu, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,guoshu:{}",this.getClass().getName(),guoshu.toString());
        GuoshuEntity oldGuoshuEntity = guoshuService.selectById(guoshu.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        if("".equals(guoshu.getGuoshuPhoto()) || "null".equals(guoshu.getGuoshuPhoto())){
                guoshu.setGuoshuPhoto(null);
        }

            guoshuService.updateById(guoshu);//根据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<GuoshuEntity> oldGuoshuList =guoshuService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        ArrayList<GuoshuEntity> list = new ArrayList<>();
        for(Integer id:ids){
            GuoshuEntity guoshuEntity = new GuoshuEntity();
            guoshuEntity.setId(id);
            guoshuEntity.setGuoshuDelete(2);
            list.add(guoshuEntity);
        }
        if(list != null && list.size() >0){
            guoshuService.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<GuoshuEntity> guoshuList = 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){
                            //循环
                            GuoshuEntity guoshuEntity = new GuoshuEntity();
//                            guoshuEntity.setGuoshuName(data.get(0));                    //果蔬名称 要改的
//                            guoshuEntity.setGuoshuUuidNumber(data.get(0));                    //果蔬编号 要改的
//                            guoshuEntity.setGuoshuPhoto("");//详情和图片
//                            guoshuEntity.setGuoshuTypes(Integer.valueOf(data.get(0)));   //果蔬类型 要改的
//                            guoshuEntity.setGuoshuErjiTypes(Integer.valueOf(data.get(0)));   //二级类型 要改的
//                            guoshuEntity.setGuoshuChandi(data.get(0));                    //果蔬产地 要改的
//                            guoshuEntity.setGuoshuQihou(data.get(0));                    //气候 要改的
//                            guoshuEntity.setGuoshuJijie(data.get(0));                    //季节 要改的
//                            guoshuEntity.setGuoshuClicknum(Integer.valueOf(data.get(0)));   //果蔬热度 要改的
//                            guoshuEntity.setGuoshuContent("");//详情和图片
//                            guoshuEntity.setGuoshuBingchonghaiContent("");//详情和图片
//                            guoshuEntity.setShangxiaTypes(Integer.valueOf(data.get(0)));   //是否上架 要改的
//                            guoshuEntity.setGuoshuDelete(1);//逻辑删除字段
//                            guoshuEntity.setInsertTime(date);//时间
//                            guoshuEntity.setCreateTime(date);//时间
                            guoshuList.add(guoshuEntity);

                            //把要查询是否重复的字段放入map中
                                //果蔬编号
                                if(seachFields.containsKey("guoshuUuidNumber")){
                                    List<String> guoshuUuidNumber = seachFields.get("guoshuUuidNumber");
                                    guoshuUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> guoshuUuidNumber = new ArrayList<>();
                                    guoshuUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("guoshuUuidNumber",guoshuUuidNumber);
                                }
                        }

                        //查询是否重复
                         //果蔬编号
                        List<GuoshuEntity> guoshuEntities_guoshuUuidNumber = guoshuService.selectList(new EntityWrapper<GuoshuEntity>().in("guoshu_uuid_number", seachFields.get("guoshuUuidNumber")).eq("guoshu_delete", 1));
                        if(guoshuEntities_guoshuUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(GuoshuEntity s:guoshuEntities_guoshuUuidNumber){
                                repeatFields.add(s.getGuoshuUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [果蔬编号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        guoshuService.insertBatch(guoshuList);
                        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<GuoshuView> returnGuoshuViewList = new ArrayList<>();

        //查看收藏
        Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));
        PageUtils pageUtils = guoshuCollectionService.queryPage(params1);
        List<GuoshuCollectionView> collectionViewsList =(List<GuoshuCollectionView>)pageUtils.getList();
        Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型list
        for(GuoshuCollectionView collectionView:collectionViewsList){
            Integer guoshuTypes = collectionView.getGuoshuTypes();
            if(typeMap.containsKey(guoshuTypes)){
                typeMap.put(guoshuTypes,typeMap.get(guoshuTypes)+1);
            }else{
                typeMap.put(guoshuTypes,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("guoshuTypes",type);
            PageUtils pageUtils1 = guoshuService.queryPage(params2);
            List<GuoshuView> guoshuViewList =(List<GuoshuView>)pageUtils1.getList();
            returnGuoshuViewList.addAll(guoshuViewList);
            if(returnGuoshuViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环
        }
        //正常查询出来商品,用于补全推荐缺少的数据
        PageUtils page = guoshuService.queryPage(params);
        if(returnGuoshuViewList.size()<limit){//返回数量还是小于要求数量
            int toAddNum = limit - returnGuoshuViewList.size();//要添加的数量
            List<GuoshuView> guoshuViewList =(List<GuoshuView>)page.getList();
            for(GuoshuView guoshuView:guoshuViewList){
                Boolean addFlag = true;
                for(GuoshuView returnGuoshuView:returnGuoshuViewList){
                    if(returnGuoshuView.getId().intValue() ==guoshuView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品
                }
                if(addFlag){
                    toAddNum=toAddNum-1;
                    returnGuoshuViewList.add(guoshuView);
                    if(toAddNum==0) break;//够数量了
                }
            }
        }else {
            returnGuoshuViewList = returnGuoshuViewList.subList(0, limit);
        }

        for(GuoshuView c:returnGuoshuViewList)
            dictionaryService.dictionaryConvert(c, request);
        page.setList(returnGuoshuViewList);
        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 = guoshuService.queryPage(params);

        //字典表数据转换
        List<GuoshuView> list =(List<GuoshuView>)page.getList();
        for(GuoshuView 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);
        GuoshuEntity guoshu = guoshuService.selectById(id);
            if(guoshu !=null){

                //点击数量加1
                guoshu.setGuoshuClicknum(guoshu.getGuoshuClicknum()+1);
                guoshuService.updateById(guoshu);

                //entity转view
                GuoshuView view = new GuoshuView();
                BeanUtils.copyProperties( guoshu , view );//把实体数据重构到view中

                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }

    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody GuoshuEntity guoshu, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,guoshu:{}",this.getClass().getName(),guoshu.toString());
        Wrapper<GuoshuEntity> queryWrapper = new EntityWrapper<GuoshuEntity>()
            .eq("guoshu_name", guoshu.getGuoshuName())
            .eq("guoshu_uuid_number", guoshu.getGuoshuUuidNumber())
            .eq("guoshu_types", guoshu.getGuoshuTypes())
            .eq("guoshu_erji_types", guoshu.getGuoshuErjiTypes())
            .eq("guoshu_chandi", guoshu.getGuoshuChandi())
            .eq("guoshu_qihou", guoshu.getGuoshuQihou())
            .eq("guoshu_jijie", guoshu.getGuoshuJijie())
            .eq("guoshu_clicknum", guoshu.getGuoshuClicknum())
            .eq("shangxia_types", guoshu.getShangxiaTypes())
            .eq("guoshu_delete", guoshu.getGuoshuDelete())
//            .notIn("guoshu_types", new Integer[]{102})
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        GuoshuEntity guoshuEntity = guoshuService.selectOne(queryWrapper);
        if(guoshuEntity==null){
            guoshu.setGuoshuClicknum(1);
            guoshu.setGuoshuDelete(1);
            guoshu.setInsertTime(new Date());
            guoshu.setCreateTime(new Date());
        guoshuService.insert(guoshu);

            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.GuoshuEntity;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import java.util.List;

/**
 * 果蔬百科 服务类
 */
public interface GuoshuService extends IService<GuoshuEntity> {

    /**
    * @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.GuoshuDao;
import com.entity.GuoshuEntity;
import com.service.GuoshuService;
import com.entity.view.GuoshuView;

/**
 * 果蔬百科 服务实现类
 */
@Service("guoshuService")
@Transactional
public class GuoshuServiceImpl extends ServiceImpl<GuoshuDao, GuoshuEntity> implements GuoshuService {

    @Override
    public PageUtils queryPage(Map<String,Object> params) {
        Page<GuoshuView> page =new Query<GuoshuView>(params).getPage();
        page.setRecords(baseMapper.selectListView(page,params));
        return new PageUtils(page);
    }

}

5.4?果蔬百科Dao模块

package com.dao;

import com.entity.GuoshuEntity;
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.GuoshuView;

/**
 * 果蔬百科 Dao 接口
 *
 * @author 
 */
public interface GuoshuDao extends BaseMapper<GuoshuEntity> {

   List<GuoshuView> selectListView(Pagination page,@Param("params")Map<String,Object> params);

}

6、论文目录结构

7、源码获取

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

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

获取源码请私信

文章来源:https://blog.csdn.net/m0_74181697/article/details/135351331
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。