package com.songhua.web.controller.system;

import com.songhua.common.annotation.Log;
import com.songhua.common.core.controller.BaseController;
import com.songhua.common.core.domain.AjaxResult;
import com.songhua.common.core.page.TableDataInfo;
import com.songhua.common.enums.BusinessType;
import com.songhua.common.utils.poi.ExcelUtil;
import com.songhua.system.domain.BasicCruiseShip;
import com.songhua.system.service.IBasicCruiseShipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 游船基本信息
 * 
 * @author ruoyi
 * @date 2024-04-23
 */
@RestController
@RequestMapping("/system/ship")
public class BasicCruiseShipController extends BaseController
{
    @Autowired
    private IBasicCruiseShipService basicCruiseShipService;

    /**
     * 查询游船列表
     */
    @PreAuthorize("@ss.hasPermi('system:ship:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicCruiseShip basicCruiseShip)
    {
        startPage();
        List<BasicCruiseShip> list = basicCruiseShipService.selectBasicCruiseShipList(basicCruiseShip);
        return getDataTable(list);
    }

    /**
     * 导出游船列表
     */
    @PreAuthorize("@ss.hasPermi('system:ship:export')")
    @Log(title = "导出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicCruiseShip basicCruiseShip)
    {
        List<BasicCruiseShip> list = basicCruiseShipService.selectBasicCruiseShipList(basicCruiseShip);
        ExcelUtil<BasicCruiseShip> util = new ExcelUtil<BasicCruiseShip>(BasicCruiseShip.class);
        util.exportExcel(response, list, "游船数据");
    }

    /**
     * 获取游船详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ship:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basicCruiseShipService.selectBasicCruiseShipById(id));
    }

    /**
     * 新增游船
     */
    @PreAuthorize("@ss.hasPermi('system:ship:add')")
    @Log(title = "新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicCruiseShip basicCruiseShip)
    {
        return toAjax(basicCruiseShipService.insertBasicCruiseShip(basicCruiseShip));
    }

    /**
     * 修改游船
     */
    @PreAuthorize("@ss.hasPermi('system:ship:edit')")
    @Log(title = "修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicCruiseShip basicCruiseShip)
    {
        return toAjax(basicCruiseShipService.updateBasicCruiseShip(basicCruiseShip));
    }

    /**
     * 删除游船
     */
    @PreAuthorize("@ss.hasPermi('system:ship:remove')")
    @Log(title = "删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basicCruiseShipService.deleteBasicCruiseShipByIds(ids));
    }
}
