4.4 我收到的赞

93 阅读1分钟

携手创作,共同成长!这是我参与「掘金日新计划 · 8 月更文挑战」的第22天,点击查看活动详情

4.4 我收到的赞

image-20220721152453757.png

重构点赞功能

这里我们处理用户获得的点赞数量,我们可以在点赞的时候把这个赞的数量存到redis里(以用户id为key),所以我们需要重构一下以前写的点赞的代码

RedisKeyUtil工具类里写一个新方法设置user存到redis里的key设置成什么

image-20220721153519468.png

首先是LikeService

image-20220721164006102.png

image-20220721163249462.png

然后是LikeController

image-20220721163704665.png

然后是 discuss-detail.html

image-20220721164220123.png

image-20220721164340279.png

image-20220721164416254.png

image-20220721164529927.png

开发展示个人主页功能

直接把功能写在 UserController

image-20220721164645628.png

image-20220721164721520.png

然后是“个人主页”页面profile.html

image-20220721165048002.png

image-20220721165207344.png

image-20220721165409055.png

然后在首页index.html上加上用户头像的访问路径

image-20220721164909666.png

帖子详情页discuss-detail.html改头像的链接使其跳转到个人主页

image-20220721170209190.png

image-20220721170250181.png

私信页面letter.html改头像的链接使其跳转到展示个人主页的controller

image-20220721170600389.png

私信详情页面letter-detail.html改头像的链接使其跳转到展示个人主页的controller

image-20220721170925634.png

最后启动项目之后,经自己测试开发成功。