package com.ruoyi.dk.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.component.idempotent.annotation.RepeatSubmit;
import com.ruoyi.component.log.annotation.Log;
import com.ruoyi.component.log.enums.BusinessType;
import com.ruoyi.component.web.core.BaseController;
import com.ruoyi.dk.domain.LoansSetting;
import com.ruoyi.dk.service.LoansSettingService;
import com.ruoyi.component.core.domain.R;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 贷款设置Controller
 *
 * @author duteliang
 * @date 2023-11-29
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/LoansSetting")
public class DkLoansSettingController extends BaseController {

    private final LoansSettingService loansSettingService;

    /**
     * 获取贷款设置详细信息
     */
    @SaCheckPermission("dk:LoansSetting:query")
    @GetMapping("/info")
    public R<LoansSetting> getInfo() {
        return R.ok(loansSettingService.getLoansSetting());
    }

    /**
     * 修改贷款设置
     */
    @SaCheckPermission("dk:LoansSetting:edit")
    @Log(title = "贷款设置", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public R<Void> edit(@Validated @RequestBody LoansSetting bo) {
        return toAjax(loansSettingService.updateById(bo) ? 1 : 0);
    }
}
