package top.baogutang.admin.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.baogutang.admin.services.IScriptService;
import top.baogutang.common.domain.Results;

import javax.annotation.Resource;

/**
 * @description: 执行脚本的controller
 * @author: nikooh
 * @date: 2023/10/12 : 13:43
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/admin/script")
public class ScriptController {

    @Resource
    private IScriptService scriptService;

    @GetMapping("/python")
    public Results<Void> execPython(@RequestParam(name = "scriptPath", required = false) String scriptPath) {
        scriptService.execPython(scriptPath);
        return Results.ok();
    }
}
