package com.fs.live.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.R;
import com.fs.common.core.redis.RedisCache;
import com.fs.common.utils.DateUtils;
import com.fs.live.domain.LiveUserLike;
import com.fs.live.service.ILiveDataService;
import com.fs.live.service.ILiveUserLikeService;
import com.fs.live.websocket.bean.SendMsgVo;
import com.fs.live.websocket.service.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.websocket.server.PathParam;
import java.util.Date;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/app/live/liveData")
public class LiveDataController extends BaseController {

    @Autowired
    private ILiveDataService liveDataService;
    @Autowired
    private WebSocketServer webSocketServer;
    @Autowired
    private RedisCache redisCache;
    @Autowired
    private ILiveUserLikeService liveUserLikeService;

    /**
     * 点赞
     * */
    @GetMapping("/like/{liveId}")
    public R like(@PathVariable("liveId") Long liveId) {
        //直播间总点赞数
        Long increment = redisCache.increment("live:like:" + liveId, 1);
        return R.ok().put("like",increment);
    }
}
