本节代码开源地址

代码地址

项目运行截图

搭建后端工程

0.导入sql

在数据库导入

  1. /*
  2. Navicat Premium Data Transfer
  3. Source Server : localhost
  4. Source Server Type : MySQL
  5. Source Server Version : 80022
  6. Source Host : localhost:3306
  7. Source Schema : doubao
  8. Target Server Type : MySQL
  9. Target Server Version : 80022
  10. File Encoding : 65001
  11. */
  12. SET NAMES utf8mb4;
  13. SET FOREIGN_KEY_CHECKS = 0;
  14. -- ----------------------------
  15. -- Table structure for bms_billboard
  16. -- ----------------------------
  17. DROP TABLE IF EXISTS `bms_billboard`;
  18. CREATE TABLE `bms_billboard` (
  19. `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  20. `content` varchar(255) CHARACTER SET utf8mb4 NOT NULL COMMENT '公告',
  21. `create_time` datetime NULL DEFAULT NULL COMMENT '公告时间',
  22. `show` tinyint(1) NULL DEFAULT NULL COMMENT '1:展示中,0:过期',
  23. PRIMARY KEY (`id`) USING BTREE
  24. ) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COMMENT = '全站公告' ROW_FORMAT = DYNAMIC;
  25. -- ----------------------------
  26. -- Records of bms_billboard
  27. -- ----------------------------
  28. INSERT INTO `bms_billboard` VALUES (2, 'R1.0 开始已实现护眼模式 ,妈妈再也不用担心我的眼睛了。', '2020-11-19 17:16:19', 0);
  29. INSERT INTO `bms_billboard` VALUES (4, '系统已更新至最新版1.0.1', NULL, 1);
  30. -- ----------------------------
  31. -- Table structure for bms_follow
  32. -- ----------------------------
  33. DROP TABLE IF EXISTS `bms_follow`;
  34. CREATE TABLE `bms_follow` (
  35. `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  36. `parent_id` varchar(20) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '被关注人ID',
  37. `follower_id` varchar(20) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '关注人ID',
  38. PRIMARY KEY (`id`) USING BTREE
  39. ) ENGINE = InnoDB AUTO_INCREMENT = 130 CHARACTER SET = utf8mb4 COMMENT = '用户关注' ROW_FORMAT = DYNAMIC;
  40. -- ----------------------------
  41. -- Records of bms_follow
  42. -- ----------------------------
  43. INSERT INTO `bms_follow` VALUES (65, '1329723594994229250', '1317498859501797378');
  44. INSERT INTO `bms_follow` VALUES (85, '1332912847614083073', '1332636310897664002');
  45. INSERT INTO `bms_follow` VALUES (129, '1349290158897311745', '1349618748226658305');
  46. -- ----------------------------
  47. -- Table structure for bms_post
  48. -- ----------------------------
  49. DROP TABLE IF EXISTS `bms_post`;
  50. CREATE TABLE `bms_post` (
  51. `id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  52. `title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标题',
  53. `content` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 'markdown内容',
  54. `user_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '作者ID',
  55. `comments` int NOT NULL DEFAULT 0 COMMENT '评论统计',
  56. `collects` int NOT NULL DEFAULT 0 COMMENT '收藏统计',
  57. `view` int NOT NULL DEFAULT 0 COMMENT '浏览统计',
  58. `top` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否置顶,1-是,0-否',
  59. `essence` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否加精,1-是,0-否',
  60. `section_id` int NULL DEFAULT 0 COMMENT '专栏ID',
  61. `create_time` datetime NOT NULL COMMENT '发布时间',
  62. `modify_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  63. UNIQUE INDEX `title`(`title`) USING BTREE,
  64. INDEX `user_id`(`user_id`) USING BTREE,
  65. INDEX `create_time`(`create_time`) USING BTREE
  66. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '话题表' ROW_FORMAT = DYNAMIC;
  67. -- ----------------------------
  68. -- Records of bms_post
  69. -- ----------------------------
  70. INSERT INTO `bms_post` VALUES ('1333447953558765569', '1', '12\n2\n\n', '1349290158897311745', 0, 0, 77, b'0', b'0', 0, '2020-12-01 00:29:01', '2020-12-03 23:56:51');
  71. INSERT INTO `bms_post` VALUES ('1349362401438392322', '2021 健康,快乐', '2021的`FLAG`\n\n1. 技能进步\n2. 没有烦恼\n3. 发财 :smile:\n\n', '1349290158897311745', 0, 0, 21, b'0', b'0', 0, '2021-01-13 22:27:21', '2021-01-14 17:30:13');
  72. INSERT INTO `bms_post` VALUES ('1334481725322297346', 'hello,spring-security', ':hibiscus: spring-security\n\n', '1349290158897311745', 0, 0, 46, b'0', b'0', 0, '2020-12-03 20:56:51', NULL);
  73. INSERT INTO `bms_post` VALUES ('1332650453142827009', '哈哈哈,helloworld', '这是第一篇哦\n\n> hi :handshake: 你好\n\n`hello world`\n\n:+1: 很好\n', '1349290158897311745', 0, 0, 29, b'0', b'0', 1, '2020-11-28 19:40:02', '2020-11-28 19:46:39');
  74. INSERT INTO `bms_post` VALUES ('1333432347031646209', '哈哈哈,换了个dark主题', '主题更换为Dark\n\n', '1349290158897311745', 0, 0, 6, b'0', b'0', 0, '2020-11-30 23:27:00', NULL);
  75. INSERT INTO `bms_post` VALUES ('1333668258587750401', '嘿嘿,测试一下啊', '大家好\n`Hello everyone!`\n\n\n\n', '1349290158897311745', 0, 0, 7, b'0', b'0', 0, '2020-12-01 15:04:26', '2020-12-01 16:49:14');
  76. INSERT INTO `bms_post` VALUES ('1332682473151635458', '我要发财', '2021 冲冲冲!!!\n\n', '1349290158897311745', 0, 0, 94, b'0', b'0', 2, '2020-11-28 21:47:16', '2020-11-30 19:40:22');
  77. INSERT INTO `bms_post` VALUES ('1333695976536748034', '最新版本介绍,同步更新!', '<p align=center>一款基于SpringBoot构建的智慧社区系统</p>\n\n<p align=center>\n<a href=\"https://github.com/1020317774/rhapsody-admin/stargazers\"><img alt=\"GitHub release\" src=\"https://img.shields.io/github/release/1020317774/rhapsody-admin?style=flat-square\"></a>\n<a href=\"https://github.com/1020317774/rhapsody-admin/blob/main/LICENSE\"><img alt=\"GitHub license\" src=\"https://img.shields.io/github/license/1020317774/rhapsody-admin\"></a>\n</p>\n\n### Hi there :wave:\n\n<!--\n**1020317774/1020317774** is a :sparkles: _special_ :sparkles: repository because its `README.md` (this file) appears on your GitHub profile.\n\nHere are some ideas to get you started:\n\n- :telescope: I’m currently working on ...\n- :seedling: I’m currently learning ...\n- :dancers: I’m looking to collaborate on ...\n- :thinking: I’m looking for help with ...\n- :speech_balloon: Ask me about ...\n- :mailbox: How to reach me: ...\n- :smile: Pronouns: ...\n- :zap: Fun fact: ...\n-->\n\n[![1020317774\'s github stats](https://github-readme-stats.vercel.app/api?username=1020317774&show_icons=true&count_private=true)](https://github.com/1020317774)\n\n[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=1020317774&layout=compact)](https://github.com/1020317774)\n---------\n\n> 作者:王一晨\n> github:[https://github.com/1020317774](https://github.com/1020317774)\n\n## 技术栈\n\n- [x] SpringBoot 2.X\n- [x] Mysql 8.X\n- [x] Mybatis\n- [x] MybatisPlus\n- [x] Redis\n- [x] Jwt\n- [x] FastJson\n- [x] Hutool\n- [x] Lombok\n- [ ] ElasticSearch\n\n……\n\n## 安装指导\n\n- 克隆\n\n```java\ngit clone https://github.com/1020317774/rhapsody-admin.git\n```\n\n- 修改`application.properties`选择环境\n- 修改多环境配置中的redis参数和数据库\n- 启动`BootApplication`\n- 访问[`http://127.0.0.1:10000`](http://127.0.0.1:10000)\n\n', '1349290158897311745', 0, 0, 45, b'1', b'1', 0, '2020-12-01 16:54:34', '2020-12-01 17:05:00');
  78. INSERT INTO `bms_post` VALUES ('1349631541260595202', '权限部分 OK', '1. 创建 ok\n2. 修改 ok\n3. 删除 ok\n\n', '1349290158897311745', 0, 0, 17, b'0', b'0', 0, '2021-01-14 16:16:49', '2021-01-14 16:18:53');
  79. INSERT INTO `bms_post` VALUES ('1333676096156528641', '测试', '测试\n\n', '1349290158897311745', 0, 0, 38, b'0', b'0', 0, '2020-12-01 15:35:34', NULL);
  80. INSERT INTO `bms_post` VALUES ('1332681213400817665', '聚合查询并统计', '* [x] SQL:\n\n```sql\nSELECT s.*,\nCOUNT(t.id) AS topics\nFROM section s\nLEFT JOIN topic t\nON s.id = t.section_id\nGROUP BY s.title\n```\n\n', '1349290158897311745', 0, 0, 55, b'0', b'0', 1, '2020-11-28 21:42:16', '2020-11-29 15:00:42');
  81. INSERT INTO `bms_post` VALUES ('1335149981733449729', '视频嵌入', ':+1:\n\n[https://www.bilibili.com/video/BV1w64y1f7w3](https://www.bilibili.com/video/BV1w64y1f7w3)\n\n[1](https://www.bilibili.com/video/BV1tp4y1x72w)\n\n```\n.vditor-reset pre > code\n```\n\n```\npublic class HelloWorld {\n\npublic static void main(String[] args) {\n System.out.println(\"Hello World!\");\n}\n}\n```\n\n', '1349290158897311745', 0, 0, 41, b'0', b'0', 0, '2020-12-05 17:12:16', '2021-01-14 13:06:16');
  82. -- ----------------------------
  83. -- Table structure for bms_comment
  84. -- ----------------------------
  85. DROP TABLE IF EXISTS `bms_comment`;
  86. CREATE TABLE `bms_comment` (
  87. `id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  88. `content` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '内容',
  89. `user_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '作者ID',
  90. `topic_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'topic_id',
  91. `create_time` datetime NOT NULL COMMENT '发布时间',
  92. `modify_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  93. PRIMARY KEY (`id`) USING BTREE
  94. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '评论表' ROW_FORMAT = DYNAMIC;
  95. -- ----------------------------
  96. -- Table structure for bms_tag
  97. -- ----------------------------
  98. DROP TABLE IF EXISTS `bms_tag`;
  99. CREATE TABLE `bms_tag` (
  100. `id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签ID',
  101. `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标签',
  102. `topic_count` int NOT NULL DEFAULT 0 COMMENT '关联话题',
  103. PRIMARY KEY (`id`) USING BTREE,
  104. UNIQUE INDEX `name`(`name`) USING BTREE
  105. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '标签表' ROW_FORMAT = DYNAMIC;
  106. -- ----------------------------
  107. -- Records of bms_tag
  108. -- ----------------------------
  109. INSERT INTO `bms_tag` VALUES ('1332650453377708034', 'java', 1);
  110. INSERT INTO `bms_tag` VALUES ('1332681213568589825', 'css', 1);
  111. INSERT INTO `bms_tag` VALUES ('1332681213631504385', 'mongodb', 1);
  112. INSERT INTO `bms_tag` VALUES ('1332682473218744321', 'python', 1);
  113. INSERT INTO `bms_tag` VALUES ('1332913064463794178', 'vue', 2);
  114. INSERT INTO `bms_tag` VALUES ('1332913064530903041', 'react', 1);
  115. INSERT INTO `bms_tag` VALUES ('1333432347107143681', 'node', 1);
  116. INSERT INTO `bms_tag` VALUES ('1333432347107143682', 'mysql', 1);
  117. INSERT INTO `bms_tag` VALUES ('1333447953697177602', 'flask', 2);
  118. INSERT INTO `bms_tag` VALUES ('1333676096320106498', 'spring', 1);
  119. INSERT INTO `bms_tag` VALUES ('1333695976742268930', 'django', 1);
  120. INSERT INTO `bms_tag` VALUES ('1334481725519429634', 'security', 1);
  121. INSERT INTO `bms_tag` VALUES ('1349362401597775874', 'tensorflow', 1);
  122. INSERT INTO `bms_tag` VALUES ('1349631541306732545', 'pytorch', 1);
  123. -- ----------------------------
  124. -- Table structure for bms_post_tag
  125. -- ----------------------------
  126. DROP TABLE IF EXISTS `bms_post_tag`;
  127. CREATE TABLE `bms_post_tag` (
  128. `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  129. `tag_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签ID',
  130. `topic_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '话题ID',
  131. PRIMARY KEY (`id`) USING BTREE,
  132. INDEX `tag_id`(`tag_id`) USING BTREE,
  133. INDEX `topic_id`(`topic_id`) USING BTREE
  134. ) ENGINE = InnoDB AUTO_INCREMENT = 52 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '话题-标签 中间表' ROW_FORMAT = DYNAMIC;
  135. -- ----------------------------
  136. -- Records of bms_post_tag
  137. -- ----------------------------
  138. INSERT INTO `bms_post_tag` VALUES (36, '1332650453377708034', '1332650453142827009');
  139. INSERT INTO `bms_post_tag` VALUES (37, '1332681213568589825', '1332681213400817665');
  140. INSERT INTO `bms_post_tag` VALUES (38, '1332681213631504385', '1332681213400817665');
  141. INSERT INTO `bms_post_tag` VALUES (39, '1332682473218744321', '1332682473151635458');
  142. INSERT INTO `bms_post_tag` VALUES (40, '1332913064463794178', '1332913064396685314');
  143. INSERT INTO `bms_post_tag` VALUES (41, '1332913064530903041', '1332913064396685314');
  144. INSERT INTO `bms_post_tag` VALUES (42, '1333432347107143681', '1333432347031646209');
  145. INSERT INTO `bms_post_tag` VALUES (43, '1333432347107143682', '1333432347031646209');
  146. INSERT INTO `bms_post_tag` VALUES (44, '1333447953697177602', '1333447953558765569');
  147. INSERT INTO `bms_post_tag` VALUES (45, '1332913064463794178', '1333668258587750401');
  148. INSERT INTO `bms_post_tag` VALUES (46, '1333676096320106498', '1333676096156528641');
  149. INSERT INTO `bms_post_tag` VALUES (47, '1333695976742268930', '1333695976536748034');
  150. INSERT INTO `bms_post_tag` VALUES (48, '1334481725519429634', '1334481725322297346');
  151. INSERT INTO `bms_post_tag` VALUES (49, '1333447953697177602', '1335149981733449729');
  152. INSERT INTO `bms_post_tag` VALUES (50, '1349362401597775874', '1349362401438392322');
  153. INSERT INTO `bms_post_tag` VALUES (51, '1349631541306732545', '1349631541260595202');
  154. -- ----------------------------
  155. -- Table structure for bms_promotion
  156. -- ----------------------------
  157. DROP TABLE IF EXISTS `bms_promotion`;
  158. CREATE TABLE `bms_promotion` (
  159. `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  160. `title` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '广告标题',
  161. `link` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '广告链接',
  162. `description` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '说明',
  163. PRIMARY KEY (`id`) USING BTREE
  164. ) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COMMENT = '广告推广表' ROW_FORMAT = DYNAMIC;
  165. -- ----------------------------
  166. -- Records of bms_promotion
  167. -- ----------------------------
  168. INSERT INTO `bms_promotion` VALUES (1, '开发者头条', 'https://juejin.cn/', '开发者头条');
  169. INSERT INTO `bms_promotion` VALUES (2, '并发编程网', 'https://juejin.cn/', '并发编程网');
  170. INSERT INTO `bms_promotion` VALUES (3, '掘金', 'https://juejin.cn/', '掘金');
  171. -- ----------------------------
  172. -- Table structure for bms_tip
  173. -- ----------------------------
  174. DROP TABLE IF EXISTS `bms_tip`;
  175. CREATE TABLE `bms_tip` (
  176. `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  177. `content` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '内容',
  178. `author` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '作者',
  179. `type` tinyint NOT NULL COMMENT '1:使用,0:过期',
  180. PRIMARY KEY (`id`) USING BTREE
  181. ) ENGINE = InnoDB AUTO_INCREMENT = 24864 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '每日赠言' ROW_FORMAT = DYNAMIC;
  182. -- ----------------------------
  183. -- Records of bms_tip
  184. -- ----------------------------
  185. INSERT INTO `bms_tip` VALUES (1, '多锉出快锯,多做长知识。', '佚名', 1);
  186. INSERT INTO `bms_tip` VALUES (2, '未来总留着什么给对它抱有信心的人。', '佚名', 1);
  187. INSERT INTO `bms_tip` VALUES (3, '一个人的智慧不够用,两个人的智慧用不完。', '谚语', 1);
  188. INSERT INTO `bms_tip` VALUES (4, '十个指头按不住十个跳蚤', '傣族', 1);
  189. INSERT INTO `bms_tip` VALUES (5, '言不信者,行不果。', '墨子', 1);
  190. INSERT INTO `bms_tip` VALUES (6, '攀援而登,箕踞而遨,则几数州之土壤,皆在衽席之下。', '柳宗元', 1);
  191. INSERT INTO `bms_tip` VALUES (7, '美德大都包含在良好的习惯之内。', '帕利克', 1);
  192. INSERT INTO `bms_tip` VALUES (8, '人有不及,可以情恕。', '《晋书》', 1);
  193. INSERT INTO `bms_tip` VALUES (9, '明·吴惟顺', '法不传六耳', 1);
  194. INSERT INTO `bms_tip` VALUES (10, '真正的朋友应该说真话,不管那话多么尖锐。', '奥斯特洛夫斯基', 1);
  195. INSERT INTO `bms_tip` VALUES (11, '时间是一切财富中最宝贵的财富。', '德奥弗拉斯多', 1);
  196. INSERT INTO `bms_tip` VALUES (12, '看人下菜碟', '民谚', 1);
  197. INSERT INTO `bms_tip` VALUES (13, '如果不是怕别人反感,女人决不会保持完整的严肃。', '拉罗什福科', 1);
  198. INSERT INTO `bms_tip` VALUES (14, '爱是春暖花开时对你满满的笑意', '佚名', 1);
  199. INSERT INTO `bms_tip` VALUES (15, '希望是坚韧的拐杖,忍耐是旅行袋,携带它们,人可以登上永恒之旅。', '罗素', 1);
  200. INSERT INTO `bms_tip` VALUES (18, '天国般的幸福,存在于对真爱的希望。', '佚名', 1);
  201. INSERT INTO `bms_tip` VALUES (19, '我们现在必须完全保持党的纪律,否则一切都会陷入污泥中。', '马克思', 1);
  202. INSERT INTO `bms_tip` VALUES (20, '在科学上没有平坦的大道,只有不畏劳苦沿着陡峭山路攀登的人,才有希望达到光辉的顶点。', '马克思', 1);
  203. INSERT INTO `bms_tip` VALUES (21, '懒惰的马嫌路远', '蒙古', 1);
  204. INSERT INTO `bms_tip` VALUES (22, '别忘记热水是由冷水烧成的', '非洲', 1);
  205. -- ----------------------------
  206. -- Table structure for ums_user
  207. -- ----------------------------
  208. DROP TABLE IF EXISTS `ums_user`;
  209. CREATE TABLE `ums_user` (
  210. `id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户ID',
  211. `username` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '用户名',
  212. `alias` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户昵称',
  213. `password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '密码',
  214. `avatar` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像',
  215. `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  216. `mobile` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手机',
  217. `score` int NOT NULL DEFAULT 0 COMMENT '积分',
  218. `token` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT 'token',
  219. `bio` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '个人简介',
  220. `active` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否激活,1:是,0:否',
  221. `status` bit(1) NULL DEFAULT b'1' COMMENT '状态,1:使用,0:停用',
  222. `role_id` int NULL DEFAULT NULL COMMENT '用户角色',
  223. `create_time` datetime NOT NULL COMMENT '加入时间',
  224. `modify_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  225. PRIMARY KEY (`id`) USING BTREE,
  226. UNIQUE INDEX `user_name`(`username`) USING BTREE,
  227. INDEX `user_email`(`email`) USING BTREE,
  228. INDEX `user_create_time`(`create_time`) USING BTREE
  229. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户表' ROW_FORMAT = DYNAMIC;
  230. -- ----------------------------
  231. -- Records of ums_user
  232. -- ----------------------------
  233. INSERT INTO `ums_user` VALUES ('1349290158897311745', 'admin', 'admin', '$2a$10$8qx711TBg/2hxfL7N.sxf.0ROMhR/iuPhQx33IFqGd7PLgt5nGJTO', 'https://s3.ax1x.com/2020/12/01/DfHNo4.jpg', '23456@qq.com', NULL, 2, '', '自由职业者', b'1', b'1', NULL, '2021-01-13 17:40:17', NULL);
  234. INSERT INTO `ums_user` VALUES ('1349618748226658305', 'zhangsan', 'zhangsan', '$2a$10$7K3yYv8sMV5Xsc2facXTcuyDo8JQ4FJHvjZ7qtWYcJdei3Q6Fvqdm', 'https://s3.ax1x.com/2020/12/01/DfHNo4.jpg', '23456@qq.com', NULL, 0, '', '自由职业者', b'1', b'1', NULL, '2021-01-14 15:25:59', NULL);
  235. SET FOREIGN_KEY_CHECKS = 1;

创建maven工程

1.pom依赖

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>2.3.8.RELEASE</version>
  5. <relativePath/> <!-- lookup parent from repository -->
  6. </parent>
  1. <properties>
  2. <maven.compiler.source>8</maven.compiler.source>
  3. <maven.compiler.target>8</maven.compiler.target>
  4. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  5. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  6. <mybatis-plus.version>3.4.2</mybatis-plus.version>
  7. <fastjson.version>1.2.75</fastjson.version>
  8. <hutool.version>5.5.7</hutool.version>
  9. <jwt.version>0.9.1</jwt.version>
  10. <emoji-java.version>5.1.1</emoji-java.version>
  11. </properties>
  12. <dependencies>
  13. <dependency>
  14. <groupId>org.springframework.boot</groupId>
  15. <artifactId>spring-boot-starter</artifactId>
  16. </dependency>
  17. <!--web-->
  18. <dependency>
  19. <groupId>org.springframework.boot</groupId>
  20. <artifactId>spring-boot-starter-web</artifactId>
  21. </dependency>
  22. <!--lombok-->
  23. <dependency>
  24. <groupId>org.projectlombok</groupId>
  25. <artifactId>lombok</artifactId>
  26. <optional>true</optional>
  27. </dependency>
  28. <!--jjwt-->
  29. <dependency>
  30. <groupId>io.jsonwebtoken</groupId>
  31. <artifactId>jjwt</artifactId>
  32. <version>${jwt.version}</version>
  33. </dependency>
  34. <!--emoji-java 表情包-->
  35. <dependency>
  36. <groupId>com.vdurmont</groupId>
  37. <artifactId>emoji-java</artifactId>
  38. <version>${emoji-java.version}</version>
  39. </dependency>
  40. <!-- lettuce pool 缓存连接池-->
  41. <dependency>
  42. <groupId>org.apache.commons</groupId>
  43. <artifactId>commons-pool2</artifactId>
  44. </dependency>
  45. <!--HuTool-->
  46. <dependency>
  47. <groupId>cn.hutool</groupId>
  48. <artifactId>hutool-all</artifactId>
  49. <version>${hutool.version}</version>
  50. </dependency>
  51. <!--mysql-->
  52. <dependency>
  53. <groupId>mysql</groupId>
  54. <artifactId>mysql-connector-java</artifactId>
  55. <scope>runtime</scope>
  56. </dependency>
  57. <!--mybatis-plus-->
  58. <dependency>
  59. <groupId>com.baomidou</groupId>
  60. <artifactId>mybatis-plus-boot-starter</artifactId>
  61. <version>${mybatis-plus.version}</version>
  62. </dependency>
  63. <!--fastjson-->
  64. <dependency>
  65. <groupId>com.alibaba</groupId>
  66. <artifactId>fastjson</artifactId>
  67. <version>${fastjson.version}</version>
  68. </dependency>
  69. <!--yaml-->
  70. <dependency>
  71. <groupId>org.springframework.boot</groupId>
  72. <artifactId>spring-boot-configuration-processor</artifactId>
  73. <optional>true</optional>
  74. </dependency>
  75. <!--bean validator-->
  76. <dependency>
  77. <groupId>org.hibernate.validator</groupId>
  78. <artifactId>hibernate-validator</artifactId>
  79. </dependency>
  80. <dependency>
  81. <groupId>org.springframework.boot</groupId>
  82. <artifactId>spring-boot-starter-test</artifactId>
  83. <scope>test</scope>
  84. <exclusions>
  85. <exclusion>
  86. <groupId>org.junit.vintage</groupId>
  87. <artifactId>junit-vintage-engine</artifactId>
  88. </exclusion>
  89. </exclusions>
  90. </dependency>
  91. </dependencies>

2.yam配置

  1. # 端口号
  2. server:
  3. port: 8081
  4. # 数据库
  5. spring:
  6. datasource:
  7. driver-class-name: com.mysql.cj.jdbc.Driver
  8. username: root
  9. password: root
  10. url: jdbc:mysql://127.0.0.1:3306/nodepad_mblog?useUnicode=true&characterEncoding=utf8&autoReconnect=true&serverTimezone=GMT%2B8
  11. type: com.zaxxer.hikari.HikariDataSource
  12. # sql日志打印
  13. mybatis-plus:
  14. configuration:
  15. log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

3.启动类

  1. // 我们这里还没有配置数据库,exclude = {DataSourceAutoConfiguration.class就是启动时不加载数据库
  2. // @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
  3. @Slf4j
  4. @SpringBootApplication
  5. public class BlogApplication {
  6. public static void main(String[] args) {
  7. ConfigurableApplicationContext context = SpringApplication.run(BlogApplication.class, args);
  8. String port = context.getEnvironment().getProperty("server.port");
  9. log.info("http://localhost:"+port);
  10. }
  11. }

启动项目测试有没有报错

4.项目返回和错误处理

4.1api数据返回

IErrorCode
  1. public interface IErrorCode {
  2. /**
  3. * 错误编码: -1失败;200成功
  4. *
  5. * @return 错误编码
  6. */
  7. Integer getCode();
  8. /**
  9. * 错误描述
  10. *
  11. * @return 错误描述
  12. */
  13. String getMessage();
  14. }
ApiErrorCode
  1. public enum ApiErrorCode implements IErrorCode {
  2. /**
  3. * 成功
  4. */
  5. SUCCESS(200, "操作成功"),
  6. /**
  7. * 失败
  8. */
  9. FAILED(-1, "操作失败"),
  10. /**
  11. * 未登录,Token过期
  12. */
  13. UNAUTHORIZED(401, "暂未登录或token已经过期"),
  14. /**
  15. * 权限不足
  16. */
  17. FORBIDDEN(403, "权限不足"),
  18. /**
  19. * 参数校验错误
  20. */
  21. VALIDATE_FAILED(404, "参数检验失败");
  22. private final Integer code;
  23. private final String message;
  24. ApiErrorCode(int code, String message) {
  25. this.code = code;
  26. this.message = message;
  27. }
  28. @Override
  29. public Integer getCode() {
  30. return code;
  31. }
  32. @Override
  33. public String getMessage() {
  34. return message;
  35. }
  36. @Override
  37. public String toString() {
  38. return "ApiErrorCode{" +
  39. "code=" + code +
  40. ", message='" +message + '\'' +
  41. '}';
  42. }
  43. }
ApiResult
  1. import lombok.Data;
  2. import lombok.NoArgsConstructor;
  3. import java.io.Serializable;
  4. import java.util.Optional;
  5. @Data
  6. @NoArgsConstructor
  7. public class ApiResult<T> implements Serializable {
  8. private static final long serialVersionUID = -4153430394359594346L;
  9. /**
  10. * 业务状态码
  11. */
  12. private long code;
  13. /**
  14. * 结果集
  15. */
  16. private T data;
  17. /**
  18. * 接口描述
  19. */
  20. private String message;
  21. /**
  22. * 全参
  23. *
  24. * @param code 业务状态码
  25. * @param message 描述
  26. * @param data 结果集
  27. */
  28. public ApiResult(long code, String message, T data) {
  29. this.code = code;
  30. this.message = message;
  31. this.data = data;
  32. }
  33. public ApiResult(IErrorCode errorCode) {
  34. errorCode = Optional.ofNullable(errorCode).orElse(ApiErrorCode.FAILED);
  35. this.code = errorCode.getCode();
  36. this.message = errorCode.getMessage();
  37. }
  38. /**
  39. * 成功
  40. *
  41. * @param data 结果集
  42. * @return {code:200,message:操作成功,data:自定义}
  43. */
  44. public static <T> ApiResult<T> success() {
  45. return new ApiResult<T>(ApiErrorCode.SUCCESS.getCode(), ApiErrorCode.SUCCESS.getMessage(), null);
  46. }
  47. /**
  48. * 成功
  49. *
  50. * @param data 结果集
  51. * @return {code:200,message:操作成功,data:自定义}
  52. */
  53. public static <T> ApiResult<T> success(T data) {
  54. return new ApiResult<T>(ApiErrorCode.SUCCESS.getCode(), ApiErrorCode.SUCCESS.getMessage(), data);
  55. }
  56. /**
  57. * 成功
  58. *
  59. * @param data 结果集
  60. * @param message 自定义提示信息
  61. * @return {code:200,message:自定义,data:自定义}
  62. */
  63. public static <T> ApiResult<T> success(T data, String message) {
  64. return new ApiResult<T>(ApiErrorCode.SUCCESS.getCode(), message, data);
  65. }
  66. /**
  67. * 失败返回结果
  68. */
  69. public static <T> ApiResult<T> failed() {
  70. return failed(ApiErrorCode.FAILED);
  71. }
  72. /**
  73. * 失败返回结果
  74. *
  75. * @param message 提示信息
  76. * @return {code:枚举ApiErrorCode取,message:自定义,data:null}
  77. */
  78. public static <T> ApiResult<T> failed(String message) {
  79. return new ApiResult<T>(ApiErrorCode.FAILED.getCode(), message, null);
  80. }
  81. /**
  82. * 失败
  83. *
  84. * @param errorCode 错误码
  85. * @return {code:封装接口取,message:封装接口取,data:null}
  86. */
  87. public static <T> ApiResult<T> failed(IErrorCode errorCode) {
  88. return new ApiResult<T>(errorCode.getCode(), errorCode.getMessage(), null);
  89. }
  90. /**
  91. * 失败返回结果
  92. *
  93. * @param errorCode 错误码
  94. * @param message 错误信息
  95. * @return {code:枚举ApiErrorCode取,message:自定义,data:null}
  96. */
  97. public static <T> ApiResult<T> failed(IErrorCode errorCode, String message) {
  98. return new ApiResult<T>(errorCode.getCode(), message, null);
  99. }
  100. /**
  101. * 参数验证失败返回结果
  102. */
  103. public static <T> ApiResult<T> validateFailed() {
  104. return failed(ApiErrorCode.VALIDATE_FAILED);
  105. }
  106. /**
  107. * 参数验证失败返回结果
  108. *
  109. * @param message 提示信息
  110. */
  111. public static <T> ApiResult<T> validateFailed(String message) {
  112. return new ApiResult<T>(ApiErrorCode.VALIDATE_FAILED.getCode(), message, null);
  113. }
  114. /**
  115. * 未登录返回结果
  116. */
  117. public static <T> ApiResult<T> unauthorized(T data) {
  118. return new ApiResult<T>(ApiErrorCode.UNAUTHORIZED.getCode(), ApiErrorCode.UNAUTHORIZED.getMessage(), data);
  119. }
  120. /**
  121. * 未授权返回结果
  122. */
  123. public static <T> ApiResult<T> forbidden(T data) {
  124. return new ApiResult<T>(ApiErrorCode.FORBIDDEN.getCode(), ApiErrorCode.FORBIDDEN.getMessage(), data);
  125. }
  126. }

4.2全局异常

ApiException
  1. public class ApiException extends RuntimeException {
  2. private IErrorCode errorCode;
  3. public ApiException(IErrorCode errorCode) {
  4. super(errorCode.getMessage());
  5. this.errorCode = errorCode;
  6. }
  7. public ApiException(String message) {
  8. super(message);
  9. }
  10. public IErrorCode getErrorCode() {
  11. return errorCode;
  12. }
  13. }
ApiAsserts
  1. public class ApiAsserts {
  2. /**
  3. * 抛失败异常
  4. *
  5. * @param message 说明
  6. */
  7. public static void fail(String message) {
  8. throw new ApiException(message);
  9. }
  10. /**
  11. * 抛失败异常
  12. *
  13. * @param errorCode 状态码
  14. */
  15. public static void fail(IErrorCode errorCode) {
  16. throw new ApiException(errorCode);
  17. }
  18. }
GlobalExceptionHandler
  1. import org.springframework.web.bind.annotation.ControllerAdvice;
  2. import org.springframework.web.bind.annotation.ExceptionHandler;
  3. import org.springframework.web.bind.annotation.ResponseBody;
  4. import java.util.Map;
  5. @ControllerAdvice
  6. public class GlobalExceptionHandler {
  7. /**
  8. * 捕获自定义异常
  9. */
  10. @ResponseBody
  11. @ExceptionHandler(value = ApiException.class)
  12. public ApiResult<Map<String, Object>> handle(ApiException e) {
  13. if (e.getErrorCode() != null) {
  14. return ApiResult.failed(e.getErrorCode());
  15. }
  16. return ApiResult.failed(e.getMessage());
  17. }
  18. }

SpringBoot+Vue豆宝社区前后端分离项目手把手实战系列教程02---创建后端工程的更多相关文章

  1. SpringBoot+Vue豆宝社区前后端分离项目手把手实战系列教程01---搭建前端工程

    豆宝社区项目实战教程简介 本项目实战教程配有免费视频教程,配套代码完全开源.手把手从零开始搭建一个目前应用最广泛的Springboot+Vue前后端分离多用户社区项目.本项目难度适中,为便于大家学习, ...

  2. 《Spring Boot 入门及前后端分离项目实践》系列介绍

    课程计划 课程地址点这里 本课程是一个 Spring Boot 技术栈的实战类课程,课程共分为 3 个部分,前面两个部分为基础环境准备和相关概念介绍,第三个部分是 Spring Boot 项目实践开发 ...

  3. docker-compose 部署 Vue+SpringBoot 前后端分离项目

    一.前言 本文将通过docker-compose来部署前端Vue项目到Nginx中,和运行后端SpringBoot项目 服务器基本环境: CentOS7.3 Dokcer MySQL 二.docker ...

  4. Springboot+vue前后端分离项目,poi导出excel提供用户下载的解决方案

    因为我们做的是前后端分离项目 无法采用response.write直接将文件流写出 我们采用阿里云oss 进行保存 再返回的结果对象里面保存我们的文件地址 废话不多说,上代码 Springboot 第 ...

  5. List多个字段标识过滤 IIS发布.net core mvc web站点 ASP.NET Core 实战:构建带有版本控制的 API 接口 ASP.NET Core 实战:使用 ASP.NET Core Web API 和 Vue.js 搭建前后端分离项目 Using AutoFac

    List多个字段标识过滤 class Program{  public static void Main(string[] args) { List<T> list = new List& ...

  6. Yii框架和Vue的完美结合完成前后端分离项目

    背景说明 本文假设你对Yii和Vue都比较熟悉,至少都在项目里用过,另外笔者新人,以后不定时放一些干货,欢迎程序媛关注 Yii是一个PHP全端框架,典型的mvc的项目结构,后端接口都是一个控制器里放了 ...

  7. 喜大普奔,两个开源的 Spring Boot + Vue 前后端分离项目可以在线体验了

    折腾了一周的域名备案昨天终于搞定了. 松哥第一时间想到赶紧把微人事和 V 部落部署上去,我知道很多小伙伴已经等不及了. 1. 也曾经上过线 其实这两个项目当时刚做好的时候,我就把它们部署到服务器上了, ...

  8. 基于Vue的前后端分离项目实践

    一.为什么需要前后端分离 1.1什么是前后端分离  前后端分离这个词刚在毕业(15年)那会就听说过,但是直到17年前都没有接触过前后端分离的项目.怎么理解前后端分离?直观的感觉就是前后端分开去做,即功 ...

  9. 两个开源的 Spring Boot + Vue 前后端分离项目

    折腾了一周的域名备案昨天终于搞定了. 松哥第一时间想到赶紧把微人事和 V 部落部署上去,我知道很多小伙伴已经等不及了. 1. 也曾经上过线 其实这两个项目当时刚做好的时候,我就把它们部署到服务器上了, ...

随机推荐

  1. Hbase 表的设计原则 ————总结

    1.列族的数量及列族的势 建议将HBase列族的数量设置的越少越好.当强,对于两个或两个以上的列族HBase并不能处理的很好.这是由于HBase的Flushing和压缩是基于Region的.当一个列族 ...

  2. Flink-v1.12官方网站翻译-P017-Execution Mode (Batch/Streaming)

    执行模式(批处理/流处理) DataStream API 支持不同的运行时执行模式,您可以根据用例的要求和作业的特点从中选择.DataStream API 有一种 "经典 "的执行 ...

  3. 使用xshell连不上ubuntu14.04

    判断Ubuntu是否安装了ssh服务: 输入:#ps -e | grep ssh 如果服务已经启动,则可以看到"sshd",否则表示没有安装服务,或没有开机启动,如果不是下图情况, ...

  4. Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)

    题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...

  5. HDOJ 1242

    纠结1242很久了,查了题解才发现要优先队列才能成功 http://blog.chinaunix.net/uid-21712186-id-1818266.html 使人开窍之文章 优先队列,已经不算是 ...

  6. fzu2218 Simple String Problem

    Accept: 2    Submit: 16 Time Limit: 2000 mSec    Memory Limit : 32768 KB  Problem Description Recent ...

  7. log查看工具log2console

    log查看工具log2console介绍:https://www.cnblogs.com/TianFang/archive/2013/03/27/2985296.html Log2Console日志监 ...

  8. ThreadLocal使用全解

    一.何为ThreadLocal 1.ThreadLocal的含义 ThreadLocal,即线程变量,是一个以ThreadLocal对象为键,任意对象为值的存储结构.这个结构被附带在线程上,也就是说一 ...

  9. 网络协议 & 协议体系结构模型

    基本知识概述 网络协议是什么? 为进行网络中的数据交换,而建立的规则(约定),就称为网络协议 网络协议的三个组成要素? 语法:数据与控制信息的结构或格式 语义:发出何种控制信息,完成何种动作,作出何种 ...

  10. Ubuntu 下更改pip源使用清华源

    一.新建目录 sudo -s mkdisk ~./pip vim ~./pip/pip.conf 二.复制下面代码,并保存 [global] index-url = https://pypi.tuna ...