package com.ruoyi.web.controller.enterprise;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.system.domain.EnterpriseApply;
import com.ruoyi.system.service.IEnterpriseApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业信息审核Controller
 * 
 * @author ruoyi
 * @date 2023-02-20
 */
@RestController
@RequestMapping("/system/apply")
public class EnterpriseApplyController extends BaseController
{
    @Autowired
    private IEnterpriseApplyService enterpriseApplyService;

    /**
     * 查询企业信息审核列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EnterpriseApply enterpriseApply)
    {
        startPage();
        List<EnterpriseApply> list = enterpriseApplyService.selectEnterpriseApplyList(enterpriseApply);
        return getDataTable(list);
    }

    /**
     * 导出企业信息审核列表
     */
    @Log(title = "企业信息审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EnterpriseApply enterpriseApply)
    {
        List<EnterpriseApply> list = enterpriseApplyService.selectEnterpriseApplyList(enterpriseApply);
        ExcelUtil<EnterpriseApply> util = new ExcelUtil<EnterpriseApply>(EnterpriseApply.class);
        util.exportExcel(response, list, "企业信息审核数据");
    }

    /**
     * 获取企业信息审核详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(enterpriseApplyService.selectEnterpriseApplyById(id));
    }

    /**
     * 新增企业信息审核
     */
    @PostMapping
    public AjaxResult add(@RequestBody EnterpriseApply enterpriseApply)
    {
        return toAjax(enterpriseApplyService.insertEnterpriseApply(enterpriseApply));
    }

    /**
     * 修改企业信息审核
     */
    @Log(title = "企业信息审核", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/update")
    public AjaxResult update(@RequestBody EnterpriseApply enterpriseApply)
    {
        return toAjax(enterpriseApplyService.updateEnterpriseApply(enterpriseApply));
    }

    /**
     * 企业信息审核
     */
    @Log(title = "企业信息审核", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/put")
    public AjaxResult edit(@RequestBody EnterpriseApply enterpriseApply)
    {
        return toAjax(enterpriseApplyService.edit(enterpriseApply));
    }

    /**
     * 删除企业信息审核
     */
    @Log(title = "企业信息审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(enterpriseApplyService.deleteEnterpriseApplyByIds(ids));
    }
}
