package com.huatek.busi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.service.BusiSemiAutomaticEvaluateConfigService;
import com.huatek.busi.dto.BusiSemiAutomaticEvaluateConfigDto;
import com.huatek.busi.vo.BusiSemiAutomaticEvaluateConfigVo;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;
import com.huatek.torch.frame.validate.KerValid;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * @description BusiSemiAutomaticEvaluateConfigController
 *
 * @author Kavon
 * @date 2023/11/28 18:08
 */
@Api(tags = { Tags.BUSI_SEMI_AUTOMATIC_EVALUATE_CONFIG })
@RestController
@RequestMapping("/api/BusiSemiAutomaticEvaluateConfig")
public class BusiSemiAutomaticEvaluateConfigController {


    @Reference(check = false)
    private BusiSemiAutomaticEvaluateConfigService busiSemiAutomaticEvaluateConfigService;


    @ApiOperation(value = "查询最新半自动评估配置")
    @GetMapping(value = "/findNewestConfig", produces = { "application/json;charset=utf-8" })
    public Map<String, Object> findNewestConfig() {
        BusiSemiAutomaticEvaluateConfigVo configVo = busiSemiAutomaticEvaluateConfigService.findNewestConfig();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", configVo);
    }

    @ApiOperation(value = "初始化配置")
    @PostMapping(value = "/initConfig", produces = { "application/json;charset=utf-8" })
    public Map<String, Object> initConfig(@RequestHeader("token")String token) {
        busiSemiAutomaticEvaluateConfigService.initConfig(token);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
    }

    @ApiOperation(value = "修改配置")
    @PostMapping(value = "/updateConfig", produces = { "application/json;charset=utf-8" })
    public @KerValid Map<String, Object> updateConfig(@RequestHeader("token")String token, @RequestBody BusiSemiAutomaticEvaluateConfigDto dto) {
        busiSemiAutomaticEvaluateConfigService.updateConfig(token,dto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
    }

}