package com.fs.ad.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.ad.domain.AdDyAccount;
import com.fs.ad.service.IAdDyAccountService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 抖音账户Controller
 * 
 * @author 吴树波
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/ad/AdDyAccount")
public class AdDyAccountController extends BaseController
{
    @Autowired
    private IAdDyAccountService adDyAccountService;

    /**
     * 查询抖音账户列表
     */
    @PreAuthorize("@ss.hasPermi('ad:AdDyAccount:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdDyAccount adDyAccount)
    {
        startPage();
        List<AdDyAccount> list = adDyAccountService.selectAdDyAccountList(adDyAccount);
        return getDataTable(list);
    }

    /**
     * 导出抖音账户列表
     */
    @PreAuthorize("@ss.hasPermi('ad:AdDyAccount:export')")
    @Log(title = "抖音账户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdDyAccount adDyAccount)
    {
        List<AdDyAccount> list = adDyAccountService.selectAdDyAccountList(adDyAccount);
        ExcelUtil<AdDyAccount> util = new ExcelUtil<AdDyAccount>(AdDyAccount.class);
        return util.exportExcel(list, "抖音账户数据");
    }

    /**
     * 获取抖音账户详细信息
     */
    @PreAuthorize("@ss.hasPermi('ad:AdDyAccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adDyAccountService.selectAdDyAccountById(id));
    }

    /**
     * 新增抖音账户
     */
    @PreAuthorize("@ss.hasPermi('ad:AdDyAccount:add')")
    @Log(title = "抖音账户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdDyAccount adDyAccount)
    {
        return toAjax(adDyAccountService.insertAdDyAccount(adDyAccount));
    }

    /**
     * 修改抖音账户
     */
    @PreAuthorize("@ss.hasPermi('ad:AdDyAccount:edit')")
    @Log(title = "抖音账户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdDyAccount adDyAccount)
    {
        return toAjax(adDyAccountService.updateAdDyAccount(adDyAccount));
    }

    /**
     * 删除抖音账户
     */
    @PreAuthorize("@ss.hasPermi('ad:AdDyAccount:remove')")
    @Log(title = "抖音账户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adDyAccountService.deleteAdDyAccountByIds(ids));
    }
}
