package com.qaup.web.controller.system;

import java.util.List;
import jakarta.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.qaup.common.annotation.Log;
import com.qaup.common.core.controller.BaseController;
import com.qaup.common.core.domain.AjaxResult;
import com.qaup.common.enums.BusinessType;
import com.qaup.system.domain.SysDriverInfo;
import com.qaup.system.service.ISysDriverInfoService;
import com.qaup.common.utils.poi.ExcelUtil;
import com.qaup.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
/**
 * 驾驶员信息Controller
 * 
 * @author qaup
 * @date 2025-06-30
 */
@Tag(name = "驾驶员信息管理", description = "驾驶员信息管理")
@RestController
@RequestMapping("/system/driver_info")
public class SysDriverInfoController extends BaseController
{
    @Autowired
    private ISysDriverInfoService sysDriverInfoService;

    /**
     * 查询驾驶员信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:driver_info:list')")
    @Operation(summary = "查询驾驶员信息列表")
    @GetMapping("/list")
    public TableDataInfo list(SysDriverInfo sysDriverInfo)
    {
        startPage();
        List<SysDriverInfo> list = sysDriverInfoService.selectSysDriverInfoList(sysDriverInfo);
        return getDataTable(list);
    }

    /**
     * 导出驾驶员信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:driver_info:export')")
    @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT)
    @Operation(summary = "导出驾驶员信息列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDriverInfo sysDriverInfo)
    {
        List<SysDriverInfo> list = sysDriverInfoService.selectSysDriverInfoList(sysDriverInfo);
        ExcelUtil<SysDriverInfo> util = new ExcelUtil<SysDriverInfo>(SysDriverInfo.class);
        util.exportExcel(response, list, "驾驶员信息数据");
    }

    /**
     * 获取驾驶员信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:driver_info:query')")
    @Operation(summary = "获取驾驶员信息详细信息")
    @Parameter(name = "userId", description = "用户ID", required = true)
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(sysDriverInfoService.selectSysDriverInfoByUserId(userId));
    }

    /**
     * 新增驾驶员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:driver_info:add')")
    @Log(title = "驾驶员信息", businessType = BusinessType.INSERT)
    @Operation(summary = "新增驾驶员信息")
    @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "驾驶员信息对象", required = true, content = @Content(mediaType = "application/json", schema = @Schema(implementation = SysDriverInfo.class)))
    @PostMapping
    public AjaxResult add(@RequestBody SysDriverInfo sysDriverInfo)
    {
        return toAjax(sysDriverInfoService.insertSysDriverInfo(sysDriverInfo));
    }

    /**
     * 修改驾驶员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:driver_info:edit')")
    @Log(title = "驾驶员信息", businessType = BusinessType.UPDATE)
    @Operation(summary = "修改驾驶员信息")
    @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "驾驶员信息对象", required = true, content = @Content(mediaType = "application/json", schema = @Schema(implementation = SysDriverInfo.class)))
    @PutMapping
    public AjaxResult edit(@RequestBody SysDriverInfo sysDriverInfo)
    {
        return toAjax(sysDriverInfoService.updateSysDriverInfo(sysDriverInfo));
    }

    /**
     * 删除驾驶员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:driver_info:remove')")
    @Log(title = "驾驶员信息", businessType = BusinessType.DELETE)
    @Operation(summary = "删除驾驶员信息")
    @Parameter(name = "userIds", description = "用户ID", required = true)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysDriverInfoService.deleteSysDriverInfoByUserIds(userIds));
    }
}
