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.AgreementSetting;
import com.ruoyi.dk.service.AgreementSettingService;
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.*;

@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/dk/AgreementSetting")
public class DkAgreementSettingController extends BaseController {

    private final AgreementSettingService agreementSettingService;

    /**
     * 获取协议设置详细信息
     */
    @SaCheckPermission("dk:AgreementSetting:query")
    @GetMapping("/info")
    public R<AgreementSetting> getInfo() {
        return R.ok(agreementSettingService.getAgreementSetting());
    }

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

}
