package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WyPlatformActivity;
import com.ruoyi.system.service.IWyPlatformActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营销活动Controller
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@Api(tags = "平台活动信息")
@RestController
@RequestMapping("/system/activity")
public class WyPlatformActivityController extends BaseController
{
    @Autowired
    private IWyPlatformActivityService wyPlatformActivityService;

    /**
     * 查询营销活动列表
     */
    @ApiOperation(value = "查询营销活动列表", notes = "查询营销活动列表")
    @PreAuthorize("@ss.hasPermi('system:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyPlatformActivity wyPlatformActivity)
    {
        startPage();
        List<WyPlatformActivity> list = wyPlatformActivityService.selectWyPlatformActivityList(wyPlatformActivity);
        return getDataTable(list);
    }

    /**
     * 查询全部营销活动列表
     */
    @ApiOperation(value = "查询全部营销活动列表", notes = "查询全部营销活动列表")
    @PreAuthorize("@ss.hasPermi('system:activity:list')")
    @GetMapping("/allList")
    public AjaxResult allList(WyPlatformActivity wyPlatformActivity)
    {
        List<WyPlatformActivity> list = wyPlatformActivityService.selectWyPlatformActivityList(wyPlatformActivity);
        return AjaxResult.success(list);
    }

    /**
     * 导出营销活动列表
     */
//    @ApiOperation(value = "导出营销活动列表", notes = "导出营销活动列表")
//    @PreAuthorize("@ss.hasPermi('system:activity:export')")
//    @Log(title = "营销活动", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, WyPlatformActivity wyPlatformActivity)
//    {
//        List<WyPlatformActivity> list = wyPlatformActivityService.selectWyPlatformActivityList(wyPlatformActivity);
//        ExcelUtil<WyPlatformActivity> util = new ExcelUtil<WyPlatformActivity>(WyPlatformActivity.class);
//        util.exportExcel(response, list, "营销活动数据");
//    }

    /**
     * 获取营销活动详细信息
     */
    @ApiOperation(value = "获取营销活动详细信息", notes = "获取营销活动详细信息")
    @PreAuthorize("@ss.hasPermi('system:activity:query')")


    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyPlatformActivityService.selectWyPlatformActivityById(id));
    }

    /**
     * 新增营销活动
     */
    @ApiOperation(value = "新增营销活动", notes = "新增营销活动")
    @PreAuthorize("@ss.hasPermi('system:activity:add')")
    @Log(title = "营销活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyPlatformActivity wyPlatformActivity)
    {
        return toAjax(wyPlatformActivityService.insertWyPlatformActivity(wyPlatformActivity));
    }

    /**
     * 修改营销活动
     */
    @ApiOperation(value = "修改营销活动", notes = "修改营销活动")
    @PreAuthorize("@ss.hasPermi('system:activity:edit')")
    @Log(title = "营销活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyPlatformActivity wyPlatformActivity)
    {
        return toAjax(wyPlatformActivityService.updateWyPlatformActivity(wyPlatformActivity));
    }

    /**
     * 删除营销活动
     */
    @ApiOperation(value = "删除营销活动", notes = "删除营销活动")
    @PreAuthorize("@ss.hasPermi('system:activity:remove')")
    @Log(title = "营销活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyPlatformActivityService.deleteWyPlatformActivityByIds(ids));
    }
}
