package com.ruoyi.web.controller.system;

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.DkFj;
import com.ruoyi.system.service.IDkFjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 贷款_附件Controller
 * 
 * @author boman
 * @date 2023-06-15
 */
@RestController
@RequestMapping("/system/fj")
public class DkFjController extends BaseController
{
    @Autowired
    private IDkFjService dkFjService;

    /**
     * 查询贷款_附件列表
     */
    @PreAuthorize("@ss.hasPermi('system:fj:list')")
    @GetMapping("/list")
    public TableDataInfo list(DkFj dkFj)
    {
        startPage();
        List<DkFj> list = dkFjService.selectDkFjList(dkFj);
        return getDataTable(list);
    }

    /**
     * 导出贷款_附件列表
     */
    @PreAuthorize("@ss.hasPermi('system:fj:export')")
    @Log(title = "贷款_附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DkFj dkFj)
    {
        List<DkFj> list = dkFjService.selectDkFjList(dkFj);
        ExcelUtil<DkFj> util = new ExcelUtil<DkFj>(DkFj.class);
        util.exportExcel(response, list, "贷款_附件数据");
    }

    /**
     * 获取贷款_附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dkFjService.selectDkFjById(id));
    }

    /**
     * 新增贷款_附件
     */
    @PreAuthorize("@ss.hasPermi('system:fj:add')")
    @Log(title = "贷款_附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DkFj dkFj)
    {
        return toAjax(dkFjService.insertDkFj(dkFj));
    }

    /**
     * 修改贷款_附件
     */
    @PreAuthorize("@ss.hasPermi('system:fj:edit')")
    @Log(title = "贷款_附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DkFj dkFj)
    {
        return toAjax(dkFjService.updateDkFj(dkFj));
    }

    /**
     * 删除贷款_附件
     */
    @PreAuthorize("@ss.hasPermi('system:fj:remove')")
    @Log(title = "贷款_附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dkFjService.deleteDkFjByIds(ids));
    }
}
