package com.fs.ad.controller;

import java.util.List;

import com.fs.ad.vo.DyAuthorizedVo;
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.AdDyApi;
import com.fs.ad.service.IAdDyApiService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 抖音投流API信息Controller
 * 
 * @author 吴树波
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/ad/adDyApi")
public class AdDyApiController extends BaseController
{
    @Autowired
    private IAdDyApiService adDyApiService;

    /**
     * 查询抖音投流API信息列表
     */
    @PreAuthorize("@ss.hasPermi('ad:adDyApi:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdDyApi adDyApi)
    {
        startPage();
        List<AdDyApi> list = adDyApiService.selectAdDyApiList(adDyApi);
        return getDataTable(list);
    }

    /**
     * 导出抖音投流API信息列表
     */
    @PreAuthorize("@ss.hasPermi('ad:adDyApi:export')")
    @Log(title = "抖音投流API信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdDyApi adDyApi)
    {
        List<AdDyApi> list = adDyApiService.selectAdDyApiList(adDyApi);
        ExcelUtil<AdDyApi> util = new ExcelUtil<AdDyApi>(AdDyApi.class);
        return util.exportExcel(list, "抖音投流API信息数据");
    }

    /**
     * 获取抖音投流API信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ad:adDyApi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adDyApiService.selectAdDyApiById(id));
    }

    /**
     * 新增抖音投流API信息
     */
    @PreAuthorize("@ss.hasPermi('ad:adDyApi:add')")
    @Log(title = "抖音投流API信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdDyApi adDyApi)
    {
        return toAjax(adDyApiService.insertAdDyApi(adDyApi));
    }

    /**
     * 修改抖音投流API信息
     */
    @PreAuthorize("@ss.hasPermi('ad:adDyApi:edit')")
    @Log(title = "抖音投流API信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdDyApi adDyApi)
    {
        return toAjax(adDyApiService.updateAdDyApi(adDyApi));
    }

    /**
     * 删除抖音投流API信息
     */
    @PreAuthorize("@ss.hasPermi('ad:adDyApi:remove')")
    @Log(title = "抖音投流API信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adDyApiService.deleteAdDyApiByIds(ids));
    }
    /**
     * 删除抖音投流API信息
     */
    @Log(title = "抖音API授权", businessType = BusinessType.UPDATE)
	@GetMapping("/authorized")
    public String authorized(DyAuthorizedVo vo){
        System.out.println(vo);
        return "授权成功";
    }
}
