package com.ruoyi.web.controller.brewery;

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.brewery.domain.WyBreweryBanner;
import com.ruoyi.brewery.service.IWyBreweryBannerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 品牌方广告图Controller
 * 
 * @author ruoyi
 * @date 2024-12-21
 */
@Api(tags = "品牌方广告图")
@RestController
@RequestMapping("/system/brewery/banner")
public class WyBreweryBannerController extends BaseController
{
    @Autowired
    private IWyBreweryBannerService wyBreweryBannerService;

    /**
     * 查询品牌方广告图列表
     */
    @ApiOperation("查询品牌方广告图列表")
    @PreAuthorize("@ss.hasPermi('brewery:banner:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBreweryBanner wyBreweryBanner)
    {
        startPage();
        List<WyBreweryBanner> list = wyBreweryBannerService.selectWyBreweryBannerList(wyBreweryBanner);
        return getDataTable(list);
    }

    /**
     * 导出品牌方广告图列表
     */
    @ApiOperation("导出品牌方广告图列表")
    @PreAuthorize("@ss.hasPermi('brewery:banner:export')")
    @Log(title = "品牌方广告图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBreweryBanner wyBreweryBanner)
    {
        List<WyBreweryBanner> list = wyBreweryBannerService.selectWyBreweryBannerList(wyBreweryBanner);
        ExcelUtil<WyBreweryBanner> util = new ExcelUtil<WyBreweryBanner>(WyBreweryBanner.class);
        util.exportExcel(response, list, "品牌方广告图数据");
    }

    /**
     * 获取品牌方广告图详细信息
     */
    @ApiOperation("获取品牌方广告图详细信息")
    @PreAuthorize("@ss.hasPermi('brewery:banner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyBreweryBannerService.selectWyBreweryBannerById(id));
    }

    /**
     * 新增品牌方广告图
     */
    @ApiOperation("新增品牌方广告图")
    @PreAuthorize("@ss.hasPermi('brewery:banner:add')")
    @Log(title = "品牌方广告图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBreweryBanner wyBreweryBanner)
    {
        return toAjax(wyBreweryBannerService.insertWyBreweryBanner(wyBreweryBanner));
    }

    /**
     * 修改品牌方广告图
     */
    @ApiOperation("修改品牌方广告图")
    @PreAuthorize("@ss.hasPermi('brewery:banner:edit')")
    @Log(title = "品牌方广告图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBreweryBanner wyBreweryBanner)
    {
        return toAjax(wyBreweryBannerService.updateWyBreweryBanner(wyBreweryBanner));
    }

    /**
     * 删除品牌方广告图
     */
    @ApiOperation("删除品牌方广告图")
    @PreAuthorize("@ss.hasPermi('brewery:banner:remove')")
    @Log(title = "品牌方广告图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyBreweryBannerService.deleteWyBreweryBannerByIds(ids));
    }
}
