package com.fs.course.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.course.domain.MarketPush;
import com.fs.course.service.IMarketPushService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 营销活动推送Controller
 * 
 * @author fs
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/push/push")
public class MarketPushController extends BaseController
{
    @Autowired
    private IMarketPushService marketPushService;

    /**
     * 查询营销活动推送列表
     */
    @PreAuthorize("@ss.hasPermi('push:push:list')")
    @GetMapping("/list")
    public TableDataInfo list(MarketPush marketPush)
    {
        startPage();
        List<MarketPush> list = marketPushService.selectMarketPushList(marketPush);
        return getDataTable(list);
    }

    /**
     * 导出营销活动推送列表
     */
    @PreAuthorize("@ss.hasPermi('push:push:export')")
    @Log(title = "营销活动推送", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MarketPush marketPush)
    {
        List<MarketPush> list = marketPushService.selectMarketPushList(marketPush);
        ExcelUtil<MarketPush> util = new ExcelUtil<MarketPush>(MarketPush.class);
        return util.exportExcel(list, "营销活动推送数据");
    }

    /**
     * 获取营销活动推送详细信息
     */
    @PreAuthorize("@ss.hasPermi('push:push:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(marketPushService.selectMarketPushById(id));
    }

    /**
     * 新增营销活动推送
     */
    @PreAuthorize("@ss.hasPermi('push:push:add')")
    @Log(title = "营销活动推送", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MarketPush marketPush)
    {
        return toAjax(marketPushService.insertMarketPush(marketPush));
    }

    /**
     * 修改营销活动推送
     */
    @PreAuthorize("@ss.hasPermi('push:push:edit')")
    @Log(title = "营销活动推送", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MarketPush marketPush)
    {
        return toAjax(marketPushService.updateMarketPush(marketPush));
    }

    /**
     * 删除营销活动推送
     */
    @PreAuthorize("@ss.hasPermi('push:push:remove')")
    @Log(title = "营销活动推送", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(marketPushService.deleteMarketPushByIds(ids));
    }
}
