package com.brilliance.isc.es.validator.test.controller;

import com.brilliance.isc.common.validator.es.support.impl.EsScriptValidator;
import com.brilliance.isc.common.validator.es.utils.EsConstant;
import com.brilliance.isc.common.validator.es.vo.EnvDespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 按照交易、模块输出JS文件，供Vue调用
 * @author fukai
 */
@RestController
public class EsScriptResource {

    @Autowired
    private EsScriptValidator esScriptValidator;

    /**
     * 输出某交易下的校验规则
     * @param transName 交易名/规则名
     * @return
     */
    @GetMapping("/visitTransScript/{transName}")
    public String outputScript(@PathVariable("transName") String transName){
        EnvDespVo envDespVo = EnvDespVo.builder()
                .scriptName(transName)
                .terminal(EsConstant.VUE_TERMINAL)
                .subtype(EsConstant.JS_TYPE).build();
        return esScriptValidator.outputScript(envDespVo,null);
    }


}
