package com.ruoyi.web.modules.epidemic.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.web.modules.epidemic.domain.dto.RiskFactorWeightSaveRequest;
import com.ruoyi.web.modules.epidemic.service.IBizRiskFactorWeightService;

/**
 * 风险因子权重配置（GET 查询 + PUT 保存）
 */
@RestController
@RequestMapping("/diseaseDetection/riskFactorWeight")
public class BizRiskFactorWeightController extends BaseController
{
    @Autowired
    private IBizRiskFactorWeightService bizRiskFactorWeightService;

    @PreAuthorize("@ss.hasPermi('diseaseDetection:riskFactorWeight:query')")
    @GetMapping
    public AjaxResult getConfig()
    {
        return success(bizRiskFactorWeightService.getCurrentConfig());
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:riskFactorWeight:edit')")
    @Log(title = "风险因子权重", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult save(@RequestBody RiskFactorWeightSaveRequest request)
    {
        return toAjax(bizRiskFactorWeightService.saveConfig(request, getUsername()));
    }
}
