package com.zg.project.information.controller;

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

import com.zg.project.information.domain.SceneMapping;
import com.zg.project.information.service.ISceneMappingService;
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.zg.framework.aspectj.lang.annotation.Log;
import com.zg.framework.aspectj.lang.enums.BusinessType;
import com.zg.framework.web.controller.BaseController;
import com.zg.framework.web.domain.AjaxResult;
import com.zg.common.utils.poi.ExcelUtil;
import com.zg.framework.web.page.TableDataInfo;

/**
 * 场景编号Controller
 * 
 * @author zg
 * @date 2025-05-24
 */
@RestController
@RequestMapping("/information/scene")
public class SceneMappingController extends BaseController
{
    @Autowired
    private ISceneMappingService sceneMappingService;

    /**
     * 查询场景编号列表
     */
    @PreAuthorize("@ss.hasPermi('information:scene:list')")
    @GetMapping("/list")
    public TableDataInfo list(SceneMapping sceneMapping)
    {
        startPage();
        List<SceneMapping> list = sceneMappingService.selectSceneMappingList(sceneMapping);
        return getDataTable(list);
    }

    /**
     * 查询场景编号列表
     * @return
     */
    @PreAuthorize("@ss.hasPermi('information:scene:list')")
    @GetMapping("/getAll")
    public AjaxResult getAll()
    {
        List<SceneMapping> list = sceneMappingService.selectSceneMappingList(new SceneMapping());
        return success(list);
    }

    /**
     * 导出场景编号列表
     */
    @PreAuthorize("@ss.hasPermi('information:scene:export')")
    @Log(title = "场景编号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SceneMapping sceneMapping)
    {
        List<SceneMapping> list = sceneMappingService.selectSceneMappingList(sceneMapping);
        ExcelUtil<SceneMapping> util = new ExcelUtil<SceneMapping>(SceneMapping.class);
        util.exportExcel(response, list, "场景编号数据");
    }

    /**
     * 获取场景编号详细信息
     */
    @PreAuthorize("@ss.hasPermi('information:scene:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sceneMappingService.selectSceneMappingById(id));
    }

    /**
     * 新增场景编号
     */
    @PreAuthorize("@ss.hasPermi('information:scene:add')")
    @Log(title = "场景编号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SceneMapping sceneMapping)
    {
        return toAjax(sceneMappingService.insertSceneMapping(sceneMapping));
    }

    /**
     * 修改场景编号
     */
    @PreAuthorize("@ss.hasPermi('information:scene:edit')")
    @Log(title = "场景编号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SceneMapping sceneMapping)
    {
        return toAjax(sceneMappingService.updateSceneMapping(sceneMapping));
    }

    /**
     * 删除场景编号
     */
    @PreAuthorize("@ss.hasPermi('information:scene:remove')")
    @Log(title = "场景编号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sceneMappingService.deleteSceneMappingByIds(ids));
    }
}
