Ejemplo n.º 1
0
        public async Task <IActionResult> C([FromRoute] string act, string code)
        {
            if (string.IsNullOrEmpty(act))
            {
                return(APIReturn.BuildFail("无效的请求"));
            }
            if (string.IsNullOrEmpty(code))
            {
                return(APIReturn.BuildFail("code不能为空"));
            }
            string codeStr = code.Base64ToString();

            if (string.IsNullOrEmpty(codeStr))
            {
                return(APIReturn.BuildFail("无效的code"));
            }

            CmResult cm = null;

            if ("c".Equals(act))
            {
                cm = await coreService.C(codeStr);
            }
            else if ("cpp".Equals(act))
            {
                cm = await coreService.CPlusPlus(codeStr);
            }
            else if ("java".Equals(act))
            {
                cm = await coreService.Java(codeStr);
            }
            else if ("python".Equals(act))
            {
                cm = await coreService.Python(codeStr);
            }
            else if ("csharp".Equals(act))
            {
                cm = await coreService.CSharp(codeStr);
            }
            else if ("nodejs".Equals(act))
            {
                cm = await coreService.Nodejs(codeStr);
            }
            else
            {
                cm = CmResult.BuildFail("", "无效的请求");
            }
            if (cm.Success)
            {
                return(APIReturn.BuildSuccess(cm.Message));
            }
            return(APIReturn.BuildFail(cm.ExecMsg));
        }