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

import com.hotwj.platform.driverManagement.driverAnnualAssessment.domain.bo.HotDriverAnnualAssessmentBo;
import com.hotwj.platform.driverManagement.driverAnnualAssessment.domain.vo.HotDriverAnnualAssessmentVo;
import com.hotwj.platform.driverManagement.driverAnnualAssessment.service.IHotDriverAnnualAssessmentService;
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/driverAnnualAssessment")
@Tag(name = "驾驶员年度考核", description = "年度考核管理")
public class HotDriverAnnualAssessmentController extends BaseController {

    private final IHotDriverAnnualAssessmentService hotDriverAnnualAssessmentService;

    /**
     * 查询驾驶员年度考核列表
     */
    //@SaCheckPermission("driverManagement:driverAnnualAssessment:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询驾驶员年度考核列表")
    public TableDataInfo<HotDriverAnnualAssessmentVo> list(HotDriverAnnualAssessmentBo bo, PageQuery pageQuery) {
        return hotDriverAnnualAssessmentService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出驾驶员年度考核列表
     */
    //@SaCheckPermission("driverManagement:driverAnnualAssessment:export")
    @Log(title = "驾驶员年度考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出驾驶员年度考核列表")
    public void export(HotDriverAnnualAssessmentBo bo, HttpServletResponse response) {
        List<HotDriverAnnualAssessmentVo> list = hotDriverAnnualAssessmentService.queryList(bo);
        ExcelUtil.exportExcel(list, "驾驶员年度考核", HotDriverAnnualAssessmentVo.class, response);
    }

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

    /**
     * 新增驾驶员年度考核
     */
    //@SaCheckPermission("driverManagement:driverAnnualAssessment:add")
    @Log(title = "驾驶员年度考核", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增驾驶员年度考核")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotDriverAnnualAssessmentBo bo) {
        return toAjax(hotDriverAnnualAssessmentService.insertByBo(bo));
    }

    /**
     * 修改驾驶员年度考核
     */
    //@SaCheckPermission("driverManagement:driverAnnualAssessment:edit")
    @Log(title = "驾驶员年度考核", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改驾驶员年度考核")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotDriverAnnualAssessmentBo bo) {
        return toAjax(hotDriverAnnualAssessmentService.updateByBo(bo));
    }

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