package com.fs.ad.controller;

import com.fs.ad.domain.AdYoukuAccount;
import com.fs.ad.service.IAdYoukuAccountService;
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-02-19
 */
@RestController
@RequestMapping("/ad/AdYouKuAccount")
public class AdYoukuAccountController extends BaseController
{
    @Autowired
    private IAdYoukuAccountService adYoukuAccountService;

    /**
     * 查询优酷广告账号列表
     */
    @PreAuthorize("@ss.hasPermi('ad:AdYouKuaccount:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdYoukuAccount adYoukuAccount)
    {
        startPage();
        List<AdYoukuAccount> list = adYoukuAccountService.selectAdYoukuAccountList(adYoukuAccount);
        return getDataTable(list);
    }

    /**
     * 导出优酷广告账号列表
     */
    @PreAuthorize("@ss.hasPermi('ad:AdYouKuaccount:export')")
    @Log(title = "优酷广告账号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdYoukuAccount adYoukuAccount)
    {
        List<AdYoukuAccount> list = adYoukuAccountService.selectAdYoukuAccountList(adYoukuAccount);
        ExcelUtil<AdYoukuAccount> util = new ExcelUtil<AdYoukuAccount>(AdYoukuAccount.class);
        return util.exportExcel(list, "优酷广告账号数据");
    }

    /**
     * 获取优酷广告账号详细信息
     */
    @PreAuthorize("@ss.hasPermi('ad:AdYouKuaccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adYoukuAccountService.selectAdYoukuAccountById(id));
    }

    /**
     * 新增优酷广告账号
     */
    @PreAuthorize("@ss.hasPermi('ad:AdYouKuaccount:add')")
    @Log(title = "优酷广告账号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdYoukuAccount adYoukuAccount)
    {
        return toAjax(adYoukuAccountService.insertAdYoukuAccount(adYoukuAccount));
    }

    /**
     * 修改优酷广告账号
     */
    @PreAuthorize("@ss.hasPermi('ad:AdYouKuaccount:edit')")
    @Log(title = "优酷广告账号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdYoukuAccount adYoukuAccount)
    {
        return toAjax(adYoukuAccountService.updateAdYoukuAccount(adYoukuAccount));
    }

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