当前位置: 首页 > news >正文

网站建设师百度百科ui界面设计尺寸

网站建设师百度百科,ui界面设计尺寸,wordpress占用CPU高,在线设计平台市场分析点赞功能随处可见#xff0c;我们都知道点赞是一个非常高频的操作#xff0c;redis就非常适合做这种工作。 实现效果#xff1a; 分析#xff1a;三种类型#xff1a;给帖子点赞#xff0c;给评论点赞#xff0c;给回复点赞 我们只实现查看点赞数量的话#xff0c;只…点赞功能随处可见我们都知道点赞是一个非常高频的操作redis就非常适合做这种工作。 实现效果 分析三种类型给帖子点赞给评论点赞给回复点赞 我们只实现查看点赞数量的话只要一个int记录一下就可以但是我们之后还想查看点赞的人所以要把每一个点赞的信息都记录好方便后面的功能继续做出来。 思路 点赞把点赞的信息放进去。 取消把点赞的信息删除。 在此之前我们要封装一个get到key的类方便后面复用。 package com.now.community.community.util;public class RedisKeyUtil {private static final String SPLIT :;private static final String PREFIX_ENTITY_LIKE like:entity;private static final String PREFIX_USER_LIKE like:user;// 某个实体的赞// like:entity:entityType:entityId - set(userId)public static String getEntityLikeKey(int entityType, int entityId) {return PREFIX_ENTITY_LIKE SPLIT entityType SPLIT entityId;}// 某个用户的赞// like:user:userId - intpublic static String getUserLikeKey(int userId) {return PREFIX_USER_LIKE SPLIT userId;} }点赞业务 // 点赞public void like(int userId, int entityType, int entityId, int entityUserId) {redisTemplate.execute(new SessionCallback() {Overridepublic Object execute(RedisOperations operations) throws DataAccessException {String entityLikeKey RedisKeyUtil.getEntityLikeKey(entityType, entityId);boolean isMember operations.opsForSet().isMember(entityLikeKey, userId);operations.multi();if (isMember) {operations.opsForSet().remove(entityLikeKey, userId);} else {operations.opsForSet().add(entityLikeKey, userId);}return operations.exec();}});} 我们要查找是否点赞还有点赞数量方便页面显示 // 查询某实体点赞的数量public long findEntityLikeCount(int entityType, int entityId) {String entityLikeKey RedisKeyUtil.getEntityLikeKey(entityType, entityId);return redisTemplate.opsForSet().size(entityLikeKey);}// 查询某人对某实体的点赞状态public int findEntityLikeStatus(int userId, int entityType, int entityId) {String entityLikeKey RedisKeyUtil.getEntityLikeKey(entityType, entityId);return redisTemplate.opsForSet().isMember(entityLikeKey, userId) ? 1 : 0;} 点赞LikeController RequestMapping(path /like, method RequestMethod.POST)ResponseBodypublic String like(int entityType, int entityId,int entityUserId,int postId) {User user hostHolder.getUser();// 点赞likeService.like(user.getId(), entityType, entityId,entityUserId);// 数量long likeCount likeService.findEntityLikeCount(entityType, entityId);// 状态int likeStatus likeService.findEntityLikeStatus(user.getId(), entityType, entityId);// 返回的结果MapString, Object map new HashMap();map.put(likeCount, likeCount);map.put(likeStatus, likeStatus);return CommunityUtil.getJSONString(0, null, map);}
http://www.zqtcl.cn/news/987436/

相关文章:

  • 爱心捐赠网站怎么做中国机械网官网
  • 好的ftp网站微信小程序开发基础
  • 西安 网站 公司wordpress+帖子置顶
  • 广州开发网站服务上海千途网站建设
  • 网站建设功能分为几种百度搜索数据
  • 电影网站模板html微信开发者代码管理
  • 小程序ui界面设计手机优化大师官网
  • 佳木斯市建设局网站网络游戏名
  • 建筑钢结构网站汉阳网站建设哪家便宜
  • 营销型网站建设评价临湘网站建设
  • 做网站的价格参考巴中建网站的公司
  • 张家口建设网站网络技术工程师
  • 大型网站后台登录地址一般是如何设置的哪里网站用vue.js做的
  • 网页设计规范图标设计百度seo优化多少钱
  • 网站打开速度概念建筑网站知乎
  • 网站的flash怎么做的杭州市城乡建设网官网
  • 宿迁网站建设排名wordpress多站点可视化
  • 苏州好的做网站的公司哪家好前端如何做响应式网站
  • 广州网站建设招标推广方式有哪些渠道
  • 郑州做网站狼牙东莞建设造价信息网站
  • 网站制作代理加盟国内seo服务商
  • 如何在建设银行网站预约纪念币网络销售好不好做
  • 利用淘宝视频服务做视频网站聊城做网站价格
  • 做美容行业的网站哪个好广西互联网企业
  • 做网站平台的营业执照江镇做包子网站
  • 网站建设 摄影服务wordpress破解模板
  • 网站规划中的三种常用类型宁波海曙区建设局网站
  • dede做网站湖北网址大全
  • 如何注册网站的名字html表单制作
  • 中国建设工程协会标准网站什么网站做推广比较好