package beilv.venue.controller;

import java.util.List;

import beilv.venue.domain.BeilvVenue;
import beilv.venue.service.IBeilvVenueService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import beilv.common.annotation.Log;
import beilv.common.enums.BusinessType;

import beilv.common.core.controller.BaseController;
import beilv.common.core.domain.AjaxResult;
import beilv.common.utils.poi.ExcelUtil;
import beilv.common.core.page.TableDataInfo;

/**
 * 场馆信息Controller
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@Controller
@RequestMapping("/system/venue")
public class BeilvVenueController extends BaseController
{
    private String prefix = "system/venue";

    @Autowired
    private IBeilvVenueService beilvVenueService;

    @RequiresPermissions("system:venue:view")
    @GetMapping()
    public String venue()
    {
        return prefix + "/venue";
    }

    /**
     * 查询场馆信息列表
     */
    @RequiresPermissions("system:venue:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BeilvVenue beilvVenue)
    {
        startPage();
        List<BeilvVenue> list = beilvVenueService.selectBeilvVenueList(beilvVenue);
        return getDataTable(list);
    }

    /**
     * 导出场馆信息列表
     */
    @RequiresPermissions("system:venue:export")
    @Log(title = "场馆信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BeilvVenue beilvVenue)
    {
        List<BeilvVenue> list = beilvVenueService.selectBeilvVenueList(beilvVenue);
        ExcelUtil<BeilvVenue> util = new ExcelUtil<BeilvVenue>(BeilvVenue.class);
        return util.exportExcel(list, "场馆信息数据");
    }

    /**
     * 新增场馆信息
     */
    @RequiresPermissions("system:venue:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存场馆信息
     */
    @RequiresPermissions("system:venue:add")
    @Log(title = "场馆信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BeilvVenue beilvVenue)
    {
        return toAjax(beilvVenueService.insertBeilvVenue(beilvVenue));
    }

    /**
     * 修改场馆信息
     */
    @RequiresPermissions("system:venue:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BeilvVenue beilvVenue = beilvVenueService.selectBeilvVenueById(id);
        mmap.put("beilvVenue", beilvVenue);
        return prefix + "/edit";
    }

    /**
     * 修改保存场馆信息
     */
    @RequiresPermissions("system:venue:edit")
    @Log(title = "场馆信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BeilvVenue beilvVenue)
    {
        return toAjax(beilvVenueService.updateBeilvVenue(beilvVenue));
    }

    /**
     * 删除场馆信息
     */
    @RequiresPermissions("system:venue:remove")
    @Log(title = "场馆信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(beilvVenueService.deleteBeilvVenueByIds(ids));
    }
}
