package com.ruoyi.xq.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xq.domain.AgreementSetting;
import com.ruoyi.xq.service.AgreementSettingService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 协议设置
 *
 * @author 77
 * @date 2024-03-04
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/xq/agreementSetting")
public class AgreementSettingController extends BaseController {

    private final AgreementSettingService agreementSettingService;

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

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

}
