当前位置:网站首页>Handwriting a blogging platform ~ Day 3
Handwriting a blogging platform ~ Day 3
2022-08-02 01:57:00 【hiccup kid paper】
留给读者
In the first two days, the basic design of the environment construction and project architecture has been solved,There is also a method of persistence layer for everyone,Today, I will tell you what data a blog platform should need,What is the relationship between the data,and complete the first functional module.
Of course, I also promised to show you the effect of the blog yesterday.,In fact, if you are careful, you have already seen the blog.,blog ongithub主页上,You can go to the bottom and click on the technical column to jump,Look at my personal blog.
Here is an example of an article:
The Backtracking Method of the Forced Deduction Algorithm
如果github进不去,easy to downloadsteam++,Of course it's not that kind of wall-climbing software,Mainly for learning,你懂得,Many foreign websites are still inaccessible,但githubeasy access,Of course there are many other functions,有兴趣可以了解一下.
给出链接:https://steampp.net/
Chicken soup is over,废话不多说,干代码!
简单来说,A blogging platform is a project where you can publish articles and freely comment,要做到这一点,must have the following data.
- 文章存储
- Article classification storage
- 标签存储
- 评论存储
- 用户存储
Article and comment storage involves non-relational data,Of course you also can still as relational to deal with it,But only as a persistence layer object for reverse engineering,后面会详讲.
不管怎么样,Persistence layer(mapper和pojo)finish first!
- 用户和用户详情
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`permission` int NOT NULL DEFAULT 2,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for user_info
-- ----------------------------
DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`sex` int NULL DEFAULT NULL,
`avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`nickname` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tel` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`email` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `user_id`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
- 标签和分类
-- ----------------------------
-- Table structure for tag
-- ----------------------------
DROP TABLE IF EXISTS `tag`;
CREATE TABLE `tag` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for classfication
-- ----------------------------
DROP TABLE IF EXISTS `classfication`;
CREATE TABLE `classfication` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
- Articles and Tags
-- ----------------------------
-- Table structure for article
-- ----------------------------
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` datetime NOT NULL,
`update_time` datetime NULL DEFAULT NULL,
`summary` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`content` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`class_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`comment_counts` int NULL DEFAULT NULL,
`read_counts` int NULL DEFAULT NULL,
`receive_like_counts` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for articles2tags
-- ----------------------------
DROP TABLE IF EXISTS `articles2tags`;
CREATE TABLE `articles2tags` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`tag_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
- Users and Articles
Here is an expanded collection of articles,没有去实现,有兴趣可以去试试
-- ----------------------------
-- Table structure for user_like_articles
-- ----------------------------
DROP TABLE IF EXISTS `user_like_articles`;
CREATE TABLE `user_like_articles` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
- Users and Comments
-- ----------------------------
-- Table structure for commnet
-- ----------------------------
DROP TABLE IF EXISTS `commnet`;
CREATE TABLE `commnet` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`father_comment_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`to_user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`from_user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`comment` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` datetime NOT NULL,
`status` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
Readers have doubts,Why do you say that articles and comments are non-relational?,Then why do you still build these two tables into relational ones?MySQL中呢?
问得好,Because we use lazy development,Reverse engineering is based on the relational,You need to build a table first to reverse the generation of objects andmapper,Instead of manually write himself!
打开你的generatorConfig.xml
So simple to write you a few table name,Note CamelCase,user_info在JavaThe resulting object is nameduserInfo
<table tableName="user"></table>
<table tableName="article"></table>
<table tableName="articles2tags"></table>
<table tableName="classfication"></table>
<table tableName="commment"></table>
<table tableName="tag"></table>
<table tableName="user_info"></table>
It's probably like this when it's done:

- Complete a function module for login and registration
Before completing, you need to save the user login information toRedis中作为缓存,The next login directly accesses the cache without going throughMySQL数据库,减轻对MySQL的负担,You may wish to download firstRedis,go to simple use,Continue to do it next weekend!
下载链接:https://redis.io/download/#redis-downloads
I like to useLinux版本的,You may wish to use a virtual machine to try!
边栏推荐
- 【服务器数据恢复】服务器Raid5阵列mdisk磁盘离线的数据恢复案例
- typescript35-class的构造函数
- Rust P2P Network Application Combat-1 P2P Network Core Concepts and Ping Program
- The ultra-large-scale industrial practical semantic segmentation dataset PSSL and pre-training model are open source!
- Some insights from 5 years of automated testing experience: UI automation must overcome these 10 pits
- Redis 底层的数据结构
- Reflex WMS中阶系列7:已经完成拣货尚未Load的HD如果要取消拣货,该如何处理?
- 【ORB_SLAM2】SetPose、UpdatePoseMatrices
- YGG 公会发展计划第 1 季总结
- MySQL optimization strategy
猜你喜欢

The characteristics and principle of typescript29 - enumeration type

Day115.尚医通:后台用户管理:用户锁定解锁、详情、认证列表审批

Image fusion based on weighted 】 and pyramid image fusion with matlab code

『网易实习』周记(一)

S/4中究竟有多少个模块,你对这些模块了解多少

Chengdu openGauss user group recruit!

"NetEase Internship" Weekly Diary (2)

Fly propeller power space future PIE - Engine Engine build earth science

Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation

记录一次数组转集合出现错误的坑点,尽量使用包装类型数组进行转换
随机推荐
3个月测试员自述:4个影响我职业生涯的重要技能
Entry name ‘org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt’ collided
Constructor instance method inheritance of typescript37-class (extends)
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
Ask God to answer, how should this kind of sql be written?
秒懂大模型 | 3步搞定AI写摘要
volatile原理解析
Redis 持久化 - RDB 与 AOF
A full set of common interview questions for software testing functional testing [open thinking questions] interview summary 4-3
Hash collisions and consistent hashing
Anti-oversold and high concurrent deduction scheme for e-commerce inventory system
Force buckle, 752-open turntable lock
Huawei's 5-year female test engineer resigns: what a painful realization...
手写一个博客平台~第一天
大话西游无法登陆解决
6-25 Vulnerability Exploitation - irc Backdoor Exploitation
Chengdu openGauss user group recruit!
typeof in typescript32-ts
Analysis of volatile principle