package com.fs.ad.controller;

import com.fs.ad.domain.AdHtmlClickLog;
import com.fs.ad.service.IAdHtmlClickLogService;
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.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-01-09
 */
@RestController
@RequestMapping("/ad/clickLog")
public class AdHtmlClickLogController extends BaseController
{
    @Autowired
    private IAdHtmlClickLogService adHtmlClickLogService;

    /**
     * 查询广告点击列表
     */
    @PreAuthorize("@ss.hasPermi('ad:clickLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdHtmlClickLog adHtmlClickLog)
    {
        startPage();
        List<AdHtmlClickLog> list = adHtmlClickLogService.selectAdHtmlClickLogList(adHtmlClickLog);
        return getDataTable(list);
    }

    /**
     * 导出广告点击列表
     */
    @PreAuthorize("@ss.hasPermi('ad:clickLog:export')")
    @Log(title = "广告点击", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdHtmlClickLog adHtmlClickLog)
    {
        List<AdHtmlClickLog> list = adHtmlClickLogService.selectAdHtmlClickLogList(adHtmlClickLog);
        ExcelUtil<AdHtmlClickLog> util = new ExcelUtil<AdHtmlClickLog>(AdHtmlClickLog.class);
        return util.exportExcel(list, "广告点击数据");
    }

    /**
     * 获取广告点击详细信息
     */
    @PreAuthorize("@ss.hasPermi('ad:clickLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adHtmlClickLogService.selectAdHtmlClickLogById(id));
    }

    /**
     * 新增广告点击
     */
    @PreAuthorize("@ss.hasPermi('ad:clickLog:add')")
    @Log(title = "广告点击", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdHtmlClickLog adHtmlClickLog)
    {
        return toAjax(adHtmlClickLogService.insertAdHtmlClickLog(adHtmlClickLog));
    }

    /**
     * 修改广告点击
     */
    @PreAuthorize("@ss.hasPermi('ad:clickLog:edit')")
    @Log(title = "广告点击", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdHtmlClickLog adHtmlClickLog)
    {
        return toAjax(adHtmlClickLogService.updateAdHtmlClickLog(adHtmlClickLog));
    }

    /**
     * 删除广告点击
     */
    @PreAuthorize("@ss.hasPermi('ad:clickLog:remove')")
    @Log(title = "广告点击", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adHtmlClickLogService.deleteAdHtmlClickLogByIds(ids));
    }
}
