package com.ruoyi.web.controller.guarantee;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.guarantee.GuaranteeInfoFj;
import com.ruoyi.system.service.guarantee.IGuaranteeInfoFjService;
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.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.common.core.page.TableDataInfo;

/**
 * 反担保基础信息附件Controller
 *
 * @author boman
 * @date 2024-08-01
 */
@RestController
@RequestMapping("/guarantee/fj")
public class GuaranteeInfoFjController extends BaseController
{
    @Autowired
    private IGuaranteeInfoFjService guaranteeInfoFjService;

/**
 * 查询反担保基础信息附件列表
 */
@PreAuthorize("@ss.hasPermi('guarantee:fj:list')")
@GetMapping("/list")
    public TableDataInfo list(GuaranteeInfoFj guaranteeInfoFj)
    {
        startPage();
        List<GuaranteeInfoFj> list = guaranteeInfoFjService.selectGuaranteeInfoFjList(guaranteeInfoFj);
        return getDataTable(list);
    }

    /**
     * 导出反担保基础信息附件列表
     */
    @PreAuthorize("@ss.hasPermi('guarantee:fj:export')")
    @Log(title = "反担保基础信息附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GuaranteeInfoFj guaranteeInfoFj)
    {
        List<GuaranteeInfoFj> list = guaranteeInfoFjService.selectGuaranteeInfoFjList(guaranteeInfoFj);
        ExcelUtil<GuaranteeInfoFj> util = new ExcelUtil<GuaranteeInfoFj>(GuaranteeInfoFj.class);
        util.exportExcel(response, list, "反担保基础信息附件数据");
    }

    /**
     * 获取反担保基础信息附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('guarantee:fj:query')")
    @GetMapping(value = "/{guaranteeInfoFjId}")
    public AjaxResult getInfo(@PathVariable("guaranteeInfoFjId") Long guaranteeInfoFjId)
    {
        return success(guaranteeInfoFjService.selectGuaranteeInfoFjByGuaranteeInfoFjId(guaranteeInfoFjId));
    }

    /**
     * 新增反担保基础信息附件
     */
    @PreAuthorize("@ss.hasPermi('guarantee:fj:add')")
    @Log(title = "反担保基础信息附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GuaranteeInfoFj guaranteeInfoFj)
    {
        return toAjax(guaranteeInfoFjService.insertGuaranteeInfoFj(guaranteeInfoFj));
    }

    /**
     * 修改反担保基础信息附件
     */
    @PreAuthorize("@ss.hasPermi('guarantee:fj:edit')")
    @Log(title = "反担保基础信息附件", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody GuaranteeInfoFj guaranteeInfoFj)
    {
        return toAjax(guaranteeInfoFjService.updateGuaranteeInfoFj(guaranteeInfoFj));
    }

    /**
     * 删除反担保基础信息附件
     */
    @PreAuthorize("@ss.hasPermi('guarantee:fj:remove')")
    @Log(title = "反担保基础信息附件", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{guaranteeInfoFjIds}")
    public AjaxResult remove(@PathVariable Long[] guaranteeInfoFjIds)
    {
        return toAjax(guaranteeInfoFjService.deleteGuaranteeInfoFjByGuaranteeInfoFjIds(guaranteeInfoFjIds));
    }
}
