58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using Core;
|
|
using Core.Helpers;
|
|
using Core.Interfaces;
|
|
using Core.SpecConfig;
|
|
using Core.Yaml;
|
|
using Generator.Daos;
|
|
using Generator.Infrastructure.OpenApi;
|
|
|
|
namespace Generator.Repo;
|
|
|
|
public class GenerateRepo
|
|
{
|
|
private readonly IGeneratorDirector<OpenApiYaml> _genDirector;
|
|
private readonly DotnetDao _dotnetDao;
|
|
private readonly JavaDao _javaDao;
|
|
private readonly JavascriptDao _javascriptDao;
|
|
|
|
public GenerateRepo(
|
|
OpenApiDirector genDirector,
|
|
DotnetDao dotnetDao,
|
|
JavaDao javaDao,
|
|
JavascriptDao jsDao)
|
|
{
|
|
_genDirector = genDirector;
|
|
_dotnetDao = dotnetDao;
|
|
_javaDao = javaDao;
|
|
_javascriptDao = jsDao;
|
|
}
|
|
|
|
public async Task GenerateDotnet(GenerationType type, ISpecFile specFile)
|
|
{
|
|
var file = TypeHelper.SafeCast<ISpecFile, OpenApiYaml>(specFile);
|
|
var config = _dotnetDao.GetDotnetGenerate(type, specFile);
|
|
if (type != GenerationType.Client)
|
|
{
|
|
await _genDirector.DotnetServer(file, config);
|
|
}
|
|
else
|
|
{
|
|
await _genDirector.DotnetClient(file, config);
|
|
}
|
|
}
|
|
|
|
public async Task GenerateJava(ISpecFile specFile)
|
|
{
|
|
var file = TypeHelper.SafeCast<ISpecFile, OpenApiYaml>(specFile);
|
|
|
|
var config = _javaDao.GetJavaGenerate(specFile);
|
|
await _genDirector.Java(file, config);
|
|
}
|
|
|
|
public async Task GenerateJavascript(ISpecFile specFile)
|
|
{
|
|
var file = TypeHelper.SafeCast<ISpecFile, OpenApiYaml>(specFile);
|
|
var config = _javascriptDao.GetJavascript(file);
|
|
await _genDirector.Javascript(file, config);
|
|
}
|
|
} |