package net.northking.cctp.scriptcase.api.atuScript;

import cn.gjing.tools.auth.annotation.RequiredPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.scriptcase.api.atuScript.service.AtuScriptVersionApiService;
import net.northking.cctp.scriptcase.db.entity.AtuScriptVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "脚本版本管理")
@RequestMapping("/v1/scriptVersion")
@RestController
public class ScriptVersionCtrl {
    /**
     * 日志
     */
    private final static Logger logger = LoggerFactory.getLogger(ScriptVersionCtrl.class);

    @Autowired
    private AtuScriptVersionApiService apiService;

    @ApiOperation(value = "查看版本列表")
    @RequiredPermissions("ui-queryScriptVersionList")
    @GetMapping(value = "/scriptVersionList/{scriptId}")
    public ResultWrapper<List<AtuScriptVersion>> scriptVersionList(@PathVariable("scriptId") String scriptId)
    {
        logger.debug("start scriptVersionList");
        ResultWrapper<List<AtuScriptVersion>> wrapper = new ResultWrapper<>();
        List<AtuScriptVersion> res = apiService.scriptVersionList(scriptId);
        logger.debug("end scriptVersionList");
        return wrapper.success(res);
    }

}
