package com.hotwj.platform.driverManagement.driverFileSign.controller;

import com.hotwj.platform.driverManagement.driverFileSign.domain.bo.HotDriverFileSignBo;
import com.hotwj.platform.driverManagement.driverFileSign.domain.vo.HotDriverFileSignVo;
import com.hotwj.platform.driverManagement.driverFileSign.service.IHotDriverFileSignService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 驾驶员文件签订
 *
 * @author shihongwei
 * @date 2025-12-22
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/driverManagement/driverFileSign")
@Tag(name = "驾驶员文件签订", description = "驾驶员文件签订管理")
public class HotDriverFileSignController extends BaseController {

    private final IHotDriverFileSignService hotDriverFileSignService;

    /**
     * 查询驾驶员文件签订列表
     */
    //@SaCheckPermission("driverManagement:driverFileSign:list")
    @GetMapping("/list")
    @Operation(summary = "查询驾驶员文件签订列表")
    public TableDataInfo<HotDriverFileSignVo> list(HotDriverFileSignBo bo, PageQuery pageQuery) {
        return hotDriverFileSignService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出驾驶员文件签订列表
     */
    //@SaCheckPermission("driverManagement:driverFileSign:export")
    @Log(title = "驾驶员文件签订", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出驾驶员文件签订列表")
    public void export(HotDriverFileSignBo bo, HttpServletResponse response) {
        List<HotDriverFileSignVo> list = hotDriverFileSignService.queryList(bo);
        ExcelUtil.exportExcel(list, "驾驶员文件签订", HotDriverFileSignVo.class, response);
    }

    /**
     * 获取驾驶员文件签订详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("driverManagement:driverFileSign:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取驾驶员文件签订详细信息")
    public R<HotDriverFileSignVo> getInfo(@NotNull(message = "主键不能为空")
                                          @PathVariable Long id) {
        return R.ok(hotDriverFileSignService.queryById(id));
    }

    /**
     * 新增驾驶员文件签订
     */
    //@SaCheckPermission("driverManagement:driverFileSign:add")
    @Log(title = "驾驶员文件签订", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增驾驶员文件签订")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotDriverFileSignBo bo) {
        bo.setIsDeleted(0L);
        return toAjax(hotDriverFileSignService.insertByBo(bo));
    }

    /**
     * 修改驾驶员文件签订
     */
    //@SaCheckPermission("driverManagement:driverFileSign:edit")
    @Log(title = "驾驶员文件签订", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改驾驶员文件签订")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotDriverFileSignBo bo) {
        return toAjax(hotDriverFileSignService.updateByBo(bo));
    }

    /**
     * 删除驾驶员文件签订
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("driverManagement:driverFileSign:remove")
    @Log(title = "驾驶员文件签订", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除驾驶员文件签订")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotDriverFileSignService.deleteWithValidByIds(List.of(ids), true));
    }
}
