package com.ruoyi.web.controller.bgt;

import com.ruoyi.bgt.domain.dto.BgtReissueacardListDTO;
import com.ruoyi.bgt.domain.dto.BgtReissueacardUpdateDTO;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wgz.bo.res.WgzReplacementCardRecordRes;
import com.ruoyi.wgz.domain.WgzReissueacard;
import com.ruoyi.wgz.service.IWgzReissueacardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * 补卡申请Controller
 *
 * @author ruoyi
 * @date 2025-02-20
 */
@Api(value = "App包工头补卡审批控制器", tags = {"App包工头补卡审批"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/bgt/reissueacard")
public class AppBgtReissueacardController extends BaseController {

    private final IWgzReissueacardService iWgzReissueacardService;

    /**
     * 查询补卡申请列表
     */
    @ApiOperation("查询补卡申请列表")
    @GetMapping("/list")
    public TableDataInfo<WgzReplacementCardRecordRes> list(@Validated BgtReissueacardListDTO dto) {
        return iWgzReissueacardService.appQueryPageList(dto);
    }


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

    @ApiOperation("补卡审核")
    @Log(title = "补卡审核", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody BgtReissueacardUpdateDTO dto) {
        return toAjax(iWgzReissueacardService.appUpdate(dto) ? 1 : 0);
    }

}
