当前位置:网站首页>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!
边栏推荐
猜你喜欢

LeetCode Brushing Diary: 74. Searching 2D Matrix

hash table

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

Analysis of volatile principle

The ultra-large-scale industrial practical semantic segmentation dataset PSSL and pre-training model are open source!

Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021:解读
软件测试功能测试全套常见面试题【开放性思维题】面试总结4-3

2023年起,这些地区软考成绩低于45分也能拿证

Record the pits where an error occurs when an array is converted to a collection, and try to use an array of packaging types for conversion

Navicat数据显示不完全的解决方法
随机推荐
LeetCode刷题日记:74. 搜索二维矩阵
雇用WordPress开发人员:4个实用的方法
Some insights from 5 years of automated testing experience: UI automation must overcome these 10 pits
牛顿定理和相关推论
Anti-oversold and high concurrent deduction scheme for e-commerce inventory system
libcurl访问url保存为文件的简单示例
AntPathMatcher使用
bool Frame::PosInGrid(const cv::KeyPoint &kp, int &posX, int &posY)
浅谈国产ERP的“横纵竖”三向发展态势
Typescript31 - any type
Handwriting a blogging platform ~ the first day
【刷题篇】打家劫舍
typescript30 - any type
typescript30-any类型
CodeTon Round 2 D. Magical Array 规律
typescript29-枚举类型的特点和原理
安全(1)
2023年起,这些地区软考成绩低于45分也能拿证
当关注「互联网+」模式的时候,通常仅仅只是在关注「互联网+」模式本身
3. Bean scope and life cycle