当前位置:网站首页>Tiktok actual battle ~ list of bloggers I follow, follow and check
Tiktok actual battle ~ list of bloggers I follow, follow and check
2022-06-28 16:01:00 【gblfy】


List of articles
One 、 Focus on modules
1. Focus on the flow chart
Not yet , Coming soon !
2. Focus on the process brief
Not yet , Coming soon !
Two 、 The front end pays attention to the relevant
2.1. Check the list of bloggers I follow
// Check the list of bloggers I follow
queryMyFollowList(page) {
var me = this;
// if (page == 0) {
// me.followsList = [];
// }
page = page + 1;
var userId = getApp().getUserInfoSession().id;
var serverUrl = app.globalData.serverUrl;
uni.request({
method: "GET",
header: {
headerUserId: userId,
headerUserToken: app.getUserSessionToken()
},
url: serverUrl + "/fans/queryMyFollows?myId=" + userId + "&page=" + page + "&pageSize=10",
success(result) {
if (result.data.status == 200) {
var followsList = result.data.data.rows;
var totalPage = result.data.data.total;
me.followsList = me.followsList.concat(followsList);
me.page = page;
me.totalPage = totalPage;
}
}
});
},
2.2. Cancel the attention
// Cancel the attention
cancelFollow(vlogerId) {
var me = this;
var userId = getApp().getUserInfoSession().id;
var serverUrl = app.globalData.serverUrl;
uni.request({
method: "POST",
header: {
headerUserId: userId,
headerUserToken: app.getUserSessionToken()
},
url: serverUrl + "/fans/cancel?myId=" + userId + "&vlogerId=" + vlogerId,
success(result) {
if (result.data.status == 200) {
me.reFreshList(vlogerId, false);
} else {
uni.showToast({
title: result.data.msg,
icon: "none",
duration: 3000
});
}
}
});
},
2.2. Pay attention to me
// Pay attention to me
followMe(vlogerId) {
var me = this;
var userId = getApp().getUserInfoSession().id;
var serverUrl = app.globalData.serverUrl;
uni.request({
method: "POST",
header: {
headerUserId: userId,
headerUserToken: app.getUserSessionToken()
},
url: serverUrl + "/fans/follow?myId=" + userId + "&vlogerId=" + vlogerId,
success(result) {
if (result.data.status == 200) {
me.reFreshList(vlogerId, true);
} else {
uni.showToast({
title: result.data.msg,
icon: "none",
duration: 3000
});
}
}
});
},
2.4. Slide up the paged fan list
<template>
<view class="page">
<view class="line"></view>
<scroll-view scroll-y="true" @scrolltolower="pagingFollowsList()">
<view
class="user-wrapper"
v-for="(f, index) in followsList"
:key="index">
<view class="user-info">
<image class="face" :src="f.face" style="align-self: center;"></image>
<text class="user-name" style="align-self: center;">{
{
f.nickname}}</text>
</view>
<view v-if="!f.followed" class="operator-wrapper" style="width: 140rpx; height: 60rpx;display: flex;flex-direction: row;justify-content: center;background-color: #ef274d;border-radius: 10px;align-self: center;">
<text class="operator-words" style="align-self: center;color: #FFFFFF;" @click="followMe(f.vlogerId)"> Focus on </text>
</view>
<view v-if="f.followed" class="operator-wrapper" style="width: 140rpx; height: 60rpx;display: flex;flex-direction: row;justify-content: center;background-color: #ef274d;border-radius: 10px;align-self: center;border-width: 1px;border-color: #ef274d;background-color: #181b27;">
<text class="operator-words" style="align-self: center;color: #ef274d;" @click="cancelFollow(f.vlogerId)"> Take off </text>
</view>
</view>
</scroll-view>
</view>
</template>
// Slide up the paged fan list
pagingFollowsList() {
// this.followsList = this.followsList.concat(this.followsList);
if (this.page >= this.totalPage) {
return;
}
this.queryMyFollowList(this.page);
}
2.5. Status refresh
// Focus on / Closed list Reset status refresh settings
reFreshList(vlogerId, status) {
var me = this;
var followsList = me.followsList;
for (var i = 0 ; i < followsList.length ; i ++) {
var vloger = followsList[i];
if (vloger.vlogerId == vlogerId) {
vloger.followed = status;
followsList.splice(i,1, vloger);
}
}
me.followsList = followsList;
},
3、 ... and 、 The back-end pays attention to relevant
3.1. Check the list of bloggers I follow
/**
* Check the list of bloggers I follow
*
* @param myId My users ID
* @param page Current page
* @param pageSize How many are displayed on each page
* @return
*/
@GetMapping("queryMyFollows")
public GraceJSONResult queryMyFollows(@RequestParam String myId,
@RequestParam Integer page,
@RequestParam Integer pageSize) {
return GraceJSONResult.ok(
fansService.queryMyFollows(
myId,
page,
pageSize));
}
@Override
public PagedGridResult queryMyFollows(String myId,
Integer page,
Integer pageSize) {
Map<String, Object> map = new HashMap<>();
map.put("myId", myId);
PageHelper.startPage(page, pageSize);
List<VlogerVO> list = fansMapperCustom.queryMyFollows(map);
return setterPagedGrid(list, page);
}
<select id="queryMyFollows" resultType="com.gblfy.vo.VlogerVO" parameterType="map">
SELECT
u.id as vlogerId,
u.nickname as nickname,
u.face as face
FROM
fans f
LEFT JOIN
users u
ON
f.vloger_id = u.id
WHERE
f.fan_id = #{paramMap.myId}
ORDER BY
u.nickname
ASC
</select>
3.2. Take off
/**
* Take off
*
* @param myId My users ID
* @param vlogerId Video publisher ID
* @return
*/
@PostMapping("cancel")
public GraceJSONResult cancel(@RequestParam String myId,
@RequestParam String vlogerId) {
// Delete the execution of the business
fansService.doCancel(myId, vlogerId);
// Blogger fans -1, My attention -1
// My total number of concerns
redis.decrement(REDIS_MY_FOLLOWS_COUNTS + ":" + myId, 1);
// The total number of bloggers' fans
redis.decrement(REDIS_MY_FANS_COUNTS + ":" + vlogerId, 1);
// My relationship with bloggers , rely on redis, Do not store databases , avoid db Performance bottlenecks
redis.del(REDIS_FANS_AND_VLOGGER_RELATIONSHIP + ":" + myId + ":" + vlogerId);
return GraceJSONResult.ok();
}
3.3. Focus on
/**
* Focus on
*
* @param myId My users ID
* @param vlogerId Video publisher ID
* @return
*/
@PostMapping("follow")
public GraceJSONResult follow(@RequestParam String myId,
@RequestParam String vlogerId) {
// Whether two id Can't be empty
if (StringUtils.isBlank(myId) || StringUtils.isBlank(vlogerId)) {
return GraceJSONResult.errorCustom(ResponseStatusEnum.SYSTEM_ERROR);
}
// Judge the current user , You can't pay attention to yourself
if (myId.equalsIgnoreCase(vlogerId)) {
return GraceJSONResult.errorCustom(ResponseStatusEnum.SYSTEM_RESPONSE_NO_INFO);
}
// Whether two id Whether the corresponding user exists
Users vloger = userService.getUser(vlogerId);
Users myInfo = userService.getUser(myId);
// fixme: Two users id Judgment after database query , It's good to separate ? It's better to combine and judge ?
if (myInfo == null || vloger == null) {
return GraceJSONResult.errorCustom(ResponseStatusEnum.SYSTEM_RESPONSE_NO_INFO);
}
// Saving fans relates to the database
fansService.doFollow(myId, vlogerId);
// Blogger fans +1, My attention +1
// My total number of concerns
redis.increment(REDIS_MY_FOLLOWS_COUNTS + ":" + myId, 1);
// The total number of bloggers' fans
redis.increment(REDIS_MY_FANS_COUNTS + ":" + vlogerId, 1);
// My relationship with bloggers , rely on redis, Do not store databases , avoid db Performance bottlenecks
redis.set(REDIS_FANS_AND_VLOGGER_RELATIONSHIP + ":" + myId + ":" + vlogerId, "1");
return GraceJSONResult.ok();
}
边栏推荐
- 10 years of testing experience, worthless in the face of the physiological age of 35
- Curve 替换 Ceph 在网易云音乐的实践
- Web3.0时代来了,看天翼云存储资源盘活系统如何赋能新基建(上)
- Go zero micro Service Practice Series (VII. How to optimize such a high demand)
- 【初学者必看】vlc实现的rtsp服务器及转储H264文件
- Do not use short circuit logic to write STL sorter multi condition comparison
- NFT pledge LP liquidity mining system development details
- 分布式 CAP 定理的前世今生
- Visual Studio 2010 编绎Qt5.6.3
- MIPS assembly language learning-01-sum of two numbers, environment configuration and how to run
猜你喜欢

