当前位置:网站首页>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 :
边栏推荐
- 动态切换数据源
- 【DSP】【第二篇】了解C6678和创建工程
- B-杰哥的树(状压树形dp)
- 小孩子学什么编程?
- 8086指令码汇总表(表格)
- Jupyter launch didn't respond after Anaconda was installed & the web page was opened and ran without execution
- C language games - three chess
- [weekly pit] calculate the sum of primes within 100 + [answer] output triangle
- How to select several hard coded SQL rows- How to select several hardcoded SQL rows?
- Function optimization and arrow function of ES6
猜你喜欢
5. 無線體內納米網:十大“可行嗎?”問題
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
Introduction of Xia Zhigang
逻辑是个好东西
Detailed explanation of knowledge map construction process steps
Use of OLED screen
How to upgrade high value-added links in the textile and clothing industry? APS to help
(work record) March 11, 2020 to March 15, 2021
[weekly pit] positive integer factorization prime factor + [solution] calculate the sum of prime numbers within 100
电子游戏的核心原理
随机推荐
永磁同步电机转子位置估算专题 —— 基波模型与转子位置角
5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
【DSP】【第一篇】开始DSP学习
Rhcsa Road
[DIY]如何制作一款個性的收音機
B-jiege's tree (pressed tree DP)
【每周一坑】信息加密 +【解答】正整数分解质因数
Special topic of rotor position estimation of permanent magnet synchronous motor -- Summary of position estimation of fundamental wave model
看过很多教程,却依然写不好一个程序,怎么破?
数字三角形模型 AcWing 1018. 最低通行费
Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
[network planning] Chapter 3 data link layer (4) LAN, Ethernet, WLAN, VLAN
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
(工作记录)2020年3月11日至2021年3月15日
Boder radius has four values, and boder radius exceeds four values
[wechat applet] operation mechanism and update mechanism
【微信小程序】運行機制和更新機制
Catch ball game 1
8086指令码汇总表(表格)
深度学习分类网络 -- ZFNet