新增发帖达人页面
This commit is contained in:
parent
de721bed3a
commit
d7ad5d7e25
7
sql/加qq群即可获取.md
Normal file
7
sql/加qq群即可获取.md
Normal file
@ -0,0 +1,7 @@
|
||||
SQL文件开源的,在QQ群,开源不易,
|
||||
|
||||
请在gitee或github左上角star后备注gitee的用户名加**QQ群(640700429)**获取
|
||||
|
||||
或者扫码进群
|
||||
|
||||
![](https://gitee.com/virus010101/linfeng-community/raw/master/images/qrcode.jpg)
|
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* -----------------------------------
|
||||
* 林风社交论坛开源版本请务必保留此注释头信息
|
||||
* 开源地址: https://gitee.com/virus010101/linfeng-community
|
||||
* 商业版演示站点: https://www.linfeng.tech
|
||||
* 商业版购买联系技术客服
|
||||
* QQ: 3582996245
|
||||
* 可正常分享和学习源码,不得专卖或非法牟利!
|
||||
* Copyright (c) 2021-2023 linfeng all rights reserved.
|
||||
* 版权所有 ,侵权必究!
|
||||
* -----------------------------------
|
||||
*/
|
||||
package io.linfeng.common.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Jl.Yu
|
||||
* @email linfengtech001@163.com
|
||||
* @date 2022-10-08 13:51:43
|
||||
*/
|
||||
@Data
|
||||
public class AppUserRankResponse implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer uid;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 性别(0未知,1男,2女)
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String intro;
|
||||
|
||||
/**
|
||||
* 用户标签
|
||||
*/
|
||||
private String tagStr;
|
||||
|
||||
private Integer postNumber;
|
||||
|
||||
}
|
@ -14,6 +14,7 @@ package io.linfeng.modules.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import io.linfeng.common.response.AppUserInfoResponse;
|
||||
import io.linfeng.common.response.AppUserRankResponse;
|
||||
import io.linfeng.common.response.AppUserResponse;
|
||||
import io.linfeng.common.response.HomeRateResponse;
|
||||
import io.linfeng.common.utils.AppPageUtils;
|
||||
@ -66,5 +67,7 @@ public interface AppUserService extends IService<AppUserEntity> {
|
||||
AppUserInfoResponse findUserInfoById(Integer uid, AppUserEntity user);
|
||||
|
||||
Integer miniWxLogin(WxLoginForm form);
|
||||
|
||||
List<AppUserRankResponse> userRank();
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package io.linfeng.modules.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@ -34,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -43,6 +45,9 @@ import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static java.util.Map.Entry.comparingByValue;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@ -322,6 +327,28 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppUserRankResponse> userRank() {
|
||||
DateTime month = cn.hutool.core.date.DateUtil.beginOfMonth(new Date());
|
||||
|
||||
List<PostEntity> postList = postService.lambdaQuery().gt(PostEntity::getCreateTime, month).list();
|
||||
Map<Integer, Long> collect = postList.stream().collect(Collectors.groupingBy(PostEntity::getUid, Collectors.counting()));
|
||||
Map<Integer, Long> sorted = collect
|
||||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Collections.reverseOrder(comparingByValue()))
|
||||
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2,
|
||||
LinkedHashMap::new));
|
||||
List<AppUserRankResponse> list=new ArrayList<>();
|
||||
sorted.forEach((k,v)->{
|
||||
AppUserRankResponse response=new AppUserRankResponse();
|
||||
BeanUtils.copyProperties(this.getById(k),response);
|
||||
response.setPostNumber(v.intValue());
|
||||
list.add(response);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private Integer getTotalNum() {
|
||||
return this.lambdaQuery().select(AppUserEntity::getUid).count();
|
||||
|
@ -12,6 +12,7 @@
|
||||
package io.linfeng.modules.app.controller;
|
||||
|
||||
import io.linfeng.common.response.AppUserInfoResponse;
|
||||
import io.linfeng.common.response.AppUserRankResponse;
|
||||
import io.linfeng.common.response.AppUserResponse;
|
||||
import io.linfeng.common.utils.AppPageUtils;
|
||||
import io.linfeng.common.utils.R;
|
||||
@ -30,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -41,7 +43,7 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
@Api(tags = "APP登录接口")
|
||||
public class AppLoginController {
|
||||
public class AppUserInfoController {
|
||||
|
||||
|
||||
@Autowired
|
||||
@ -134,13 +136,7 @@ public class AppLoginController {
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@PostMapping("/cancelFollow")
|
||||
@ApiOperation("取消关注用户")
|
||||
public R cancelFollow(@LoginUser AppUserEntity user, @RequestBody AddFollowForm request) {
|
||||
appUserService.cancelFollow(request, user);
|
||||
return R.ok("取消关注用户成功");
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@GetMapping("/userFans")
|
||||
@ -169,4 +165,14 @@ public class AppLoginController {
|
||||
|
||||
return R.ok().put("result", response);
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@PostMapping("/userRank")
|
||||
@ApiOperation("发帖达人列表")
|
||||
public R userRank() {
|
||||
List<AppUserRankResponse> list=appUserService.userRank();
|
||||
return R.ok().put("result",list);
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,28 @@
|
||||
</view>
|
||||
<!-- 发帖达人 -->
|
||||
<view v-show="pageCurrent == 1">
|
||||
发帖达人
|
||||
<navigator :url="'/pages/user/home?uid=' + item.uid" class="user-item" hover-class="none"
|
||||
v-for="(item, index) in userList" :key="index">
|
||||
<view v-if="index < 10" class="user-index-hot">{{ index + 1 }}</view>
|
||||
<view v-else class="user-index">{{ index + 1 }}</view>
|
||||
<image class="avatar" mode="aspectFill" :src="item.avatar"></image>
|
||||
<view class="right">
|
||||
<text class="username">{{ item.username }}</text>
|
||||
<view class="tag-wrap">
|
||||
<text class="tag" :key="index2">{{ item.intro }}</text>
|
||||
<text class="tag" :key="index2">+{{ item.postNumber }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</navigator>
|
||||
<!-- 加载状态 -->
|
||||
<block v-if="userList.length === 0 && loadStatus == 'nomore'">
|
||||
<u-empty margin-top="100" text="暂无内容" mode="favor"></u-empty>
|
||||
</block>
|
||||
<block v-else>
|
||||
<view style="margin: 30rpx 0;">
|
||||
<u-loadmore :status="loadStatus" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
|
||||
@ -55,12 +76,14 @@
|
||||
loadPostStatus: 'loadmore',
|
||||
classId: 0,
|
||||
page: 1,
|
||||
userList: [],
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getBannerList();
|
||||
this.getPostList();
|
||||
this.getClassList();
|
||||
this.getUserRanking();
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.pageCurrent == 0) {
|
||||
@ -68,7 +91,8 @@
|
||||
this.getPostList()
|
||||
}
|
||||
if (this.pageCurrent == 1) {
|
||||
|
||||
this.userList = [];
|
||||
this.getUserRanking();
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
@ -78,7 +102,8 @@
|
||||
this.getPostList()
|
||||
}
|
||||
if (this.pageCurrent == 1) {
|
||||
|
||||
this.userList = [];
|
||||
this.getUserRanking();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -95,7 +120,6 @@
|
||||
})
|
||||
},
|
||||
pageTabChange(index) {
|
||||
// console.log(index)
|
||||
this.pageCurrent = index
|
||||
},
|
||||
tabChange(index) {
|
||||
@ -111,6 +135,13 @@
|
||||
this.classList = this.classList.concat(res.result)
|
||||
})
|
||||
},
|
||||
getUserRanking() {
|
||||
this.$H
|
||||
.post('user/userRank')
|
||||
.then(res => {
|
||||
this.userList = res.result;
|
||||
});
|
||||
},
|
||||
// 根据分页和分类展示帖子列表
|
||||
getPostList() {
|
||||
console.log('classId:', this.classId)
|
||||
@ -158,7 +189,7 @@
|
||||
.user-index-hot {
|
||||
margin-right: 20rpx;
|
||||
color: #fff;
|
||||
background-image: linear-gradient(#7979b6, #aaaaff);
|
||||
background-image: linear-gradient(#e64340, #ffaac3);
|
||||
width: 55rpx;
|
||||
height: 55rpx;
|
||||
border-radius: 50%;
|
||||
@ -198,19 +229,12 @@
|
||||
border-radius: 10rpx;
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background-color: #99ccff;
|
||||
background-color: #7da9bd;
|
||||
|
||||
&:nth-child(2n) {
|
||||
background-color: #ccb3ff;
|
||||
}
|
||||
|
||||
&:nth-child(3n) {
|
||||
background-color: #ffe7b3;
|
||||
}
|
||||
|
||||
&:nth-child(5n) {
|
||||
background-color: #b3e0ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user