package com.fs.course.controller;

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.course.domain.FsUserTalentFollow;
import com.fs.course.service.IFsUserTalentFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 达人关注Controller
 *
 * @author fs
 * @date 2024-05-31
 */
@RestController
@RequestMapping("/course/userTalentFollow")
public class FsUserTalentFollowController extends BaseController
{
    @Autowired
    private IFsUserTalentFollowService fsUserTalentFollowService;

    /**
     * 查询达人关注列表
     */
    @PreAuthorize("@ss.hasPermi('course:userTalentFollow:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserTalentFollow fsUserTalentFollow)
    {
        startPage();
        List<FsUserTalentFollow> list = fsUserTalentFollowService.selectFsUserTalentFollowList(fsUserTalentFollow);
        return getDataTable(list);
    }

    /**
     * 导出达人关注列表
     */
    @PreAuthorize("@ss.hasPermi('course:userTalentFollow:export')")
    @Log(title = "达人关注", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserTalentFollow fsUserTalentFollow)
    {
        List<FsUserTalentFollow> list = fsUserTalentFollowService.selectFsUserTalentFollowList(fsUserTalentFollow);
        ExcelUtil<FsUserTalentFollow> util = new ExcelUtil<FsUserTalentFollow>(FsUserTalentFollow.class);
        return util.exportExcel(list, "达人关注数据");
    }

    /**
     * 获取达人关注详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:userTalentFollow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsUserTalentFollowService.selectFsUserTalentFollowById(id));
    }

    /**
     * 新增达人关注
     */
    @PreAuthorize("@ss.hasPermi('course:userTalentFollow:add')")
    @Log(title = "达人关注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserTalentFollow fsUserTalentFollow)
    {
        return toAjax(fsUserTalentFollowService.insertFsUserTalentFollow(fsUserTalentFollow));
    }

    /**
     * 修改达人关注
     */
    @PreAuthorize("@ss.hasPermi('course:userTalentFollow:edit')")
    @Log(title = "达人关注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserTalentFollow fsUserTalentFollow)
    {
        return toAjax(fsUserTalentFollowService.updateFsUserTalentFollow(fsUserTalentFollow));
    }

    /**
     * 删除达人关注
     */
    @PreAuthorize("@ss.hasPermi('course:userTalentFollow:remove')")
    @Log(title = "达人关注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsUserTalentFollowService.deleteFsUserTalentFollowByIds(ids));
    }
}
