package com.jianshui.web.controller.platform;

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.jianshui.common.annotation.Log;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.enums.BusinessType;
import com.jianshui.platform.domain.VehicleCode;
import com.jianshui.platform.service.IVehicleCodeService;
import com.jianshui.common.utils.poi.ExcelUtil;
import com.jianshui.common.core.page.TableDataInfo;

/**
 * 车辆编码Controller
 * 
 * @author kk
 * @date 2023-06-28
 */
@RestController
@RequestMapping("/platform/vehiclecode")
public class VehicleCodeController extends BaseController
{
    @Autowired
    private IVehicleCodeService vehicleCodeService;

    /**
     * 查询车辆编码列表
     */
    @PreAuthorize("@ss.hasPermi('platform:vehiclecode:list')")
    @GetMapping("/list")
    public TableDataInfo list(VehicleCode vehicleCode)
    {
        startPage();
        List<VehicleCode> list = vehicleCodeService.selectVehicleCodeList(vehicleCode);
        return getDataTable(list);
    }

    /**
     * 导出车辆编码列表
     */
    @PreAuthorize("@ss.hasPermi('platform:vehiclecode:export')")
    @Log(title = "车辆编码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VehicleCode vehicleCode)
    {
        List<VehicleCode> list = vehicleCodeService.selectVehicleCodeList(vehicleCode);
        ExcelUtil<VehicleCode> util = new ExcelUtil<VehicleCode>(VehicleCode.class);
        util.exportExcel(response, list, "车辆编码数据");
    }

    /**
     * 获取车辆编码详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:vehiclecode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vehicleCodeService.selectVehicleCodeById(id));
    }

    /**
     * 新增车辆编码
     */
    @PreAuthorize("@ss.hasPermi('platform:vehiclecode:add')")
    @Log(title = "车辆编码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VehicleCode vehicleCode)
    {
        return toAjax(vehicleCodeService.insertVehicleCode(vehicleCode));
    }

    /**
     * 修改车辆编码
     */
    @PreAuthorize("@ss.hasPermi('platform:vehiclecode:edit')")
    @Log(title = "车辆编码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VehicleCode vehicleCode)
    {
        return toAjax(vehicleCodeService.updateVehicleCode(vehicleCode));
    }

    /**
     * 删除车辆编码
     */
    @PreAuthorize("@ss.hasPermi('platform:vehiclecode:remove')")
    @Log(title = "车辆编码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vehicleCodeService.deleteVehicleCodeByIds(ids));
    }
}
