package com.yijia.station.controller;

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.yijia.common.annotation.Log;
import com.yijia.common.core.controller.BaseController;
import com.yijia.common.core.domain.AjaxResult;
import com.yijia.common.enums.BusinessType;
import com.yijia.station.domain.StationClassStructure;
import com.yijia.station.service.IStationClassStructureService;
import com.yijia.common.utils.poi.ExcelUtil;
import com.yijia.common.core.page.TableDataInfo;

/**
 * 班结管理Controller
 * 
 * @author yijia
 * @date 2020-12-14
 */
@RestController
@RequestMapping("/station/structure")
public class StationClassStructureController extends BaseController
{
    @Autowired
    private IStationClassStructureService stationClassStructureService;

    /**
     * 查询班结管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:structure:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationClassStructure stationClassStructure)
    {
        startPage();
        List<StationClassStructure> list = stationClassStructureService.selectStationClassStructureList(stationClassStructure);
        return getDataTable(list);
    }

    /**
     * 导出班结管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:structure:export')")
    @Log(title = "班结管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StationClassStructure stationClassStructure)
    {
        List<StationClassStructure> list = stationClassStructureService.selectStationClassStructureList(stationClassStructure);
        ExcelUtil<StationClassStructure> util = new ExcelUtil<StationClassStructure>(StationClassStructure.class);
        return util.exportExcel(list, "structure");
    }

    /**
     * 获取班结管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:structure:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stationClassStructureService.selectStationClassStructureById(id));
    }

    /**
     * 新增班结管理
     */
    @PreAuthorize("@ss.hasPermi('station:structure:add')")
    @Log(title = "班结管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationClassStructure stationClassStructure)
    {
        return toAjax(stationClassStructureService.insertStationClassStructure(stationClassStructure));
    }

    /**
     * 修改班结管理
     */
    @PreAuthorize("@ss.hasPermi('station:structure:edit')")
    @Log(title = "班结管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationClassStructure stationClassStructure)
    {
        return toAjax(stationClassStructureService.updateStationClassStructure(stationClassStructure));
    }

    /**
     * 删除班结管理
     */
    @PreAuthorize("@ss.hasPermi('station:structure:remove')")
    @Log(title = "班结管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stationClassStructureService.deleteStationClassStructureByIds(ids));
    }
}
