package com.ruoyi.cms.controller.cms;

import java.util.List;

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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.cms.domain.SubwayStation;
import com.ruoyi.cms.service.ISubwayStationService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地铁站点Controller
 * 
 * @author Lishundong
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/cms/station")
@Api(tags = "后台：地铁站点")
public class SubwayStationController extends BaseController
{
    @Autowired
    private ISubwayStationService subwayStationService;

    /**
     * 查询地铁站点列表
     */
    @ApiOperation("查询地铁站点列表")
    @GetMapping("/list")
    public TableDataInfo list(SubwayStation subwayStation)
    {
        startPage();
        List<SubwayStation> list = subwayStationService.selectSubwayStationList(subwayStation);
        return getDataTable(list);
    }


    /**
     * 获取地铁站点详细信息
     */
    @ApiOperation("获取地铁站点详细信息")
    @PreAuthorize("@ss.hasPermi('system:station:query')")
    @GetMapping(value = "/{stationId}")
    public AjaxResult getInfo(@PathVariable("stationId") Long stationId)
    {
        return success(subwayStationService.selectSubwayStationByStationId(stationId));
    }

    /**
     * 新增地铁站点
     */
    @ApiOperation("新增地铁站点")
    @PreAuthorize("@ss.hasPermi('system:station:add')")
    @Log(title = "地铁站点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubwayStation subwayStation)
    {
        return toAjax(subwayStationService.insertSubwayStation(subwayStation));
    }

    /**
     * 修改地铁站点
     */
    @ApiOperation("修改地铁站点")
    @PreAuthorize("@ss.hasPermi('system:station:edit')")
    @Log(title = "地铁站点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubwayStation subwayStation)
    {
        return toAjax(subwayStationService.updateSubwayStation(subwayStation));
    }

    /**
     * 删除地铁站点
     */
    @ApiOperation("删除地铁站点")
    @PreAuthorize("@ss.hasPermi('system:station:remove')")
    @Log(title = "地铁站点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stationIds}")
    public AjaxResult remove(@PathVariable Long[] stationIds)
    {
        return toAjax(subwayStationService.deleteSubwayStationByStationIds(stationIds));
    }
    @GetMapping("/import")
    public AjaxResult importStation(){
        subwayStationService.importStation();
        return success();
    }
}
