package com.ruoyi.ibs.list.controller;

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

import com.ruoyi.ibs.list.domain.OtherBankRate;
import com.ruoyi.ibs.list.service.IOtherBankRateService;
import io.swagger.annotations.ApiOperation;
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.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人视图他行征信利率Controller
 * 
 * @author ruoyi
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/system/rate")
public class OtherBankRateController extends BaseController
{
    @Autowired
    private IOtherBankRateService otherBankRateService;

    /**
     * 查询个人视图他行征信利率列表
     */
    //@PreAuthorize("@ss.hasPermi('system:rate:list')")
    @GetMapping("/list")
    @ApiOperation("根据身份证号查询他行利率")
    @Log(title = "客户视图-根据身份证号查询他行利率")
    public TableDataInfo list(OtherBankRate otherBankRate)
    {
        startPage();
        List<OtherBankRate> list = otherBankRateService.selectOtherBankRateList(otherBankRate);
        return getDataTable(list);
    }

    /**
     * 导出个人视图他行征信利率列表
     */
    @PreAuthorize("@ss.hasPermi('system:rate:export')")
    @Log(title = "客户视图-个人视图他行征信利率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OtherBankRate otherBankRate)
    {
        List<OtherBankRate> list = otherBankRateService.selectOtherBankRateList(otherBankRate);
        ExcelUtil<OtherBankRate> util = new ExcelUtil<OtherBankRate>(OtherBankRate.class);
        util.exportExcel(response, list, "个人视图他行征信利率数据");
    }

    /**
     * 获取个人视图他行征信利率详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rate:query')")
    @Log(title = "客户视图-获取个人视图他行征信利率详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(otherBankRateService.selectOtherBankRateById(id));
    }

    /**
     * 新增个人视图他行征信利率
     */
    //@PreAuthorize("@ss.hasPermi('system:rate:add')")
    @Log(title = "客户视图-个人视图他行征信利率", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增他行利率")
    public AjaxResult add(OtherBankRate otherBankRate)
    {
        return toAjax(otherBankRateService.insertOtherBankRate(otherBankRate));
    }

    /**
     * 修改个人视图他行征信利率
     */
    //@PreAuthorize("@ss.hasPermi('system:rate:edit')")
    @Log(title = "客户视图-个人视图他行征信利率", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    @ApiOperation("编辑他行利率")
    public AjaxResult edit(OtherBankRate otherBankRate)
    {
        return toAjax(otherBankRateService.updateOtherBankRate(otherBankRate));
    }

    /**
     * 删除个人视图他行征信利率
     */
    @PreAuthorize("@ss.hasPermi('system:rate:remove')")
    @Log(title = "客户视图-个人视图他行征信利率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(otherBankRateService.deleteOtherBankRateByIds(ids));
    }
}
