package com.ruoyi.frequency.workspanorama.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.frequency.workspanorama.entity.WorksPanorama;
import com.ruoyi.frequency.workspanorama.service.WorksPanoramaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 作品和全景图关联Controller
 * 
 * @author zj
 * @date 2023-09-22
 */
@RestController
@RequestMapping("/frequency/workspanorama")
public class WorksPanoramaController extends BaseController
{
    @Autowired
    private WorksPanoramaService worksPanoramaService;

    /**
     * 查询作品和全景图关联列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:workspanorama:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorksPanorama worksPanorama)
    {
        startPage();
        List<WorksPanorama> list = worksPanoramaService.selectWorksPanoramaList(worksPanorama);
        return getDataTable(list);
    }

    /**
     * 导出作品和全景图关联列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:workspanorama:export')")
    @Log(title = "作品和全景图关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorksPanorama worksPanorama)
    {
        List<WorksPanorama> list = worksPanoramaService.selectWorksPanoramaList(worksPanorama);
        ExcelUtil<WorksPanorama> util = new ExcelUtil<WorksPanorama>(WorksPanorama.class);
        return util.exportExcel(list, "作品和全景图关联数据");
    }

    /**
     * 获取作品和全景图关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:workspanorama:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(worksPanoramaService.selectWorksPanoramaById(id));
    }

    /**
     * 新增作品和全景图关联
     */
    @PreAuthorize("@ss.hasPermi('frequency:workspanorama:add')")
    @Log(title = "作品和全景图关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorksPanorama worksPanorama)
    {
        return toAjax(worksPanoramaService.insertWorksPanorama(worksPanorama));
    }

    /**
     * 修改作品和全景图关联
     */
    @PreAuthorize("@ss.hasPermi('frequency:workspanorama:edit')")
    @Log(title = "作品和全景图关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorksPanorama worksPanorama)
    {
        return toAjax(worksPanoramaService.updateWorksPanorama(worksPanorama));
    }

    /**
     * 删除作品和全景图关联
     */
    @PreAuthorize("@ss.hasPermi('frequency:workspanorama:remove')")
    @Log(title = "作品和全景图关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(worksPanoramaService.deleteWorksPanoramaByIds(ids));
    }
}
