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

import com.hotwj.platform.driverManagement.driverRewardPunishment.domain.bo.HotDriverRewardPunishmentBo;
import com.hotwj.platform.driverManagement.driverRewardPunishment.domain.vo.HotDriverRewardPunishmentVo;
import com.hotwj.platform.driverManagement.driverRewardPunishment.service.IHotDriverRewardPunishmentService;
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/driverRewardPunishment")
@Tag(name = "驾驶员奖惩记录", description = "奖惩记录管理")
public class HotDriverRewardPunishmentController extends BaseController {

    private final IHotDriverRewardPunishmentService hotDriverRewardPunishmentService;

    /**
     * 查询驾驶员奖惩记录列表
     */
    //@SaCheckPermission("driverManagement:driverRewardPunishment:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询驾驶员奖惩记录列表")
    public TableDataInfo<HotDriverRewardPunishmentVo> list(HotDriverRewardPunishmentBo bo, PageQuery pageQuery) {
        return hotDriverRewardPunishmentService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出驾驶员奖惩记录列表
     */
    //@SaCheckPermission("driverManagement:driverRewardPunishment:export")
    @Log(title = "驾驶员奖惩记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出驾驶员奖惩记录列表")
    public void export(HotDriverRewardPunishmentBo bo, HttpServletResponse response) {
        List<HotDriverRewardPunishmentVo> list = hotDriverRewardPunishmentService.queryList(bo);
        ExcelUtil.exportExcel(list, "驾驶员奖惩记录", HotDriverRewardPunishmentVo.class, response);
    }

    /**
     * 获取驾驶员奖惩记录详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("driverManagement:driverRewardPunishment:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询驾驶员奖惩记录详情")
    public R<HotDriverRewardPunishmentVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable Long id) {
        return R.ok(hotDriverRewardPunishmentService.queryById(id));
    }

    /**
     * 新增驾驶员奖惩记录
     */
    //@SaCheckPermission("driverManagement:driverRewardPunishment:add")
    @Log(title = "驾驶员奖惩记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增驾驶员奖惩记录")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotDriverRewardPunishmentBo bo) {
        return toAjax(hotDriverRewardPunishmentService.insertByBo(bo));
    }

    /**
     * 修改驾驶员奖惩记录
     */
    //@SaCheckPermission("driverManagement:driverRewardPunishment:edit")
    @Log(title = "驾驶员奖惩记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改驾驶员奖惩记录")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotDriverRewardPunishmentBo bo) {
        return toAjax(hotDriverRewardPunishmentService.updateByBo(bo));
    }

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