package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.SysScenicDefault;
import com.ruoyi.system.service.ISysScenicDefaultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 各景区默认配置Controller
 * 
 * @author haotian
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/system/default")
public class SysScenicDefaultController extends BaseController
{
    @Autowired
    private ISysScenicDefaultService sysScenicDefaultService;

    /**
     * 查询各景区默认配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:default:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysScenicDefault sysScenicDefault)
    {
        startPage();
        List<SysScenicDefault> list = sysScenicDefaultService.selectSysScenicDefaultList(sysScenicDefault);
        return getDataTable(list);
    }

    /**
     * 导出各景区默认配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:default:export')")
    @Log(title = "各景区默认配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysScenicDefault sysScenicDefault)
    {
        List<SysScenicDefault> list = sysScenicDefaultService.selectSysScenicDefaultList(sysScenicDefault);
        ExcelUtil<SysScenicDefault> util = new ExcelUtil<SysScenicDefault>(SysScenicDefault.class);
        util.exportExcel(response, list, "各景区默认配置数据");
    }

    /**
     * 获取各景区默认配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:default:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysScenicDefaultService.selectSysScenicDefaultById(id));
    }

    /**
     * 新增各景区默认配置
     */
    @PreAuthorize("@ss.hasPermi('system:default:add')")
    @Log(title = "各景区默认配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysScenicDefault sysScenicDefault)
    {
        return toAjax(sysScenicDefaultService.insertSysScenicDefault(sysScenicDefault));
    }

    /**
     * 修改各景区默认配置
     */
    @PreAuthorize("@ss.hasPermi('system:default:edit')")
    @Log(title = "各景区默认配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysScenicDefault sysScenicDefault)
    {
        return toAjax(sysScenicDefaultService.updateSysScenicDefault(sysScenicDefault));
    }

    /**
     * 删除各景区默认配置
     */
    @PreAuthorize("@ss.hasPermi('system:default:remove')")
    @Log(title = "各景区默认配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysScenicDefaultService.deleteSysScenicDefaultByIds(ids));
    }
}