5分钟的时间制作一个反弹球游戏

Soliciting articles and contributions - building a blog environment with a lightweight application server

MIPS assembly language learning -02- logic judgment - foreground input

VS2013 帮助文档中没有 win32/com

Etcd可视化工具:Kstone简介(一)

Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse

Xinchuang operating system -- kylin kylin desktop operating system (project 10 security center)

go-zero 微服务实战系列(七、请求量这么高该如何优化)

Coding Devops helps Sinochem information to build a new generation of research efficiency platform and drive the new future of "online Sinochem"

wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe-Module
随机推荐
Visual Studio 2019软件安装包和安装教程
Flutter simply implements multilingual internationalization
关注35岁的坎:畏惧是因为你没有匹配这个年纪该有的能力
What! One command to get the surveillance?
如何查询数据库中一个表中的所有数据呢?
The world has embraced Web3.0 one after another, and many countries have clearly begun to seize the initiative
10:00面试,10:02就出来了 ,问的实在是太...
信创操作系统--麒麟Kylin桌面操作系统 (项目十 安全中心)
5 minutes to make a bouncing ball game
Do not use short circuit logic to write STL sorter multi condition comparison
Solution to JSON parsing problem using curl for Tron API signature broadcast and json Problem record of the loads method
10: 00 interview, came out at 10:02, the question is really too
Focus on the 35 year old Kan: fear is because you don't have the ability to match your age
国债与定期存款哪个更安全 两者之间有何区别
ROS knowledge points - ROS create workspace
Gbase Nantah General Motors appears at the 6th World Intelligence Conference
大神详解开源 BUFF 增益攻略丨直播讲座
零钱兑换(动态规划)
部门新来了个字节25K出来的,让我见识到了什么是天花板
看界面控件DevExpress WinForms如何创建一个虚拟键盘