package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FollowInfo;
import com.ruoyi.system.service.IFollowInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 关注信息Controller
 * 
 * @author haotian
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/info")
public class FollowInfoController extends BaseController
{
    @Autowired
    private IFollowInfoService followInfoService;

    /**
     * 查询关注信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(FollowInfo followInfo)
    {
        startPage();
        List<FollowInfo> list = followInfoService.selectFollowInfoList(followInfo);
        return getDataTable(list);
    }

    /**
     * 导出关注信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "关注信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FollowInfo followInfo)
    {
        List<FollowInfo> list = followInfoService.selectFollowInfoList(followInfo);
        ExcelUtil<FollowInfo> util = new ExcelUtil<FollowInfo>(FollowInfo.class);
        util.exportExcel(response, list, "关注信息数据");
    }

    /**
     * 获取关注信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{followInfoId}")
    public AjaxResult getInfo(@PathVariable("followInfoId") Long followInfoId)
    {
        return success(followInfoService.selectFollowInfoByFollowInfoId(followInfoId));
    }

    /**
     * 新增关注信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "关注信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FollowInfo followInfo)
    {
        return toAjax(followInfoService.insertFollowInfo(followInfo));
    }

    /**
     * 修改关注信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "关注信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FollowInfo followInfo)
    {
        return toAjax(followInfoService.updateFollowInfo(followInfo));
    }

    /**
     * 删除关注信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "关注信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{followInfoIds}")
    public AjaxResult remove(@PathVariable Long[] followInfoIds)
    {
        return toAjax(followInfoService.deleteFollowInfoByFollowInfoIds(followInfoIds));
    }
}
