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;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -106,10 +108,27 @@ namespace com.krohne.genericdatabaseapiservice.Services {
|
|||||||
Logger.LogInformation("Input Property name: {0} {1} ", propertyInfo.Name, propertyInfo.PropertyType);
|
Logger.LogInformation("Input Property name: {0} {1} ", propertyInfo.Name, propertyInfo.PropertyType);
|
||||||
var attributes = propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), true);
|
var attributes = propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), true);
|
||||||
var dma = (DataMemberAttribute)attributes[0];
|
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);
|
var value = propertyInfo.GetValue(input);
|
||||||
Logger.LogInformation("Input Value: {0}", value);
|
Type typ = value.GetType();
|
||||||
cmd.Parameters.AddWithValue(dma.Name, propertyInfo.GetValue(input));
|
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 {
|
} else {
|
||||||
Logger.LogInformation("no input data");
|
Logger.LogInformation("no input data");
|
||||||
|
@ -121,7 +121,12 @@ for path in apiDefinition['paths'].values():
|
|||||||
paramInputTypes = []
|
paramInputTypes = []
|
||||||
if 'parameters' in operation:
|
if 'parameters' in operation:
|
||||||
for paramsInputType in operation['parameters']:
|
for paramsInputType in operation['parameters']:
|
||||||
|
if paramsInputType['schema']['type'] == 'array':
|
||||||
|
paramsInputType['type'] = CsTypeConverter(paramsInputType['schema']['items']['type'])
|
||||||
|
paramsInputType['isList'] = True
|
||||||
|
else:
|
||||||
paramsInputType['type'] = CsTypeConverter(paramsInputType['schema']['type'])
|
paramsInputType['type'] = CsTypeConverter(paramsInputType['schema']['type'])
|
||||||
|
paramsInputType['isList'] = False
|
||||||
del paramsInputType['schema']
|
del paramsInputType['schema']
|
||||||
paramsInputType['csName'] = CsOperationNameConverter(paramsInputType['name'])
|
paramsInputType['csName'] = CsOperationNameConverter(paramsInputType['name'])
|
||||||
paramInputTypes.append(paramsInputType)
|
paramInputTypes.append(paramsInputType)
|
||||||
|
20
openapi.yaml
20
openapi.yaml
@ -158,7 +158,7 @@ paths:
|
|||||||
500:
|
500:
|
||||||
$ref: "#/components/responses/serverSideError"
|
$ref: "#/components/responses/serverSideError"
|
||||||
# --------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------------
|
||||||
/pdb/v2/pcbItem/{serialNumbers}:
|
/pdb/v2/pcbItem:
|
||||||
get:
|
get:
|
||||||
tags: [ "Regular" ]
|
tags: [ "Regular" ]
|
||||||
operationId: Regular.pcbItem
|
operationId: Regular.pcbItem
|
||||||
@ -170,14 +170,14 @@ paths:
|
|||||||
DATABASETAGEND
|
DATABASETAGEND
|
||||||
STATEMENTBEGIN
|
STATEMENTBEGIN
|
||||||
SELECT
|
SELECT
|
||||||
sn.seriennummer AS serial_number
|
sn.seriennummer AS serialNumber
|
||||||
,CAST(sn.produktionsauftrag AS INT) AS production_order
|
,CAST(sn.produktionsauftrag AS INT) AS productionOrder
|
||||||
,sn.n AS batch_index
|
,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 article_code
|
,(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 bom_index
|
,(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 has_ems_update
|
,(CASE WHEN ISNULL(ems.Seriennummer) THEN FALSE ELSE TRUE END) AS hasEmsUpdate
|
||||||
,stammdaten.bezeichnung AS description
|
,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
|
FROM sn
|
||||||
JOIN auftraege ON sn.produktionsauftrag = auftraege.produktionsauftrag
|
JOIN auftraege ON sn.produktionsauftrag = auftraege.produktionsauftrag
|
||||||
JOIN stammdaten ON auftraege.artikelcode = stammdaten.Artikelcode
|
JOIN stammdaten ON auftraege.artikelcode = stammdaten.Artikelcode
|
||||||
@ -373,7 +373,11 @@ components:
|
|||||||
deliveryDate:
|
deliveryDate:
|
||||||
type: dateTime
|
type: dateTime
|
||||||
nullable: true
|
nullable: true
|
||||||
|
# --------------------------------------------------------------------------------------------------
|
||||||
pcbItem:
|
pcbItem:
|
||||||
|
description: pcb items selected by serial number
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
serialNumber:
|
serialNumber:
|
||||||
type: integer
|
type: integer
|
||||||
nullable: true
|
nullable: true
|
||||||
|
@ -29,8 +29,15 @@ namespace ${env['packagename']}.Implementations
|
|||||||
[Required]
|
[Required]
|
||||||
#end if
|
#end if
|
||||||
[DataMember(Name="$inputType['name']")]
|
[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 for
|
||||||
}
|
}
|
||||||
#end if
|
#end if
|
||||||
@ -65,7 +72,14 @@ $sep#slurp
|
|||||||
#if $inputType['required']
|
#if $inputType['required']
|
||||||
[Required()]#slurp
|
[Required()]#slurp
|
||||||
#end if
|
#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 = ', '
|
#set sep = ', '
|
||||||
#end for
|
#end for
|
||||||
#end if
|
#end if
|
||||||
|
Reference in New Issue
Block a user