当前位置:网站首页>Variable star --- article module (1)
Variable star --- article module (1)
2022-07-06 20:38:00 【mb61037a3723f67】
Catalog
One : Get article details :
1: Analysis of article detail table :
analysis : To return the content information of the article , Article table , Users of articles . These three kinds of information come from three tables . If User Table as the main table , You cannot query the information of the article , So only the article table can be used as the main table .
2: Enter the data in the article content table :
mysql -uroot -pmysql -D hm_topnews -h 192.168.44.128 < sql file name
3: Write ideas :
1: First get the parameters , Need to get user's id, as well as is_refresh, Determine whether the user is logged in , And get article_id, The article id, Because we need to according to the article id Query the linked table .
2: Logical processing : The article table is used as the main table , Joint user table and article content table , According to the article id, Query the title of the article , Author information of the article , The content of the article .
3: If the user has logged in , Check whether the user pays attention to the author of the article , Query whether the user has collected this article , And the user's attitude towards the author .
4: Build response returns : Convert the data related to the article into a dictionary and return .
app/resource/article/article.py
test — Return the default information when you are not logged in :
4: Pay attention to the author's implementation :
1: Code implementation :
2: Add fields to the database :6 User No 1 No. author :
3: test :
5: Collection relationship and attitude relationship :
1: Add the relationship between users and articles collection and the attitude relationship between users and articles in the database .
2: Code implementation :
Two : Focus on users :
1: Demand analysis :
1: To obtain parameters : User id, The author's id.
2: Business logic : According to the user id And the author id Query in the following table , Three relationships are known [ Focus on =1, No attention to =0, Pull black =2], If the data is queried in the database, it may be concerned or hacked , Send this follow interface request , It can only be attention , Therefore, modify the relationship to focus on the relationship , And modify the time of concern .
3: If there is no data in the database , Explain that I haven't paid attention to , Therefore, we need to add data to the database .
4: After clicking on the user's attention , The number of users' followers should be increased 1, The number of fans of the author is also increased by one .
2: Code implementation :
Interface code :
Routing code :
test :
3、 ... and : Cancel paying attention to the interface :
1: Interface code :
2: route :
3: test :
边栏推荐
- 持续测试(CT)实战经验分享
- 02 basic introduction - data package expansion
- Pytest (3) - Test naming rules
- Activiti global process monitors activitieventlistener to monitor different types of events, which is very convenient without configuring task monitoring in acitivit
- recyclerview gridlayout 平分中间空白区域
- 【DSP】【第一篇】开始DSP学习
- OAI 5G NR+USRP B210安装搭建
- "Penalty kick" games
- Unity writes a timer tool to start timing from the whole point. The format is: 00:00:00
- Problems encountered in using RT thread component fish
猜你喜欢
Force deduction brush question - 98 Validate binary search tree
SQL injection 2
逻辑是个好东西
(work record) March 11, 2020 to March 15, 2021
The mail command is used in combination with the pipeline command statement
电子游戏的核心原理
Le lancement du jupyter ne répond pas après l'installation d'Anaconda
【DSP】【第一篇】开始DSP学习
持续测试(CT)实战经验分享
Rhcsa Road
随机推荐
[network planning] Chapter 3 data link layer (3) channel division medium access control
Pytest (3) - Test naming rules
Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
Core principles of video games
【微信小程序】运行机制和更新机制
Quel genre de programmation les enfants apprennent - ils?
Minimum cut edge set of undirected graph
JS implementation force deduction 71 question simplified path
【GET-4】
"Penalty kick" games
OAI 5G NR+USRP B210安装搭建
Tencent byte Alibaba Xiaomi jd.com offer got a soft hand, and the teacher said it was great
The mail command is used in combination with the pipeline command statement
22-07-05 upload of qiniu cloud storage pictures and user avatars
【每周一坑】输出三角形
Rhcsa Road
Anaconda安装后Jupyter launch 没反应&网页打开运行没执行
How to upgrade high value-added links in the textile and clothing industry? APS to help
Anaconda安裝後Jupyter launch 沒反應&網頁打開運行沒執行
Common doubts about the introduction of APS by enterprises