当前位置:网站首页>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!
边栏推荐
- 用位运算为你的程序加速
- bool Frame::PosInGrid(const cv::KeyPoint &kp, int &posX, int &posY)
- Fly propeller power space future PIE - Engine Engine build earth science
- volatile原理解析
- Local storage in Kubernetes
- Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021:解读
- 有效进行自动化测试,这几个软件测试工具一定要收藏好!!!
- For effective automated testing, these software testing tools must be collected!!!
- 电商库存系统的防超卖和高并发扣减方案
- 大话西游创建角色失败解决
猜你喜欢
Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem
Win Go开发包安装配置、GoLand配置
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
typescript33 - high-level overview of typescript
Pcie the inbound and outbound
pcie inbound和outbound关系
Chengdu openGauss user group recruit!
检查IP或端口是否被封
第一次写对牛客的编程面试题:输入一个字符串,返回该字符串出现最多的字母
『网易实习』周记(三)
随机推荐
Named parameter implementation of JDBC PreparedStatement
《自然语言处理实战入门》 基于知识图谱的问答机器人
YGG Guild Development Plan Season 1 Summary
【ORB_SLAM2】void Frame::ComputeImageBounds(const cv::Mat &imLeft)
typescript37-class的构造函数实例方法继承(extends)
AntPathMatcher uses
AntPathMatcher使用
oracle查询扫描全表和走索引
传统企业数字化转型需要经过几个阶段?
第一次写对牛客的编程面试题:输入一个字符串,返回该字符串出现最多的字母
typescript30 - any type
手写一个博客平台~第一天
记录一次数组转集合出现错误的坑点,尽量使用包装类型数组进行转换
A full set of common interview questions for software testing functional testing [open thinking questions] interview summary 4-3
Day115.尚医通:后台用户管理:用户锁定解锁、详情、认证列表审批
typescript38-class的构造函数实例方法继承(implement)
制造企业数字化转型现状分析
哈希冲突和一致性哈希
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021:解读
"NetEase Internship" Weekly Diary (2)