package com.fs.ad.controller;

import java.util.List;

import com.fs.common.core.domain.R;
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.AdHtmlTemplate;
import com.fs.ad.service.IAdHtmlTemplateService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 广告信息流链接Controller
 * 
 * @author fs
 * @date 2024-12-31
 */
@RestController
@RequestMapping("/ad/html/template")
public class AdHtmlTemplateController extends BaseController
{
    @Autowired
    private IAdHtmlTemplateService adHtmlUrlService;

    /**
     * 查询广告信息流链接列表
     */
    @PreAuthorize("@ss.hasPermi('ad:html:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdHtmlTemplate adHtmlTemplate)
    {
        startPage();
        List<AdHtmlTemplate> list = adHtmlUrlService.selectAdHtmlUrlList(adHtmlTemplate);
        return getDataTable(list);
    }

    /**
     * 导出广告信息流链接列表
     */
    @PreAuthorize("@ss.hasPermi('ad:html:export')")
    @Log(title = "广告信息流链接", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdHtmlTemplate adHtmlTemplate)
    {
        List<AdHtmlTemplate> list = adHtmlUrlService.selectAdHtmlUrlList(adHtmlTemplate);
        ExcelUtil<AdHtmlTemplate> util = new ExcelUtil<AdHtmlTemplate>(AdHtmlTemplate.class);
        return util.exportExcel(list, "广告信息流链接数据");
    }

    /**
     * 获取广告信息流链接详细信息
     */
    @PreAuthorize("@ss.hasPermi('ad:html:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adHtmlUrlService.selectAdHtmlUrlById(id));
    }

    /**
     * 新增广告信息流链接
     */
    @PreAuthorize("@ss.hasPermi('ad:html:add')")
    @Log(title = "广告信息流链接", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdHtmlTemplate adHtmlTemplate)
    {
        return toAjax(adHtmlUrlService.insertAdHtmlUrl(adHtmlTemplate));
    }

    /**
     * 修改广告信息流链接
     */
    @PreAuthorize("@ss.hasPermi('ad:html:edit')")
    @Log(title = "广告信息流链接", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdHtmlTemplate adHtmlTemplate)
    {
        return toAjax(adHtmlUrlService.updateAdHtmlUrl(adHtmlTemplate));
    }

    /**
     * 删除广告信息流链接
     */
    @PreAuthorize("@ss.hasPermi('ad:html:remove')")
    @Log(title = "广告信息流链接", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adHtmlUrlService.deleteAdHtmlUrlByIds(ids));
    }

    @GetMapping(value = "/listAll")
    public R listAll(){
        return R.ok().put("data", adHtmlUrlService.list());
    }
}
