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

import com.hotwj.platform.driverManagement.driverSkillAssessment.domain.bo.HotDriverSkillAssessmentBo;
import com.hotwj.platform.driverManagement.driverSkillAssessment.domain.vo.HotDriverSkillAssessmentVo;
import com.hotwj.platform.driverManagement.driverSkillAssessment.service.IHotDriverSkillAssessmentService;
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-16
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/driverManagement/driverSkillAssessment")
@Tag(name = "驾驶员技能考核", description = "技能考核管理")
public class HotDriverSkillAssessmentController extends BaseController {

    private final IHotDriverSkillAssessmentService hotDriverSkillAssessmentService;

    /**
     * 查询驾驶员技能考核（明细项）列表
     */
    //@SaCheckPermission("driverManagement:driverSkillAssessment:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询驾驶员技能考核（明细项）列表")
    public TableDataInfo<HotDriverSkillAssessmentVo> list(HotDriverSkillAssessmentBo bo, PageQuery pageQuery) {
        return hotDriverSkillAssessmentService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出驾驶员技能考核（明细项）列表
     */
    //@SaCheckPermission("driverManagement:driverSkillAssessment:export")
    @Log(title = "驾驶员技能考核（明细项）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出驾驶员技能考核（明细项）列表")
    public void export(HotDriverSkillAssessmentBo bo, HttpServletResponse response) {
        List<HotDriverSkillAssessmentVo> list = hotDriverSkillAssessmentService.queryList(bo);
        ExcelUtil.exportExcel(list, "驾驶员技能考核（明细项）", HotDriverSkillAssessmentVo.class, response);
    }

    /**
     * 获取驾驶员技能考核（明细项）详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("driverManagement:driverSkillAssessment:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询驾驶员技能考核（明细项）详情")
    public R<HotDriverSkillAssessmentVo> getInfo(@NotNull(message = "主键不能为空")
                                                 @PathVariable Long id) {
        return R.ok(hotDriverSkillAssessmentService.queryById(id));
    }

    /**
     * 新增驾驶员技能考核（明细项）
     */
    //@SaCheckPermission("driverManagement:driverSkillAssessment:add")
    @Log(title = "驾驶员技能考核（明细项）", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增驾驶员技能考核（明细项）")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotDriverSkillAssessmentBo bo) {
        return toAjax(hotDriverSkillAssessmentService.insertByBo(bo));
    }

    /**
     * 修改驾驶员技能考核（明细项）
     */
    //@SaCheckPermission("driverManagement:driverSkillAssessment:edit")
    @Log(title = "驾驶员技能考核（明细项）", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改驾驶员技能考核（明细项）")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotDriverSkillAssessmentBo bo) {
        return toAjax(hotDriverSkillAssessmentService.updateByBo(bo));
    }

    /**
     * 删除驾驶员技能考核（明细项）
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("driverManagement:driverSkillAssessment:remove")
    @Log(title = "驾驶员技能考核（明细项）", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除驾驶员技能考核（明细项）")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotDriverSkillAssessmentService.deleteWithValidByIds(List.of(ids), true));
    }
}
