package com.fs.app.controller.live;

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.common.utils.poi.ExcelUtil;
import com.fs.live.domain.LiveUserFollow;
import com.fs.live.service.ILiveUserFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户直播关注Controller
 *
 * @author fs
 * @date 2025-07-11
 */
@RestController
@RequestMapping("/app/live/liveUserFollow")
public class LiveUserFollowController extends BaseController
{
    @Autowired
    private ILiveUserFollowService liveUserFollowService;

    /**
     * 查询用户直播关注列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LiveUserFollow liveUserFollow)
    {
        startPage();
        List<LiveUserFollow> list = liveUserFollowService.selectLiveUserFollowList(liveUserFollow);
        return getDataTable(list);
    }

    /**
     * 导出用户直播关注列表
     */
    @Log(title = "用户直播关注", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveUserFollow liveUserFollow)
    {
        List<LiveUserFollow> list = liveUserFollowService.selectLiveUserFollowList(liveUserFollow);
        ExcelUtil<LiveUserFollow> util = new ExcelUtil<LiveUserFollow>(LiveUserFollow.class);
        return util.exportExcel(list, "用户直播关注数据");
    }

    /**
     * 获取用户直播关注详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(liveUserFollowService.selectLiveUserFollowById(id));
    }

    /**
     * 新增用户直播关注
     */
    @Log(title = "用户直播关注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveUserFollow liveUserFollow)
    {
        return toAjax(liveUserFollowService.insertLiveUserFollow(liveUserFollow));
    }

    /**
     * 修改用户直播关注
     */
    @Log(title = "用户直播关注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveUserFollow liveUserFollow)
    {
        return toAjax(liveUserFollowService.updateLiveUserFollow(liveUserFollow));
    }

    /**
     * 删除用户直播关注
     */
    @Log(title = "用户直播关注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveUserFollowService.deleteLiveUserFollowByIds(ids));
    }
}
