package com.ruoyi.dk.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.component.core.domain.R;
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.HomeSetting;
import com.ruoyi.dk.service.HomeSettingService;
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/HomeSetting")
public class DkHomeSettingController extends BaseController {

    private final HomeSettingService homeSettingService;


    /**
     * 获取常规设置详细信息
     */
    @SaCheckPermission("dk:HomeSetting:query")
    @GetMapping("/info")
    public R<HomeSetting> getInfo() {
        return R.ok(homeSettingService.getHomeSetting());
    }

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