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

import com.hotwj.platform.driverManagement.driverWorkExperience.domain.bo.HotDriverWorkExperienceBo;
import com.hotwj.platform.driverManagement.driverWorkExperience.domain.vo.HotDriverWorkExperienceVo;
import com.hotwj.platform.driverManagement.driverWorkExperience.service.IHotDriverWorkExperienceService;
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-15
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/driverManagement/driverWorkExperience")
@Tag(name = "驾驶员工作经历", description = "工作经历管理")
public class HotDriverWorkExperienceController extends BaseController {

    private final IHotDriverWorkExperienceService hotDriverWorkExperienceService;

    /**
     * 查询驾驶员工作经历列表
     */
    //@SaCheckPermission("driverManagement:driver:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询驾驶员工作经历列表")
    public TableDataInfo<HotDriverWorkExperienceVo> list(HotDriverWorkExperienceBo bo, PageQuery pageQuery) {
        return hotDriverWorkExperienceService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出驾驶员工作经历列表
     */
    //@SaCheckPermission("driverManagement:driver:export")
    @Log(title = "驾驶员工作经历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出驾驶员工作经历列表")
    public void export(HotDriverWorkExperienceBo bo, HttpServletResponse response) {
        List<HotDriverWorkExperienceVo> list = hotDriverWorkExperienceService.queryList(bo);
        ExcelUtil.exportExcel(list, "驾驶员工作经历", HotDriverWorkExperienceVo.class, response);
    }

    /**
     * 获取驾驶员工作经历详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("driverManagement:driver:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询驾驶员工作经历详情")
    public R<HotDriverWorkExperienceVo> getInfo(@NotNull(message = "主键不能为空")
                                                @PathVariable Long id) {
        return R.ok(hotDriverWorkExperienceService.queryById(id));
    }

    /**
     * 新增驾驶员工作经历
     */
    //@SaCheckPermission("driverManagement:driver:add")
    @Log(title = "驾驶员工作经历", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增驾驶员工作经历")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotDriverWorkExperienceBo bo) {
        return toAjax(hotDriverWorkExperienceService.insertByBo(bo));
    }

    /**
     * 修改驾驶员工作经历
     */
    //@SaCheckPermission("driverManagement:driver:edit")
    @Log(title = "驾驶员工作经历", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改驾驶员工作经历")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotDriverWorkExperienceBo bo) {
        return toAjax(hotDriverWorkExperienceService.updateByBo(bo));
    }

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