package com.fs.app.controller.live;


import com.fs.app.facade.LiveFacadeService;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.live.domain.LiveWatchUser;
import com.fs.live.service.ILiveWatchUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 直播间观看用户Controller
 *
 * @author fs
 * @date 2025-01-18
 */
@RestController
@RequestMapping("/app/live/liveWatchUser")
public class LiveWatchUserController extends BaseController
{
    @Autowired
    private ILiveWatchUserService liveWatchUserService;

    @Autowired
    private LiveFacadeService liveFacadeService;


    @GetMapping("/watchUserList")
    public TableDataInfo watchUserList(LiveWatchUser param) {
/*        param.setOnline(0);
        List<LiveWatchUserVO> onLineUserList = liveWatchUserService.selectOnlineUserList(param);
        return getDataTable(onLineUserList);*/
        return liveFacadeService.watchUserList(param);
    }


    /**
     * 获取直播间观看用户详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(liveWatchUserService.selectLiveWatchUserById(id));
    }

    /**
     * 新增直播间观看用户
     */
    @Log(title = "直播间观看用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveWatchUser liveWatchUser)
    {
        return toAjax(liveWatchUserService.insertLiveWatchUser(liveWatchUser));
    }

    /**
     * 修改直播间观看用户
     */
    @Log(title = "直播间观看用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveWatchUser liveWatchUser)
    {
        return toAjax(liveWatchUserService.updateLiveWatchUser(liveWatchUser));
    }

    /**
     * 删除直播间观看用户
     */
    @Log(title = "直播间观看用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveWatchUserService.deleteLiveWatchUserByIds(ids));
    }

    /**
     * 修改直播间用户禁言状态
     */
    @Log(title = "直播间观看用户", businessType = BusinessType.UPDATE)
    @PutMapping("/changeUserState")
    public AjaxResult changeUserState(@RequestParam Long liveId, @RequestParam Long userId) {
        return toAjax(liveWatchUserService.changeUserState(liveId, userId));
    }

}
