package com.ruoyi.frequency.advertisingimages.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.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.frequency.advertisingimages.entity.AdvertisingImages;
import com.ruoyi.frequency.advertisingimages.service.AdvertisingImagesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广告图Controller
 *
 * @author liwenlong
 * @date 2024-02-05
 */
@RestController
@RequestMapping("/frequency/advertisingimages")
public class AdvertisingImagesController extends BaseController
{
    @Autowired
    private AdvertisingImagesService advertisingImagesService;

    /**
     * 查询广告图列表
     */
    //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:list')")
    @PostMapping("/list")
    public TableDataInfo<AdvertisingImages> list(@RequestBody AdvertisingImages advertisingImages)
    {
        startPage();
        List<AdvertisingImages> list = advertisingImagesService.selectAdvertisingImagesList(advertisingImages);
        return getDataTable(list);
    }

    /**
     * 导出广告图列表
     */
    //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:export')")
    @Log(title = "广告图", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdvertisingImages advertisingImages)
    {
        List<AdvertisingImages> list = advertisingImagesService.selectAdvertisingImagesList(advertisingImages);
        ExcelUtil<AdvertisingImages> util = new ExcelUtil<AdvertisingImages>(AdvertisingImages.class);
        return util.exportExcel(list, "广告图数据");
    }

    /**
     * 获取广告图详细信息
     */
    //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<AdvertisingImages> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(advertisingImagesService.selectAdvertisingImagesById(id));
    }

    /**
     * 新增广告图
     */
    //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:add')")
    @Log(title = "广告图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdvertisingImages advertisingImages)
    {
        return toAjax(advertisingImagesService.insertAdvertisingImages(advertisingImages));
    }

    /**
     * 修改广告图
     */
    //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:edit')")
    @Log(title = "广告图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdvertisingImages advertisingImages)
    {
        return toAjax(advertisingImagesService.updateAdvertisingImages(advertisingImages));
    }

    /**
     * 删除广告图
     */
    //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:remove')")
    @Log(title = "广告图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(advertisingImagesService.deleteAdvertisingImagesByIds(ids,delFlag));
    }
}
