diff --git a/src/components/designer/es-modeling/panels/CommandDefinitionPanel.vue b/src/components/designer/es-modeling/panels/CommandDefinitionPanel.vue index 9e85f332..1f498146 100644 --- a/src/components/designer/es-modeling/panels/CommandDefinitionPanel.vue +++ b/src/components/designer/es-modeling/panels/CommandDefinitionPanel.vue @@ -302,6 +302,7 @@ }, "value.controllerInfo.method": function(newVal) { this.setApiPath() + this.setHttpCommand() }, "value.restRepositoryInfo.method":function(newVal){ this.setHttpCommand() @@ -424,25 +425,23 @@ var tempField = ''; if(target.isVO){ var field = target.fieldDescriptors - for(var i = 0; i < field.length; i++){ - var voField = ''; - - switch(field[i].className){ + field.forEach(item => { + switch(item.className) { case "String": - tempField = tempField.concat(`"${field[i].nameCamelCase}":"value"`, ", "); + tempField = tempField.concat(`"${item.nameCamelCase}":"value"`, ", "); break; case "Long": case "Integer": case "Float": case "BigDecimal": case "Double": - tempField = tempField.concat(`"${field[i].nameCamelCase}":"0"`, ", "); + tempField = tempField.concat(`"${item.nameCamelCase}":"0"`, ", "); break; case "Boolean": - tempField = tempField.concat(`"${field[i].nameCamelCase}":"true"`, ", "); + tempField = tempField.concat(`"${item.nameCamelCase}":"true"`, ", "); break; } - } + }); tempField = tempField.slice(0, -2); fieldDescriptorsName = fieldDescriptorsName.concat(`${target.nameCamelCase}:='{${tempField}}' `); @@ -486,8 +485,56 @@ if(me.value.fieldDescriptors && me.value.fieldDescriptors.length > 0 ){ fieldDescriptorsName = '' me.value.fieldDescriptors.forEach(function (fieldItem) { - if(!fieldItem.isKey){ - fieldDescriptorsName = fieldDescriptorsName.concat(`${fieldItem.name}="value" ` ) + if(!fieldItem.isKey && !fieldItem.isVO && (fieldItem.className == 'String' || fieldItem.className == 'Long' || fieldItem.className == 'Integer' || fieldItem.className == 'Double' || fieldItem.className == 'BigDecimal')){ + switch(fieldItem.className){ + case "String": + fieldDescriptorsName = fieldDescriptorsName.concat(`${fieldItem.name}="value" ` ) + break; + case "Long": + case "Integer": + case "Float": + case "BigDecimal": + case "Double": + fieldDescriptorsName = fieldDescriptorsName.concat(`${fieldItem.name}=0 ` ) + break; + case "Boolean": + fieldDescriptorsName = fieldDescriptorsName.concat(`${fieldItem.name}=true ` ) + break; + } + }else if(!fieldItem.isKey && (fieldItem.className != 'String' || fieldItem.className != 'Long' || fieldItem.className != 'Integer' || fieldItem.className != 'Double' || fieldItem.className != 'BigDecimal')){ + Object.values((me.relatedAggregate.aggregateRoot.entities.relations) || {}) + .filter(relation => relation.targetElement.namePascalCase === fieldItem.className) + .forEach((field) => { + var target = field.targetElement; + var tempField = ''; + if(target.isVO){ + var field = target.fieldDescriptors + field.forEach(item => { + switch(item.className) { + case "String": + tempField = tempField.concat(`"${item.nameCamelCase}":"value"`, ", "); + break; + case "Long": + case "Integer": + case "Float": + case "BigDecimal": + case "Double": + tempField = tempField.concat(`"${item.nameCamelCase}":"0"`, ", "); + break; + case "Boolean": + tempField = tempField.concat(`"${item.nameCamelCase}":"true"`, ", "); + break; + } + }); + tempField = tempField.slice(0, -2); + fieldDescriptorsName = fieldDescriptorsName.concat(`${target.nameCamelCase}:='{${tempField}}' `); + + }else{ + if(target._type.endsWith("enum")){ + fieldDescriptorsName = fieldDescriptorsName.concat(`${fieldItem.name}="${target.items[0].value}" ` ) + } + } + }); } }) } @@ -502,11 +549,11 @@ } else { // Controller -> Extend Verb if(me.value.controllerInfo.method == 'POST'){ - me.commandExample = `http POST localhost:8080/${pluralize(changeCase.camelCase(me.relatedAggregateName))} ${fieldDescriptorsName}` + me.commandExample = `http POST localhost:8080/${pluralize(changeCase.camelCase(me.relatedAggregateName))}${me.value.controllerInfo.apiPath} ${fieldDescriptorsName}` }else if(me.value.controllerInfo.method == 'PUT'){ - me.commandExample = `http PUT localhost:8080/${pluralize(changeCase.camelCase(me.relatedAggregateName))}/1/${me.value.controllerInfo.apiPath} ${descriptorName}="{value}"` + me.commandExample = `http PUT localhost:8080/${pluralize(changeCase.camelCase(me.relatedAggregateName))}/1/${me.value.controllerInfo.apiPath} ${fieldDescriptorsName}` }else if(me.value.controllerInfo.method == 'DELETE'){ - me.commandExample = `http DELETE localhost:8080/${pluralize(changeCase.camelCase(me.relatedAggregateName))}/1/${me.value.controllerInfo.apiPath} ${descriptorName}="{value}"` + me.commandExample = `http DELETE localhost:8080/${pluralize(changeCase.camelCase(me.relatedAggregateName))}/1/${me.value.controllerInfo.apiPath} ${fieldDescriptorsName}` } me.setApiPath() }