package com.ningdatech.carapi.industry.controller;


import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.web.bind.annotation.*;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.common.util.ExcelDownUtil;
import com.ningdatech.carapi.industry.manage.MortarEnterpriseFilingCertificateManage;
import com.ningdatech.carapi.industry.model.dto.MortarEnterpriseFilingCertificateDTO;
import com.ningdatech.carapi.industry.model.req.LabWorkerCertificateAuditReq;
import com.ningdatech.carapi.industry.model.req.LabWorkerCertificateListReq;
import com.ningdatech.carapi.industry.model.vo.MortarEnterpriseFilingCertificateChangeVO;
import com.ningdatech.carapi.industry.model.vo.MortarEnterpriseFilingCertificateVO;
import com.ningdatech.carapi.industry.service.IMortarEnterpriseFilingCertificateService;
import com.ningdatech.carapi.user.util.LoginUserUtil;
import com.ningdatech.log.annotation.WebLog;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;

/**
 * <p>
 * 砂浆企业备案证 前端控制器
 * </p>
 *
 * @author WendyYang
 * @since 2022-11-08
 */
@Api(tags = "行业服务-砂浆企业备案证")
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/industry/mortar-enterprise-filing-certificate")
public class MortarEnterpriseFilingCertificateController {

    private final MortarEnterpriseFilingCertificateManage mortarEnterpriseFilingCertificateManage;
    private final IMortarEnterpriseFilingCertificateService mortarEnterpriseFilingCertificateService;

    @GetMapping("/list")
    @ApiOperation("列表")
    public PageVo<MortarEnterpriseFilingCertificateVO> list(LabWorkerCertificateListReq req) {
        return mortarEnterpriseFilingCertificateManage.mortarEnterpriseFilingCertificateList(req);
    }

    @GetMapping("/export")
    @ApiOperation("导出")
    public void export(LabWorkerCertificateListReq req, HttpServletResponse response) {
        ExcelDownUtil.downXls(response, req, mortarEnterpriseFilingCertificateManage::mortarEnterpriseFilingCertificateExport);
    }

    @GetMapping("/changeList")
    @ApiOperation("换证列表")
    public PageVo<MortarEnterpriseFilingCertificateChangeVO> changeList(LabWorkerCertificateListReq req) {
        return mortarEnterpriseFilingCertificateManage.changeList(req);
    }

    @DeleteMapping("/del/{id}")
    @ApiOperation("删除")
    @WebLog(value = "删除")
    public void delete(@PathVariable Long id) {
        mortarEnterpriseFilingCertificateManage.delete(id);
    }

    @PostMapping("/saveOrUpdate")
    @ApiOperation("保存/修改")
    @WebLog(value = "保存/修改")
    public void saveOrUpdate(@Valid @RequestBody MortarEnterpriseFilingCertificateDTO mortarEnterprise) {
        mortarEnterpriseFilingCertificateManage.saveOrUpdate(mortarEnterprise);
    }

    @ApiOperation("审核砂浆企业备案证换证申请]")
    @PostMapping("/audit")
    public Boolean audit(@Valid @RequestBody LabWorkerCertificateAuditReq req){
        return mortarEnterpriseFilingCertificateManage.audit(req, LoginUserUtil.getUserId());
    }

}
