with and without parameters works
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
$GENERATED_CS_COMMENT
|
||||
|
||||
\#pragma warning disable 1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@ -16,6 +19,29 @@ using ${env['packagename']}.Services;
|
||||
|
||||
namespace ${env['packagename']}.Implementations
|
||||
{
|
||||
|
||||
#for $operation in $operations
|
||||
#if $operation['paramInputTypes']
|
||||
// $operation['func']
|
||||
[DataContract]
|
||||
public class ${operation['func']}InputType
|
||||
{
|
||||
#for $inputType in $operation['paramInputTypes']
|
||||
// $inputType['in']
|
||||
// $inputType['name']
|
||||
// $inputType['required']
|
||||
// $inputType['type']
|
||||
#if $inputType['required']
|
||||
[Required]
|
||||
#end if
|
||||
[DataMember(Name="$inputType['name']")]
|
||||
public int $inputType['csName'] { get; set; }
|
||||
|
||||
#end for
|
||||
}
|
||||
#end if
|
||||
#end for
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public class RegularApiImplementation : RegularApiController
|
||||
@ -31,22 +57,66 @@ namespace ${env['packagename']}.Implementations
|
||||
/// <summary>
|
||||
/// $operation['description']
|
||||
/// </summary>
|
||||
public override async Task<IActionResult> ${operation['func']}( #slurp
|
||||
#if $operation['paramsInputTypes']
|
||||
#set $sep = ""
|
||||
#for $paramsInputType in $operation['paramsInputTypes']
|
||||
$sep [FromRoute (Name = "$paramsInputType['name']")] #slurp
|
||||
#if $paramsInputType['required']
|
||||
[Required] #slurp
|
||||
#end if
|
||||
$paramsInputType['type'] $paramsInputType['name'] #slurp
|
||||
#set $sep = ","
|
||||
#end for
|
||||
#elif $operation['bodyInputType']
|
||||
public override async Task<IActionResult> ${operation['func']}(#slurp
|
||||
#if $operation['bodyInputType']
|
||||
[FromBody]$operation['bodyInputType']['csName'] $operation['bodyInputType']['apiName'] #slurp
|
||||
#end if
|
||||
#if $operation['paramInputTypes']
|
||||
#set sep = ''
|
||||
#for $inputType in $operation['paramInputTypes']
|
||||
$sep#slurp
|
||||
#if $inputType['in'] == 'query'
|
||||
[FromQuery #slurp
|
||||
#elif $inputType['in'] == 'path'
|
||||
[FromPath #slurp
|
||||
#else
|
||||
#raise Exception('Invalid in for paramInput')
|
||||
#end if
|
||||
(Name = "$inputType['name']")]#slurp
|
||||
#if $inputType['required']
|
||||
[Required()]#slurp
|
||||
#end if
|
||||
$inputType['type'] $inputType['name']#slurp
|
||||
#set sep = ', '
|
||||
#end for
|
||||
#end if
|
||||
) {
|
||||
List<$operation['resultType']['csName']> res = await _dbService.JustDoSomething<$operation['resultType']['csName']>("Hello ${operation['func']}");
|
||||
#if $operation['paramInputTypes']
|
||||
${operation['func']}InputType paramInput = new ${operation['func']}InputType();
|
||||
#for $inputType in $operation['paramInputTypes']
|
||||
paramInput.$inputType['csName'] = $inputType['name'];
|
||||
#end for
|
||||
#end if
|
||||
|
||||
List<$operation['resultType']['csName']> res = await _dbService.ReadBySelect<#slurp
|
||||
#if $operation['bodyInputType']
|
||||
$operation['bodyInputType']['csName'], #slurp
|
||||
#elif $operation['paramInputTypes']
|
||||
${operation['func']}InputType, #slurp
|
||||
#else
|
||||
Object, #slurp
|
||||
#end if
|
||||
$operation['resultType']['csName']>("#slurp
|
||||
#if not $operation['statement']
|
||||
SELECT #slurp
|
||||
#set $sep = ""
|
||||
#for $property in $types[$operation['resultType']['apiName']]['properties']
|
||||
$sep$property['sqlName'] #slurp
|
||||
#set $sep = ","
|
||||
#end for
|
||||
FROM $types[$operation['resultType']['apiName']]['sqlName']#slurp
|
||||
#else
|
||||
$operation['statement']#slurp
|
||||
#end if
|
||||
", #slurp
|
||||
#if $operation['bodyInputType']
|
||||
$operation['bodyInputType']['apiName']#slurp
|
||||
#elif $operation['paramInputTypes']
|
||||
paramInput#slurp
|
||||
#else
|
||||
null#slurp
|
||||
#end if
|
||||
);
|
||||
|
||||
// Statement:
|
||||
#if not $operation['statement']
|
||||
@ -94,3 +164,4 @@ $paramsInputType['type'] $paramsInputType['name'] #slurp
|
||||
|
||||
}
|
||||
}
|
||||
\#pragma warning restore 1591
|
||||
|
Reference in New Issue
Block a user