package com.hc.web.controller.browser.front;

import com.hc.business.service.LiveClassService;
import com.hc.business.service.LiveService;
import com.hc.core.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;


/**
 * 直播间表(Live)表控制层
 *
 * @author makejava
 * @since 2024-01-20 11:48:46
 */

@RestController
@RequestMapping("/new/api/front/live")
public class FrontLiveController {


    /**
     * 服务对象
     */
    private final LiveService liveService;
    private final LiveClassService liveClassService;

    public FrontLiveController(LiveService liveService,
                               LiveClassService liveClassService) {
        this.liveService = liveService;
        this.liveClassService = liveClassService;
    }


    @GetMapping("/{id}")
    @ApiOperation(value = "依据主键获取 Live", response = Result.class)
    public Result selectDetail(@PathVariable("id") Integer id) {
        return Result.success(this.liveService.queryById(id));
    }

    @GetMapping("/list")
    @ApiOperation(value = "获取 Live列表(分页)", response = Result.class)
    public Result listLive(@RequestParam(defaultValue = "0") Integer page,
                           @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(liveService.queryAllByLimit(page, size));
    }

//select DISTINCT c.* from live_class a join user_status b on a.class_id=b.class_id join live c on a.live_id=c.live_id where a.live_id=4 and user_id=25795
    @GetMapping("/queryListByUserIDAndLiveID")
    @ApiOperation(value = "获取用户可以参与的直播间列表", response = Result.class)
    public Result queryListByUserIDAndLiveID(@RequestParam(defaultValue = "0") Integer userId,
                                                @RequestParam(defaultValue = "0") Integer liveId) {
        return Result.success(liveService.queryListByUserIDAndLiveID(userId, liveId));
    }


}
