FleetLineTemplateController.java 3.85 KB
package com.ruoyi.template.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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 com.ruoyi.template.domain.FleetLineTemplate;
import com.ruoyi.template.service.IFleetLineTemplateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车队与线路对应模板Controller
 * 
 * @author guzijian
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/template/template")
public class FleetLineTemplateController extends BaseController
{
    @Autowired
    private IFleetLineTemplateService fleetLineTemplateService;

    /**
     * 查询车队与线路对应模板列表
     */
    @PreAuthorize("@ss.hasPermi('template:template:list')")
    @GetMapping("/list")
    public TableDataInfo list(FleetLineTemplate fleetLineTemplate)
    {
        startPage();
        List<FleetLineTemplate> list = fleetLineTemplateService.selectFleetLineTemplateList(fleetLineTemplate);
        return getDataTable(list);
    }

    /**
     * 导出车队与线路对应模板列表
     */
    @PreAuthorize("@ss.hasPermi('template:template:export')")
    @Log(title = "车队与线路对应模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FleetLineTemplate fleetLineTemplate)
    {
        List<FleetLineTemplate> list = fleetLineTemplateService.selectFleetLineTemplateList(fleetLineTemplate);
        ExcelUtil<FleetLineTemplate> util = new ExcelUtil<FleetLineTemplate>(FleetLineTemplate.class);
        util.exportExcel(response, list, "车队与线路对应模板数据");
    }

    /**
     * 获取车队与线路对应模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('template:template:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(fleetLineTemplateService.selectFleetLineTemplateById(id));
    }

    /**
     * 新增车队与线路对应模板
     */
    @PreAuthorize("@ss.hasPermi('template:template:add')")
    @Log(title = "车队与线路对应模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FleetLineTemplate fleetLineTemplate)
    {
        return toAjax(fleetLineTemplateService.insertFleetLineTemplate(fleetLineTemplate));
    }

    /**
     * 修改车队与线路对应模板
     */
    @PreAuthorize("@ss.hasPermi('template:template:edit')")
    @Log(title = "车队与线路对应模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FleetLineTemplate fleetLineTemplate)
    {
        return toAjax(fleetLineTemplateService.updateFleetLineTemplate(fleetLineTemplate));
    }

    /**
     * 删除车队与线路对应模板
     */
    @PreAuthorize("@ss.hasPermi('template:template:remove')")
    @Log(title = "车队与线路对应模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(fleetLineTemplateService.deleteFleetLineTemplateByIds(ids));
    }
}