当前位置:网站首页>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!
边栏推荐
- HSDC is related to Independent Spanning Tree
- 乱七八糟的网站
- oracle查询扫描全表和走索引
- 雇用WordPress开发人员:4个实用的方法
- typescript33 - high-level overview of typescript
- The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
- Image fusion based on weighted 】 and pyramid image fusion with matlab code
- 第一次写对牛客的编程面试题:输入一个字符串,返回该字符串出现最多的字母
- JDBC PreparedStatement 的命名参数实现
- typescript36-class的构造函数实例方法
猜你喜欢
Typescript31 - any type
Constructor instance method of typescript36-class
kubernetes之服务发现
A full set of common interview questions for software testing functional testing [open thinking questions] interview summary 4-3
3. Bean scope and life cycle
typescript30 - any type
Reflex WMS中阶系列7:已经完成拣货尚未Load的HD如果要取消拣货,该如何处理?
使用百度EasyDL实现厂区工人抽烟行为识别
喜报 | AR 开启纺织产业新模式,ALVA Systems 再获殊荣!
AOF重写
随机推荐
哈希冲突和一致性哈希
【图像融合】基于加权和金字塔实现图像融合附matlab代码
typescript30-any类型
3.Bean的作用域与生命周期
软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言
Day116. Shangyitong: Details of appointment registration ※
typescript34-class的基本使用
AOF rewrite
CodeTon Round 2 D. Magical Array 规律
LeetCode刷题日记:53、最大子数组和
YGG 公会发展计划第 1 季总结
"NetEase Internship" Weekly Diary (2)
Anti-oversold and high concurrent deduction scheme for e-commerce inventory system
Image fusion based on weighted 】 and pyramid image fusion with matlab code
Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem
Rust P2P Network Application Combat-1 P2P Network Core Concepts and Ping Program
Newton's theorem and related corollaries
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
Named parameter implementation of JDBC PreparedStatement
外包干了三年,废了...