erp-platform/api/modules/Erp.SqlQueryManager/Erp.SqlQueryManager.Application/SqlTemplateAppService.cs

60 lines
2 KiB
C#
Raw Normal View History

2025-12-05 08:56:53 +00:00
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Erp.SqlQueryManager.Application.Contracts;
using Erp.SqlQueryManager.Domain.Services;
using Erp.SqlQueryManager.Domain.Shared;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Services;
namespace Erp.SqlQueryManager.Application;
public class SqlTemplateAppService : ApplicationService, ISqlTemplateAppService
{
private readonly ISqlTemplateProvider _templateProvider;
public SqlTemplateAppService(ISqlTemplateProvider templateProvider)
{
_templateProvider = templateProvider;
}
public Task<List<SqlTemplateDto>> GetQueryTemplatesAsync()
{
var templates = _templateProvider.GetAvailableQueryTemplates()
.Select(t => new SqlTemplateDto
{
Type = t.Type,
Name = t.Name,
Description = t.Description,
Template = _templateProvider.GetQueryTemplate(t.Type)
})
.ToList();
return Task.FromResult(templates);
}
public Task<string> GetStoredProcedureTemplateAsync(string procedureName, string schemaName = "dbo")
{
var template = _templateProvider.GetStoredProcedureTemplate(procedureName, schemaName);
return Task.FromResult(template);
}
public Task<string> GetViewTemplateAsync(string viewName, string schemaName = "dbo", bool withSchemaBinding = false)
{
var template = _templateProvider.GetViewTemplate(viewName, schemaName, withSchemaBinding);
return Task.FromResult(template);
}
public Task<string> GetFunctionTemplateAsync(string functionName, SqlFunctionType functionType, string schemaName = "dbo")
{
var template = _templateProvider.GetFunctionTemplate(functionName, functionType, schemaName);
return Task.FromResult(template);
}
public Task<string> GetQueryTemplateAsync(string templateType)
{
var template = _templateProvider.GetQueryTemplate(templateType);
return Task.FromResult(template);
}
}