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

/**
 * 贷款申请_主Controller
 * 
 * @author boman
 * @date 2023-06-15
 */
@RestController
@RequestMapping("/system/dksq")
public class DksqController extends BaseController
{
    @Autowired
    private IDksqService dksqService;

    /**
     * 查询贷款申请_主列表
     */
    @PreAuthorize("@ss.hasPermi('system:dksq:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dksq dksq)
    {
        startPage();
        List<Dksq> list = dksqService.selectDksqList(dksq);
        return getDataTable(list);
    }

    /**
     * 导出贷款申请_主列表
     */
    @PreAuthorize("@ss.hasPermi('system:dksq:export')")
    @Log(title = "贷款申请_主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dksq dksq)
    {
        List<Dksq> list = dksqService.selectDksqList(dksq);
        ExcelUtil<Dksq> util = new ExcelUtil<Dksq>(Dksq.class);
        util.exportExcel(response, list, "贷款申请_主数据");
    }

    /**
     * 获取贷款申请_主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dksq:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dksqService.selectDksqById(id));
    }

    /**
     * 新增贷款申请_主
     */
    @PreAuthorize("@ss.hasPermi('system:dksq:add')")
    @Log(title = "贷款申请_主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dksq dksq)
    {
        return toAjax(dksqService.insertDksq(dksq));
    }

    /**
     * 修改贷款申请_主
     */
    @PreAuthorize("@ss.hasPermi('system:dksq:edit')")
    @Log(title = "贷款申请_主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dksq dksq)
    {
        return toAjax(dksqService.updateDksq(dksq));
    }

    /**
     * 删除贷款申请_主
     */
    @PreAuthorize("@ss.hasPermi('system:dksq:remove')")
    @Log(title = "贷款申请_主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dksqService.deleteDksqByIds(ids));
    }
}
