diff --git a/sql/加qq群即可获取.md b/sql/加qq群即可获取.md new file mode 100644 index 0000000..d806e91 --- /dev/null +++ b/sql/加qq群即可获取.md @@ -0,0 +1,7 @@ +SQL文件开源的,在QQ群,开源不易, + +请在gitee或github左上角star后备注gitee的用户名加**QQ群(640700429)**获取 + +或者扫码进群 + +![](https://gitee.com/virus010101/linfeng-community/raw/master/images/qrcode.jpg) \ No newline at end of file diff --git a/src/main/java/io/linfeng/common/response/AppUserRankResponse.java b/src/main/java/io/linfeng/common/response/AppUserRankResponse.java new file mode 100644 index 0000000..219a231 --- /dev/null +++ b/src/main/java/io/linfeng/common/response/AppUserRankResponse.java @@ -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; + +} diff --git a/src/main/java/io/linfeng/modules/admin/service/AppUserService.java b/src/main/java/io/linfeng/modules/admin/service/AppUserService.java index d3b307c..5899119 100644 --- a/src/main/java/io/linfeng/modules/admin/service/AppUserService.java +++ b/src/main/java/io/linfeng/modules/admin/service/AppUserService.java @@ -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 { AppUserInfoResponse findUserInfoById(Integer uid, AppUserEntity user); Integer miniWxLogin(WxLoginForm form); + + List userRank(); } diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java index 62aa05b..1bb4c27 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java @@ -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 i } } + @Override + public List userRank() { + DateTime month = cn.hutool.core.date.DateUtil.beginOfMonth(new Date()); + + List postList = postService.lambdaQuery().gt(PostEntity::getCreateTime, month).list(); + Map collect = postList.stream().collect(Collectors.groupingBy(PostEntity::getUid, Collectors.counting())); + Map sorted = collect + .entrySet() + .stream() + .sorted(Collections.reverseOrder(comparingByValue())) + .collect(toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, + LinkedHashMap::new)); + List 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(); diff --git a/src/main/java/io/linfeng/modules/app/controller/AppLoginController.java b/src/main/java/io/linfeng/modules/app/controller/AppUserInfoController.java similarity index 93% rename from src/main/java/io/linfeng/modules/app/controller/AppLoginController.java rename to src/main/java/io/linfeng/modules/app/controller/AppUserInfoController.java index ba1f364..44fe757 100644 --- a/src/main/java/io/linfeng/modules/app/controller/AppLoginController.java +++ b/src/main/java/io/linfeng/modules/app/controller/AppUserInfoController.java @@ -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 list=appUserService.userRank(); + return R.ok().put("result",list); + } + } diff --git a/src/main/resources/static/linfeng-community-uniapp-ky/pages/square/square.vue b/src/main/resources/static/linfeng-community-uniapp-ky/pages/square/square.vue index 0a2ed25..4294a2b 100644 --- a/src/main/resources/static/linfeng-community-uniapp-ky/pages/square/square.vue +++ b/src/main/resources/static/linfeng-community-uniapp-ky/pages/square/square.vue @@ -23,7 +23,28 @@ - 发帖达人 + + {{ index + 1 }} + {{ index + 1 }} + + + {{ item.username }} + + {{ item.intro }} + +{{ item.postNumber }} + + + + + + + + + + + + @@ -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; - } } } }