package com.hotwj.platform.config.vehicleInspectionConfig.controller;

import com.hotwj.platform.config.vehicleInspectionConfig.domain.bo.HotVehicleInspectionConfigBo;
import com.hotwj.platform.config.vehicleInspectionConfig.domain.vo.HotVehicleInspectionConfigVo;
import com.hotwj.platform.config.vehicleInspectionConfig.service.IHotVehicleInspectionConfigService;
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-19
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/config/vehicleInspectionConfig")
@Tag(name = "车辆年审检查配置", description = "车辆年审检查配置增删改查与导出")
public class HotVehicleInspectionConfigController extends BaseController {

    private final IHotVehicleInspectionConfigService hotVehicleInspectionConfigService;

    /**
     * 查询车辆年审检查配置列表
     */
    //@SaCheckPermission("config:vehicleInspectionConfig:list")
    @GetMapping("/list")
    @Operation(summary = "查询车辆年审检查配置列表")
    public TableDataInfo<HotVehicleInspectionConfigVo> list(HotVehicleInspectionConfigBo bo, PageQuery pageQuery) {
        return hotVehicleInspectionConfigService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出车辆年审检查配置列表
     */
    //@SaCheckPermission("config:vehicleInspectionConfig:export")
    @Log(title = "车辆年审检查配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出车辆年审检查配置列表")
    public void export(HotVehicleInspectionConfigBo bo, HttpServletResponse response) {
        List<HotVehicleInspectionConfigVo> list = hotVehicleInspectionConfigService.queryList(bo);
        ExcelUtil.exportExcel(list, "车辆年审检查配置", HotVehicleInspectionConfigVo.class, response);
    }

    /**
     * 获取车辆年审检查配置详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("config:vehicleInspectionConfig:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取车辆年审检查配置详细信息")
    public R<HotVehicleInspectionConfigVo> getInfo(@NotNull(message = "主键不能为空")
                                                   @PathVariable Long id) {
        return R.ok(hotVehicleInspectionConfigService.queryById(id));
    }

    /**
     * 新增车辆年审检查配置
     */
    //@SaCheckPermission("config:vehicleInspectionConfig:add")
    @Log(title = "车辆年审检查配置", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增车辆年审检查配置")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotVehicleInspectionConfigBo bo) {
        return toAjax(hotVehicleInspectionConfigService.insertByBo(bo));
    }

    /**
     * 修改车辆年审检查配置
     */
    //@SaCheckPermission("config:vehicleInspectionConfig:edit")
    @Log(title = "车辆年审检查配置", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改车辆年审检查配置")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotVehicleInspectionConfigBo bo) {
        return toAjax(hotVehicleInspectionConfigService.updateByBo(bo));
    }

    /**
     * 删除车辆年审检查配置
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("config:vehicleInspectionConfig:remove")
    @Log(title = "车辆年审检查配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除车辆年审检查配置")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotVehicleInspectionConfigService.deleteWithValidByIds(List.of(ids), true));
    }
}
