当前位置:网站首页>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,但github
easy 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
在Java
The 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!
边栏推荐
猜你喜欢
手写一个博客平台~第三天
Reflex WMS中阶系列6:对一个装货重复run pick会有什么后果?
Local storage in Kubernetes
typescript37-class的构造函数实例方法继承(extends)
安全(2)
大话西游创建角色失败解决
typescript30 - any type
飞桨助力航天宏图PIE-Engine地球科学引擎构建
软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言
Constructor instance method inheritance of typescript38-class (implement)
随机推荐
typescript32-ts中的typeof
Day116. Shangyitong: Details of appointment registration ※
typescript30-any类型
Constructor of typescript35-class
制造企业数字化转型现状分析
The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
¶Backtop 回到顶部 不生效
Data transfer at the data link layer
《自然语言处理实战入门》 基于知识图谱的问答机器人
swift项目,sqlcipher3 -&gt; 4,无法打开旧版数据库有办法解决吗
A full set of common interview questions for software testing functional testing [open thinking questions] interview summary 4-3
LeetCode brushing diary: 53, the largest sub-array and
雇用WordPress开发人员:4个实用的方法
Understand the big model in seconds | 3 steps to get AI to write a summary
哈希冲突和一致性哈希
MySQL optimization strategy
Pcie the inbound and outbound
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
软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言
YGG 公会发展计划第 1 季总结