コード例 #1
0
 @Async
 @Aop("redis")
 public void updateTopicTypeCount() {
   for (TopicType tt : TopicType.values()) {
     tt.count = jedis().zcount(RKEY_TOPIC_UPDATE + tt.name(), "-inf", "+inf");
   }
 }
コード例 #2
0
 /**
  * @api {post} /yvr/api/v1/topics 发表帖子, 以json格式提交数据
  * @apiGroup Topic
  * @apiVersion 1.0.0
  * @apiUse TOKEN
  * @apiUse TOKEN_ERROR
  * @apiParam {String} title 标题
  * @apiParam {String} content 内容
  * @apiParam {String} [tab=ask] 类型,默认为问答
  * @apiSuccess {boolean} success 是否成功
  * @apiSuccess {String} [topic_id] 成功时返回帖子的Id
  * @apiSuccess {String} [message] 失败时返回原因
  */
 @POST
 @At("/topics")
 @AdaptBy(type = WhaleAdaptor.class)
 @Filters(@By(type = AccessTokenFilter.class))
 public Object add(
     @Param("..") Topic topic,
     @Attr(scope = Scope.SESSION, value = "me") int userId,
     @Param("tab") String tab) {
   if (tab != null) topic.setType(TopicType.valueOf(tab));
   CResult re = yvrService.add(topic, userId);
   if (re.isOk()) {
     return _map("success", true, "topic_id", re.as(String.class));
   } else {
     return _map("success", false, "message", re.getMsg());
   }
 }