博主介绍:✌从事软件开发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 项目介绍
现代社会,美食不仅是满足人们基本生存需求的方式,更是一种文化和生活方式的体现。随着互联网技术的发展,人们获取美食信息的途径日益多样化,但信息的碎片化和个性化需求的增长使得用户在海量的美食信息中寻找到适合自己的内容变得困难。因此,开发一个基于Java的美食信息推荐系统,能够根据用户的个人喜好和饮食习惯,智能推荐个性化的菜谱和饮食资讯,对于提升用户体验和满足用户需求具有重要意义。该系统的设计和实现还将涉及到用户界面(UI)的友好性、系统的可扩展性、数据的安全性和隐私保护等方面,这些都是当前互联网应用开发中的关键问题。通过本课题的研究,不仅可以推动美食信息推荐技术的创新,还可以为相关领域的研究和实践提供参考,具有较高的学术价值和实际应用价值。
1.2 开发技术
Java开发语言、SpringBoot、MyBatisPlus、MySQL数据库、Maven、IDEA开发工具、JDK1.8+、Vue、HTML、CSS、JS。
2、系统功能设计结构图
管理员:登录、首页、个人中心(修改密码、个人信息)、管理员管理、用户管理、菜谱管理、论坛管理、饮食资讯管理、基础数据管理(菜谱类型管理、口味管理、资讯类型管理)、轮播图管理。
用户:注册、登录、首页、菜谱、论坛、饮食资讯、个人中心(个人中心、菜谱)
3、功能截图
3.1 前台功能
登录
首页
菜谱
论坛
饮食资讯
个人中心
3.2 后台功能
登录
首页
菜谱管理
论坛管理
饮食资讯管理
4、数据库表结构设计
CREATE DATABASE /*!32312 IF NOT EXISTS*/`meishixinxituijianxitong` /*!40100 DEFAULT CHARACTER SET utf8 */;USE `meishixinxituijianxitong`;/*Table structure for table `caipu` */DROP TABLE IF EXISTS `caipu`;CREATE TABLE `caipu` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`caipu_name` varchar(200) DEFAULT NULL COMMENT '菜谱名称 Search111 ',`caipu_uuid_number` varchar(200) DEFAULT NULL COMMENT '菜谱编号',`caipu_photo` varchar(200) DEFAULT NULL COMMENT '菜谱照片',`caipu_weizhi` varchar(200) DEFAULT NULL COMMENT '小店位置',`caipu_video` varchar(200) DEFAULT NULL COMMENT '视频推荐',`caipu_jiage` decimal(10,2) DEFAULT NULL COMMENT '菜品价格 ',`caipu_types` int(11) DEFAULT NULL COMMENT '菜谱类型 Search111',`caipu_kouwei_types` int(11) DEFAULT NULL COMMENT '口味 Search111',`caipu_clicknum` int(11) DEFAULT NULL COMMENT '菜谱热度',`caipu_content` text 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 `caipu` */insert into `caipu`(`id`,`caipu_name`,`caipu_uuid_number`,`caipu_photo`,`caipu_weizhi`,`caipu_video`,`caipu_jiage`,`caipu_types`,`caipu_kouwei_types`,`caipu_clicknum`,`caipu_content`,`insert_time`,`create_time`) values (1,'菜谱名称1','1677844866370','/upload/1677849348584.jpg','小店位置1','upload/video.mp4','787.31',1,4,309,'<p>菜品介绍1</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(2,'菜谱名称2','1677844866345','/upload/1677849334456.jpg','小店位置2','upload/video.mp4','754.58',4,2,25,'<p>菜品介绍2</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(4,'菜谱名称4','1677844866351','/upload/1677849308941.jpg','小店位置4','upload/video.mp4','544.14',1,3,105,'<p>菜品介绍4</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(5,'菜谱名称5','1677844866361','/upload/1677849293852.jpg','小店位置5','upload/video.mp4','558.14',4,2,314,'<p>菜品介绍5</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(6,'菜谱名称6','1677844866355','/upload/1677849281396.jpg','小店位置6','upload/video.mp4','65.88',3,3,385,'<p>菜品介绍6</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(7,'菜谱名称7','1677844866346','/upload/1677849269378.jpg','小店位置7','upload/video.mp4','926.45',2,1,388,'<p>菜品介绍7</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(8,'菜谱名称8','1677844866318','/upload/1677849256219.jpg','小店位置8','upload/video.mp4','378.70',4,1,148,'<p>菜品介绍8</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(9,'菜谱名称9','1677844866317','/upload/1677849239928.jpg','小店位置9','upload/video.mp4','247.47',2,2,254,'<p>菜品介绍9</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(10,'菜谱名称10','1677844866337','/upload/1677849225897.jpg','小店位置10','upload/video.mp4','425.23',2,4,86,'<p>菜品介绍10</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(11,'菜谱名称11','1677844866334','/upload/1677849214174.jpg','小店位置11','upload/video.mp4','575.76',3,4,30,'<p>菜品介绍11</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(12,'菜谱名称12','1677844866344','/upload/1677849203017.jpg','小店位置12','upload/video.mp4','331.12',1,4,405,'<p>菜品介绍12</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(13,'菜谱名称13','1677844866319','/upload/1677849191928.jpg','小店位置13','upload/video.mp4','128.45',3,1,385,'<p>菜品介绍13</p>','2023-03-03 20:01:06','2023-03-03 20:01:06'),(14,'菜谱名称14','1677844866330','/upload/1677849181906.jpg','小店位置14','upload/video.mp4','810.27',2,4,118,'<p>菜品介绍14</p>','2023-03-03 20:01:06','2023-03-03 20:01:06');/*Table structure for table `config` */DROP TABLE IF EXISTS `config`;CREATE TABLE `config` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`name` varchar(100) NOT 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=17 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-03 20:00:53'),(2,'sex_types','性别类型',2,'女',NULL,NULL,'2023-03-03 20:00:53'),(3,'caipu_types','菜谱类型',1,'菜谱类型1',NULL,NULL,'2023-03-03 20:00:53'),(4,'caipu_types','菜谱类型',2,'菜谱类型2',NULL,NULL,'2023-03-03 20:00:53'),(5,'caipu_types','菜谱类型',3,'菜谱类型3',NULL,NULL,'2023-03-03 20:00:53'),(6,'caipu_types','菜谱类型',4,'菜谱类型4',NULL,NULL,'2023-03-03 20:00:54'),(7,'caipu_kouwei_types','口味',1,'麻辣',NULL,NULL,'2023-03-03 20:00:54'),(8,'caipu_kouwei_types','口味',2,'鲜香',NULL,NULL,'2023-03-03 20:00:54'),(9,'caipu_kouwei_types','口味',3,'清淡',NULL,NULL,'2023-03-03 20:00:54'),(10,'caipu_kouwei_types','口味',4,'香辣',NULL,NULL,'2023-03-03 20:00:54'),(11,'forum_state_types','帖子状态',1,'发帖',NULL,NULL,'2023-03-03 20:00:54'),(12,'forum_state_types','帖子状态',2,'回帖',NULL,NULL,'2023-03-03 20:00:54'),(13,'forum_collection_types','收藏表类型',1,'收藏',NULL,NULL,'2023-03-03 20:00:54'),(14,'forum_collection_types','收藏表类型',2,'赞',NULL,NULL,'2023-03-03 20:00:54'),(15,'gonggao_types','资讯类型',1,'资讯类型1',NULL,NULL,'2023-03-03 20:00:54'),(16,'gonggao_types','资讯类型',2,'资讯类型2',NULL,NULL,'2023-03-03 20:00:54');/*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 '发布内容',`zan_number` int(11) DEFAULT NULL COMMENT '赞',`cai_number` int(11) DEFAULT NULL 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=15 DEFAULT CHARSET=utf8 COMMENT='论坛';/*Data for the table `forum` */insert into `forum`(`id`,`forum_name`,`yonghu_id`,`users_id`,`forum_content`,`zan_number`,`cai_number`,`super_ids`,`forum_state_types`,`insert_time`,`update_time`,`create_time`) values (1,'帖子标题1',1,NULL,'发布内容1',432,322,84,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(2,'帖子标题2',2,NULL,'发布内容2',343,257,420,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(3,'帖子标题3',2,NULL,'发布内容3',466,109,406,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(4,'帖子标题4',1,NULL,'发布内容4',352,219,247,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(5,'帖子标题5',2,NULL,'发布内容5',128,8,466,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(6,'帖子标题6',3,NULL,'发布内容6',253,404,144,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(7,'帖子标题7',3,NULL,'发布内容7',400,413,124,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(8,'帖子标题8',1,NULL,'发布内容8',236,411,31,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(9,'帖子标题9',3,NULL,'发布内容9',41,48,106,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(10,'帖子标题10',3,NULL,'发布内容10',242,156,145,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(11,'帖子标题11',2,NULL,'发布内容11',77,150,471,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(12,'帖子标题12',3,NULL,'发布内容12',330,195,204,1,'2023-03-03 20:01:06','2023-03-03 20:01:06','2023-03-03 20:01:06'),(13,'帖子标题13',1,NULL,'发布内容13',209,285,285,1,'2023-03-03 20:01:06','2023-03-03 21:25:48','2023-03-03 20:01:06'),(14,'帖子标题14',3,NULL,'发布内容14',206,424,36,1,'2023-03-03 20:01:06','2023-03-03 21:25:40','2023-03-03 20:01:06');/*Table structure for table `forum_collection` */DROP TABLE IF EXISTS `forum_collection`;CREATE TABLE `forum_collection` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`forum_id` int(11) DEFAULT NULL COMMENT '论坛',`yonghu_id` int(11) DEFAULT NULL COMMENT '用户',`forum_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=18 DEFAULT CHARSET=utf8 COMMENT='论坛收藏';/*Data for the table `forum_collection` */insert into `forum_collection`(`id`,`forum_id`,`yonghu_id`,`forum_collection_types`,`insert_time`,`create_time`) values (1,1,1,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(2,2,3,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(3,3,2,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(4,4,2,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(5,5,3,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(6,6,2,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(7,7,2,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(8,8,1,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(9,9,3,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(10,10,2,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(11,11,1,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(12,12,3,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(14,14,3,1,'2023-03-03 20:01:06','2023-03-03 20:01:06'),(17,14,1,2,'2023-03-03 21:25:40','2023-03-03 21:25:40');/*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-03 20:01:06','资讯详情1','2023-03-03 20:01:06'),(2,'饮食资讯2','upload/gonggao2.jpg',2,'2023-03-03 20:01:06','资讯详情2','2023-03-03 20:01:06'),(3,'饮食资讯3','upload/gonggao3.jpg',2,'2023-03-03 20:01:06','资讯详情3','2023-03-03 20:01:06'),(4,'饮食资讯4','upload/gonggao4.jpg',2,'2023-03-03 20:01:06','资讯详情4','2023-03-03 20:01:06'),(5,'饮食资讯5','upload/gonggao5.jpg',1,'2023-03-03 20:01:06','资讯详情5','2023-03-03 20:01:06'),(6,'饮食资讯6','upload/gonggao6.jpg',1,'2023-03-03 20:01:06','资讯详情6','2023-03-03 20:01:06'),(7,'饮食资讯7','upload/gonggao7.jpg',2,'2023-03-03 20:01:06','资讯详情7','2023-03-03 20:01:06'),(8,'饮食资讯8','upload/gonggao8.jpg',1,'2023-03-03 20:01:06','资讯详情8','2023-03-03 20:01:06'),(9,'饮食资讯9','upload/gonggao9.jpg',1,'2023-03-03 20:01:06','资讯详情9','2023-03-03 20:01:06'),(10,'饮食资讯10','upload/gonggao10.jpg',1,'2023-03-03 20:01:06','资讯详情10','2023-03-03 20:01:06'),(11,'饮食资讯11','upload/gonggao11.jpg',1,'2023-03-03 20:01:06','资讯详情11','2023-03-03 20:01:06'),(12,'饮食资讯12','upload/gonggao12.jpg',1,'2023-03-03 20:01:06','资讯详情12','2023-03-03 20:01:06'),(13,'饮食资讯13','upload/gonggao13.jpg',2,'2023-03-03 20:01:06','资讯详情13','2023-03-03 20:01:06'),(14,'饮食资讯14','upload/gonggao14.jpg',2,'2023-03-03 20:01:06','资讯详情14','2023-03-03 20:01:06');/*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,'a1','yonghu','用户','0h4dii6p8mmxo0vz9bykwivn7mjvdbix','2023-03-03 20:02:23','2023-03-03 22:25:06'),(2,1,'admin','users','管理员','ejeuo5614pbti20vshgnx3n9tqmjtkvi','2023-03-03 20:44:05','2023-03-03 22:37:20');/*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-03 20:00:53');/*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=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`,`create_time`) values (1,'a1','123456','用户姓名1','17703786901','410224199010102001','upload/yonghu1.jpg',1,'1@qq.com','2023-03-03 20:01:06'),(2,'a2','123456','用户姓名2','17703786902','410224199010102002','upload/yonghu2.jpg',2,'2@qq.com','2023-03-03 20:01:06'),(3,'a3','123456','用户姓名3','17703786903','410224199010102003','upload/yonghu3.jpg',2,'3@qq.com','2023-03-03 20:01:06');/*!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
*/
@RestController
@Controller
@RequestMapping("/caipu")
public class CaipuController {private static final Logger logger = LoggerFactory.getLogger(CaipuController.class);private static final String TABLE_NAME = "caipu";@Autowiredprivate CaipuService caipuService;@Autowiredprivate TokenService tokenService;@Autowiredprivate DictionaryService dictionaryService;//级联表非注册的service//注册表service@Autowiredprivate YonghuService yonghuService;/*** 后端列表*/@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"));CommonUtil.checkMap(params);PageUtils page = caipuService.queryPage(params);//字典表数据转换List<CaipuView> list =(List<CaipuView>)page.getList();for(CaipuView 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);CaipuEntity caipu = caipuService.selectById(id);if(caipu !=null){//entity转viewCaipuView view = new CaipuView();BeanUtils.copyProperties( caipu , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody CaipuEntity caipu, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,caipu:{}",this.getClass().getName(),caipu.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");Wrapper<CaipuEntity> queryWrapper = new EntityWrapper<CaipuEntity>().eq("caipu_name", caipu.getCaipuName()).eq("caipu_weizhi", caipu.getCaipuWeizhi()).eq("caipu_video", caipu.getCaipuVideo()).eq("caipu_types", caipu.getCaipuTypes()).eq("caipu_kouwei_types", caipu.getCaipuKouweiTypes()).eq("caipu_clicknum", caipu.getCaipuClicknum());logger.info("sql语句:"+queryWrapper.getSqlSegment());CaipuEntity caipuEntity = caipuService.selectOne(queryWrapper);if(caipuEntity==null){caipu.setCaipuClicknum(1);caipu.setInsertTime(new Date());caipu.setCreateTime(new Date());caipuService.insert(caipu);return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody CaipuEntity caipu, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,caipu:{}",this.getClass().getName(),caipu.toString());CaipuEntity oldCaipuEntity = caipuService.selectById(caipu.getId());//查询原先数据String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");if("".equals(caipu.getCaipuPhoto()) || "null".equals(caipu.getCaipuPhoto())){caipu.setCaipuPhoto(null);}if("".equals(caipu.getCaipuVideo()) || "null".equals(caipu.getCaipuVideo())){caipu.setCaipuVideo(null);}caipuService.updateById(caipu);//根据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<CaipuEntity> oldCaipuList =caipuService.selectBatchIds(Arrays.asList(ids));//要删除的数据caipuService.deleteBatchIds(Arrays.asList(ids));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<CaipuEntity> caipuList = 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){//循环CaipuEntity caipuEntity = new CaipuEntity();
// caipuEntity.setCaipuName(data.get(0)); //菜谱名称 要改的
// caipuEntity.setCaipuUuidNumber(data.get(0)); //菜谱编号 要改的
// caipuEntity.setCaipuPhoto("");//详情和图片
// caipuEntity.setCaipuWeizhi(data.get(0)); //小店位置 要改的
// caipuEntity.setCaipuVideo(data.get(0)); //视频推荐 要改的
// caipuEntity.setCaipuJiage(data.get(0)); //菜品价格 要改的
// caipuEntity.setCaipuTypes(Integer.valueOf(data.get(0))); //菜谱类型 要改的
// caipuEntity.setCaipuKouweiTypes(Integer.valueOf(data.get(0))); //口味 要改的
// caipuEntity.setCaipuClicknum(Integer.valueOf(data.get(0))); //菜谱热度 要改的
// caipuEntity.setCaipuContent("");//详情和图片
// caipuEntity.setInsertTime(date);//时间
// caipuEntity.setCreateTime(date);//时间caipuList.add(caipuEntity);//把要查询是否重复的字段放入map中//菜谱编号if(seachFields.containsKey("caipuUuidNumber")){List<String> caipuUuidNumber = seachFields.get("caipuUuidNumber");caipuUuidNumber.add(data.get(0));//要改的}else{List<String> caipuUuidNumber = new ArrayList<>();caipuUuidNumber.add(data.get(0));//要改的seachFields.put("caipuUuidNumber",caipuUuidNumber);}}//查询是否重复//菜谱编号List<CaipuEntity> caipuEntities_caipuUuidNumber = caipuService.selectList(new EntityWrapper<CaipuEntity>().in("caipu_uuid_number", seachFields.get("caipuUuidNumber")));if(caipuEntities_caipuUuidNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(CaipuEntity s:caipuEntities_caipuUuidNumber){repeatFields.add(s.getCaipuUuidNumber());}return R.error(511,"数据库的该表中的 [菜谱编号] 字段已经存在 存在数据为:"+repeatFields.toString());}caipuService.insertBatch(caipuList);return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入数据异常,请联系管理员");}}/*** 前端列表*/@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 = caipuService.queryPage(params);//字典表数据转换List<CaipuView> list =(List<CaipuView>)page.getList();for(CaipuView 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);CaipuEntity caipu = caipuService.selectById(id);if(caipu !=null){//点击数量加1caipu.setCaipuClicknum(caipu.getCaipuClicknum()+1);caipuService.updateById(caipu);//entity转viewCaipuView view = new CaipuView();BeanUtils.copyProperties( caipu , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody CaipuEntity caipu, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,caipu:{}",this.getClass().getName(),caipu.toString());Wrapper<CaipuEntity> queryWrapper = new EntityWrapper<CaipuEntity>().eq("caipu_name", caipu.getCaipuName()).eq("caipu_uuid_number", caipu.getCaipuUuidNumber()).eq("caipu_weizhi", caipu.getCaipuWeizhi()).eq("caipu_video", caipu.getCaipuVideo()).eq("caipu_types", caipu.getCaipuTypes()).eq("caipu_kouwei_types", caipu.getCaipuKouweiTypes()).eq("caipu_clicknum", caipu.getCaipuClicknum());logger.info("sql语句:"+queryWrapper.getSqlSegment());CaipuEntity caipuEntity = caipuService.selectOne(queryWrapper);if(caipuEntity==null){caipu.setInsertTime(new Date());caipu.setCreateTime(new Date());caipuService.insert(caipu);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.CaipuEntity;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import java.util.List;/*** 菜谱 服务类*/
public interface CaipuService extends IService<CaipuEntity> {/*** @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.CaipuDao;
import com.entity.CaipuEntity;
import com.service.CaipuService;
import com.entity.view.CaipuView;/*** 菜谱 服务实现类*/
@Service("caipuService")
@Transactional
public class CaipuServiceImpl extends ServiceImpl<CaipuDao, CaipuEntity> implements CaipuService {@Overridepublic PageUtils queryPage(Map<String,Object> params) {Page<CaipuView> page =new Query<CaipuView>(params).getPage();page.setRecords(baseMapper.selectListView(page,params));return new PageUtils(page);}}
5.4 菜谱Dao模块
package com.dao;import com.entity.CaipuEntity;
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.CaipuView;/*** 菜谱 Dao 接口** @author 学长编程*/
public interface CaipuDao extends BaseMapper<CaipuEntity> {List<CaipuView> selectListView(Pagination page,@Param("params")Map<String,Object> params);}
6、论文目录结构
7、源码获取
感谢大家的阅读,如有不懂的问题可以评论区交流或私聊!
喜欢文章可以点赞、收藏、关注、评论啦
→获取源码请私信←