package com.ruoyi.web.controller.wgz.controller;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.wgz.domain.WgzReissueacard;
import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wgz.bo.WgzReissueacardQueryBo;
import com.ruoyi.wgz.service.IWgzReissueacardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 补卡申请Controller
 *
 * @author ruoyi
 * @date 2025-02-20
 */
@Api(value = "补卡申请控制器", tags = {"补卡申请管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wgz/reissueacard")
public class WgzReissueacardController extends BaseController {

    private final IWgzReissueacardService iWgzReissueacardService;

    /**
     * 查询补卡申请列表
     */
    @ApiOperation("查询补卡申请列表")
    @PreAuthorize("@ss.hasPermi('wgz:reissueacard:list')")
    @GetMapping("/list")
    public TableDataInfo<WgzReissueacard> list(@Validated WgzReissueacardQueryBo bo) {
        return iWgzReissueacardService.queryPageList(bo);
    }

    /**
     * 导出补卡申请列表
     */
    @ApiOperation("导出补卡申请列表")
    @PreAuthorize("@ss.hasPermi('wgz:reissueacard:export')")
    @Log(title = "补卡申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<WgzReissueacard> export(@Validated WgzReissueacardQueryBo bo) {
        List<WgzReissueacard> list = iWgzReissueacardService.queryList(bo);
        ExcelUtil<WgzReissueacard> util = new ExcelUtil<WgzReissueacard>(WgzReissueacard.class);
        return util.exportExcel(list, "补卡申请");
    }

    /**
     * 获取补卡申请详细信息
     */
    @ApiOperation("获取补卡申请详细信息")
    @PreAuthorize("@ss.hasPermi('wgz:reissueacard:query')")
    @GetMapping("/{id}")
    public AjaxResult<WgzReissueacard> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iWgzReissueacardService.queryById(id));
    }

    /**
     * 新增补卡申请
     */
    @ApiOperation("新增补卡申请")
    @PreAuthorize("@ss.hasPermi('wgz:reissueacard:add')")
    @Log(title = "补卡申请", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody WgzReissueacard bo) {
        return toAjax(iWgzReissueacardService.insert(bo) ? 1 : 0);
    }

    /**
     * 修改补卡申请
     */
    @ApiOperation("修改补卡申请")
    @PreAuthorize("@ss.hasPermi('wgz:reissueacard:edit')")
    @Log(title = "补卡申请", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody WgzReissueacard bo) {
        return toAjax(iWgzReissueacardService.update(bo) ? 1 : 0);
    }

    /**
     * 删除补卡申请
     */
    @ApiOperation("删除补卡申请")
    @PreAuthorize("@ss.hasPermi('wgz:reissueacard:remove')")
    @Log(title = "补卡申请" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iWgzReissueacardService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
