package com.ruoyi.cms.controller.cms;

import java.util.List;

import com.ruoyi.common.annotation.BussinessLog;
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.SubwayLine;
import com.ruoyi.cms.service.ISubwayLineService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地铁线路Controller
 * 
 * @author Lishundong
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/cms/line")
@Api(tags = "后台：地铁线路")
public class SubwayLineController extends BaseController
{
    @Autowired
    private ISubwayLineService subwayLineService;

    /**
     * 查询地铁线路列表
     */
    @ApiOperation("查询地铁线路列表")
    @GetMapping("/list")
    @BussinessLog(title = "查询地铁线路列表", businessType = BusinessType.CLEAN)
    public TableDataInfo list(SubwayLine subwayLine)
    {
        startPage();
        List<SubwayLine> list = subwayLineService.selectSubwayLineList(subwayLine);
        return getDataTable(list);
    }


    /**
     * 获取地铁线路详细信息
     */
    @ApiOperation("获取地铁线路详细信息")
    @PreAuthorize("@ss.hasPermi('system:line:query')")
    @GetMapping(value = "/{lineId}")
    public AjaxResult getInfo(@PathVariable("lineId") Long lineId)
    {
        return success(subwayLineService.selectSubwayLineByLineId(lineId));
    }

    /**
     * 新增地铁线路
     */
    @ApiOperation("新增地铁线路")
    @PreAuthorize("@ss.hasPermi('system:line:add')")
    @Log(title = "地铁线路", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubwayLine subwayLine)
    {
        return toAjax(subwayLineService.insertSubwayLine(subwayLine));
    }

    /**
     * 修改地铁线路
     */
    @ApiOperation("修改地铁线路")
    @PreAuthorize("@ss.hasPermi('system:line:edit')")
    @Log(title = "地铁线路", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubwayLine subwayLine)
    {
        return toAjax(subwayLineService.updateSubwayLine(subwayLine));
    }

    /**
     * 删除地铁线路
     */
    @ApiOperation("删除地铁线路")
    @PreAuthorize("@ss.hasPermi('system:line:remove')")
    @Log(title = "地铁线路", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lineId}")
    public AjaxResult remove(@PathVariable Long lineId)
    {
        return toAjax(subwayLineService.deleteSubwayLineByLineIds(lineId));
    }
}
