not yet working support for list input parameters
This commit is contained in:
25
DbService.cs
25
DbService.cs
@ -2,8 +2,10 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -106,10 +108,27 @@ namespace com.krohne.genericdatabaseapiservice.Services {
|
||||
Logger.LogInformation("Input Property name: {0} {1} ", propertyInfo.Name, propertyInfo.PropertyType);
|
||||
var attributes = propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), true);
|
||||
var dma = (DataMemberAttribute)attributes[0];
|
||||
Logger.LogInformation("Input DataMember name: {0} {1} ", dma.Name, dma.TypeId);
|
||||
Logger.LogInformation("Input DataMember name: {0} {1}", dma.Name, dma.TypeId);
|
||||
var value = propertyInfo.GetValue(input);
|
||||
Logger.LogInformation("Input Value: {0}", value);
|
||||
cmd.Parameters.AddWithValue(dma.Name, propertyInfo.GetValue(input));
|
||||
Type typ = value.GetType();
|
||||
var isList = typ.IsGenericType && (typ.GetGenericTypeDefinition() == typeof(List<>));
|
||||
if (isList) {
|
||||
var p1 = propertyInfo.GetValue(input) as System.Collections.IEnumerable;
|
||||
var p2 = new StringBuilder();
|
||||
var sep = "";
|
||||
foreach (var x in p1) {
|
||||
Logger.LogInformation("x: {0}", x);
|
||||
p2.Append(sep);
|
||||
p2.Append(x);
|
||||
sep = ",";
|
||||
}
|
||||
var p3 = p2.ToString();
|
||||
Logger.LogInformation("Input Value: p3:{0} typ:{1} isList:{2}", p3, typ, isList);
|
||||
cmd.Parameters.AddWithValue(dma.Name, p3);
|
||||
} else {
|
||||
Logger.LogInformation("Input Value: {0} {1} {2}", value, typ, isList);
|
||||
cmd.Parameters.AddWithValue(dma.Name, value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logger.LogInformation("no input data");
|
||||
|
@ -121,7 +121,12 @@ for path in apiDefinition['paths'].values():
|
||||
paramInputTypes = []
|
||||
if 'parameters' in operation:
|
||||
for paramsInputType in operation['parameters']:
|
||||
paramsInputType['type'] = CsTypeConverter(paramsInputType['schema']['type'])
|
||||
if paramsInputType['schema']['type'] == 'array':
|
||||
paramsInputType['type'] = CsTypeConverter(paramsInputType['schema']['items']['type'])
|
||||
paramsInputType['isList'] = True
|
||||
else:
|
||||
paramsInputType['type'] = CsTypeConverter(paramsInputType['schema']['type'])
|
||||
paramsInputType['isList'] = False
|
||||
del paramsInputType['schema']
|
||||
paramsInputType['csName'] = CsOperationNameConverter(paramsInputType['name'])
|
||||
paramInputTypes.append(paramsInputType)
|
||||
|
22
openapi.yaml
22
openapi.yaml
@ -158,7 +158,7 @@ paths:
|
||||
500:
|
||||
$ref: "#/components/responses/serverSideError"
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
/pdb/v2/pcbItem/{serialNumbers}:
|
||||
/pdb/v2/pcbItem:
|
||||
get:
|
||||
tags: [ "Regular" ]
|
||||
operationId: Regular.pcbItem
|
||||
@ -170,14 +170,14 @@ paths:
|
||||
DATABASETAGEND
|
||||
STATEMENTBEGIN
|
||||
SELECT
|
||||
sn.seriennummer AS serial_number
|
||||
,CAST(sn.produktionsauftrag AS INT) AS production_order
|
||||
,sn.n AS batch_index
|
||||
,(CASE WHEN auftraege.artikelcode LIKE 'T%' THEN CAST(SUBSTRING(auftraege.artikelcode, 2) AS INT) ELSE CAST(auftraege.artikelcode AS INT) END) AS article_code
|
||||
,(CASE WHEN ISNULL(ems.Seriennummer) THEN auftraege.IX ELSE ems.Equi_index END) AS bom_index
|
||||
,(CASE WHEN ISNULL(ems.Seriennummer) THEN FALSE ELSE TRUE END) AS has_ems_update
|
||||
sn.seriennummer AS serialNumber
|
||||
,CAST(sn.produktionsauftrag AS INT) AS productionOrder
|
||||
,sn.n AS batchIndex
|
||||
,(CASE WHEN auftraege.artikelcode LIKE 'T%' THEN CAST(SUBSTRING(auftraege.artikelcode, 2) AS INT) ELSE CAST(auftraege.artikelcode AS INT) END) AS articleCode
|
||||
,(CASE WHEN ISNULL(ems.Seriennummer) THEN auftraege.IX ELSE ems.Equi_index END) AS bomIndex
|
||||
,(CASE WHEN ISNULL(ems.Seriennummer) THEN FALSE ELSE TRUE END) AS hasEmsUpdate
|
||||
,stammdaten.bezeichnung AS description
|
||||
,(CASE WHEN modulindex.modulindex = "" THEN NULL ELSE modulindex.modulindex END) AS module_index
|
||||
,(CASE WHEN modulindex.modulindex = \"\" THEN NULL ELSE modulindex.modulindex END) AS moduleIndex
|
||||
FROM sn
|
||||
JOIN auftraege ON sn.produktionsauftrag = auftraege.produktionsauftrag
|
||||
JOIN stammdaten ON auftraege.artikelcode = stammdaten.Artikelcode
|
||||
@ -373,7 +373,11 @@ components:
|
||||
deliveryDate:
|
||||
type: dateTime
|
||||
nullable: true
|
||||
pcbItem:
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
pcbItem:
|
||||
description: pcb items selected by serial number
|
||||
type: object
|
||||
properties:
|
||||
serialNumber:
|
||||
type: integer
|
||||
nullable: true
|
||||
|
@ -29,8 +29,15 @@ namespace ${env['packagename']}.Implementations
|
||||
[Required]
|
||||
#end if
|
||||
[DataMember(Name="$inputType['name']")]
|
||||
public $inputType['type'] $inputType['csName'] { get; set; }
|
||||
|
||||
public #slurp
|
||||
#if $inputType['isList']
|
||||
List<#slurp
|
||||
#end if
|
||||
$inputType['type']#slurp
|
||||
#if $inputType['isList']
|
||||
>#slurp
|
||||
#end if
|
||||
$inputType['csName'] { get; set; }
|
||||
#end for
|
||||
}
|
||||
#end if
|
||||
@ -65,7 +72,14 @@ $sep#slurp
|
||||
#if $inputType['required']
|
||||
[Required()]#slurp
|
||||
#end if
|
||||
$inputType['type'] $inputType['name']#slurp
|
||||
#if $inputType['isList']
|
||||
List<#slurp
|
||||
#end if
|
||||
$inputType['type']#slurp
|
||||
#if $inputType['isList']
|
||||
>#slurp
|
||||
#end if
|
||||
$inputType['name']#slurp
|
||||
#set sep = ', '
|
||||
#end for
|
||||
#end if
|
||||
|
Reference in New Issue
Block a user