package com.ruoyi.web.controller.loan;

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

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.loan.LoanSchedule;
import com.ruoyi.system.service.loan.ILoanScheduleService;
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.common.core.page.TableDataInfo;

/**
 * 业务进度Controller
 *
 * @author boman
 * @date 2024-04-24
 */
@RestController
@RequestMapping("/schedule")
public class LoanScheduleController extends BaseController {
    @Autowired
    private ILoanScheduleService loanScheduleService;

    /**
     * 查询业务进度列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:list')")
    @GetMapping("/list")
    public AjaxResult list(LoanSchedule loanSchedule) {
        return loanScheduleService.selectLoanScheduleList(loanSchedule);
    }

/*    *//**
     * 导出业务进度列表
     *//*
    @PreAuthorize("@ss.hasPermi('system:schedule:export')")
    @Log(title = "业务进度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LoanSchedule loanSchedule) {
        List<LoanSchedule> list = loanScheduleService.selectLoanScheduleList(loanSchedule);
        ExcelUtil<LoanSchedule> util = new ExcelUtil<LoanSchedule>(LoanSchedule.class);
        util.exportExcel(response, list, "业务进度数据");
    }*/

    /**
     * 获取业务进度详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:query')")
    @GetMapping(value = "/{loanScheduleId}")
    public AjaxResult getInfo(@PathVariable("loanScheduleId") Long loanScheduleId) {
        return success(loanScheduleService.selectLoanScheduleByLoanScheduleId(loanScheduleId));
    }

    /**
     * 新增业务进度
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:add')")
    @Log(title = "业务进度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LoanSchedule loanSchedule) {
        return toAjax(loanScheduleService.insertLoanSchedule(loanSchedule));
    }

    /**
     * 修改业务进度
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:edit')")
    @Log(title = "业务进度", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody LoanSchedule loanSchedule) {
        return toAjax(loanScheduleService.updateLoanSchedule(loanSchedule));
    }

    /**
     * 删除业务进度
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:remove')")
    @Log(title = "业务进度", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{loanScheduleIds}")
    public AjaxResult remove(@PathVariable Long[] loanScheduleIds) {
        return toAjax(loanScheduleService.deleteLoanScheduleByLoanScheduleIds(loanScheduleIds));
    }
}
