package com.fs.ad.controller;

import com.fs.ad.domain.AdIqiyiAccount;
import com.fs.ad.service.IAdIqiyiAccountService;
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.domain.R;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
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 2025-03-03
 */
@RestController
@RequestMapping("/ad/AdIqiyiAccount")
public class AdIqiyiAccountController extends BaseController
{
    @Autowired
    private IAdIqiyiAccountService adIqiyiAccountService;

    /**
     * 查询爱奇艺广告账号列表
     */
    @PreAuthorize("@ss.hasPermi('ad:AdIqiyiAccount:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdIqiyiAccount adIqiyiAccount)
    {
        startPage();
        List<AdIqiyiAccount> list = adIqiyiAccountService.selectAdIqiyiAccountList(adIqiyiAccount);
        return getDataTable(list);
    }

    /**
     * 导出爱奇艺广告账号列表
     */
    @PreAuthorize("@ss.hasPermi('ad:AdIqiyiAccount:export')")
    @Log(title = "爱奇艺广告账号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdIqiyiAccount adIqiyiAccount)
    {
        List<AdIqiyiAccount> list = adIqiyiAccountService.selectAdIqiyiAccountList(adIqiyiAccount);
        ExcelUtil<AdIqiyiAccount> util = new ExcelUtil<AdIqiyiAccount>(AdIqiyiAccount.class);
        return util.exportExcel(list, "爱奇艺广告账号数据");
    }

    /**
     * 获取爱奇艺广告账号详细信息
     */
    @PreAuthorize("@ss.hasPermi('ad:AdIqiyiAccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adIqiyiAccountService.selectAdIqiyiAccountById(id));
    }

    /**
     * 新增爱奇艺广告账号
     */
    @PreAuthorize("@ss.hasPermi('ad:AdIqiyiAccount:add')")
    @Log(title = "爱奇艺广告账号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdIqiyiAccount adIqiyiAccount)
    {
        return toAjax(adIqiyiAccountService.insertAdIqiyiAccount(adIqiyiAccount));
    }

    /**
     * 修改爱奇艺广告账号
     */
    @PreAuthorize("@ss.hasPermi('ad:AdIqiyiAccount:edit')")
    @Log(title = "爱奇艺广告账号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdIqiyiAccount adIqiyiAccount)
    {
        return toAjax(adIqiyiAccountService.updateAdIqiyiAccount(adIqiyiAccount));
    }

    /**
     * 删除爱奇艺广告账号
     */
    @PreAuthorize("@ss.hasPermi('ad:AdIqiyiAccount:remove')")
    @Log(title = "爱奇艺广告账号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adIqiyiAccountService.deleteAdIqiyiAccountByIds(ids));
    }
    /**
     * 删除优酷广告账号
     */
    @PreAuthorize("@ss.hasPermi('ad:AdYouKuaccount:list')")
    @GetMapping("/listAll")
    public R listAll(){
        return R.ok().put("data", adIqiyiAccountService.listAll());
    }
}
