发表于: 2019-11-14 23:40:20

1 900


今天完成的事情:

看微信支付,嗯,老规矩,看不懂,要多看几遍了。


加了个对留言点赞后的的消息新增

/**
* 增加点赞,根据点赞类型,对应表点赞统计加1,新增对应消息
*
* @param request
* @param type  点赞对象类型,学习对象或留言
* @param bizId 点赞对象ID
*/
@PostMapping("/a/u/like")
public Map<String, Object> likeInsert(HttpServletRequest request, Integer type, Long bizId) {
   HashMap<String, Object> result = new HashMap<>(16);
   try {
       long userId = JWTUtil.getUserIdFromToken(request);
       log.info("用户ID为{}给{}类型ID为{}点赞", userId, type, bizId);
       StudyLike studyLike = new StudyLike();
       studyLike.setCreateBy(userId);
       studyLike.setUpdateBy(userId);
       studyLike.setType(type);
       studyLike.setBizId(bizId);
       int likeAddSuccess = studyLikeServer.insertSelective(studyLike);
       /*对应的类型对象点赞统计加1*/
       if (type == 10) {
           StudyObject studyObject=new StudyObject();
           studyObject.setId(bizId);
           studyObject.setLikeCount(1);
           studyObjectServer.updateCount(studyObject);
       } else if (type == 20) {
           Comment comment=new Comment();
           comment.setId(bizId);
           comment.setLikeCount(1);
           commentServer.updateByPrimaryKeySelective(comment);
           /*获取被点赞留言信息*/
           Comment commentMsg=commentServer.selectByPrimaryKey(bizId);
           /*给被点赞人进行消息提醒*/
           UserMessage userMessage=new UserMessage();
           userMessage.setCreateBy(userId);
           userMessage.setUpdateBy(userId);
           userMessage.setStudyLikeId(bizId);
           userMessage.setUserId(commentMsg.getCreateBy());
           userMessage.setReadFlag(false);
           userMessage.setMessageId(0L);
           userMessageServer.insertSelective(userMessage);
       }
       Long studyLikeInsertId = studyLike.getId();
       result.put("code", SUCCESS.getCode());
       result.put("msg", SUCCESS.getMsg());
       result.put("id", studyLikeInsertId);
       log.info("新增的点赞对应id:{}", studyLikeInsertId);
       return result;
   } catch (Exception e) {
       e.printStackTrace();
       result.put("code", REQUEST_FAILED.getCode());
       result.put("msg", REQUEST_FAILED.getMsg());
       return result;
   }
}


因为数据库不是我做的。他在这里消息是否已读用了tinying类型

用代码自动生成后,在java里是boolean类型的,默认未读,就是0,对应的是false


和师姐讨论了一下数据库字段非null问题。修真院这边是强制所有字段非空。可以防止出现空指针问题。

然后师姐写了一个类用来初始化实体类的属性值,想了想,好像可以有。当然,详细情况还要多写几次尝试下。


大概长这样




明天计划的事情:

继续看微信支付。


遇到的问题:

和前端遇到了一个问题,进页面获取用户的年级信息,想让我在查询学习对象时获取。。

按照接口功能的单一性。怎么也不属于我这里,,应该让前端自己去获取,然后再传给我。

准备晨会的时候讨论清楚

收获:



返回列表 返回列表
评论

    分享到