added aggregateid attribute
parent
c5acb46f5a
commit
40331eba21
|
@ -1,13 +1,16 @@
|
|||
const javaModels = require('../java-model')
|
||||
const javaUnions = require('../java-unions')
|
||||
const javaType = require('../java-type')
|
||||
const Mustache = require('mustache')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const templateModel = fs.readFileSync(path.resolve(path.join('templates', 'axon-event.java.mustache')), 'utf-8')
|
||||
const templateUnion = fs.readFileSync(path.resolve(path.join('templates', 'union.java.mustache')), 'utf-8')
|
||||
|
||||
module.exports = (service) => {
|
||||
|
||||
const unions = javaUnions.mapUnions(service.unions, service.models, service.namespace)
|
||||
let models = service.models.map(model => {
|
||||
let aggregateAttribute = (model.attributes.find(attr => attr.name === 'aggregateId') || { value: {} }).value
|
||||
let aggregateId = {}
|
||||
|
@ -27,7 +30,17 @@ module.exports = (service) => {
|
|||
contents: Mustache.render(templateModel, { service, ...model })
|
||||
}
|
||||
})
|
||||
return modelFiles
|
||||
const unionFiles = unions.map(union => {
|
||||
return {
|
||||
name: `${union.name}.java`,
|
||||
dir: union.dir,
|
||||
contents: Mustache.render(templateUnion, { service, ...e })
|
||||
}
|
||||
})
|
||||
return [
|
||||
...modelFiles,
|
||||
...unionFiles
|
||||
]
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
const javaModels = require('../java-model')
|
||||
const javaUnions = require('../java-unions')
|
||||
const Mustache = require('mustache')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const templateModel = fs.readFileSync(path.resolve(path.join('templates', 'lombok-model.java.mustache')), 'utf-8')
|
||||
const templateEnum = fs.readFileSync(path.resolve(path.join('templates', 'lombok-enum.java.mustache')), 'utf-8')
|
||||
const templateUnion = fs.readFileSync(path.resolve(path.join('templates', 'union.java.mustache')), 'utf-8')
|
||||
|
||||
module.exports = (service) => {
|
||||
|
||||
const unions = javaUnions.mapUnions(service.unions, service.models, service.namespace)
|
||||
const models = javaModels.mapJavaModels(service.models, service.namespace)
|
||||
const enums = javaModels.mapJavaEnums(service.enums, service.namespace)
|
||||
|
||||
|
@ -25,9 +28,17 @@ module.exports = (service) => {
|
|||
contents: Mustache.render(templateEnum, { service, ...e })
|
||||
}
|
||||
})
|
||||
const unionFiles = unions.map(union => {
|
||||
return {
|
||||
name: `${union.name}.java`,
|
||||
dir: union.dir,
|
||||
contents: Mustache.render(templateUnion, { service, ...e })
|
||||
}
|
||||
})
|
||||
return [
|
||||
...modelFiles,
|
||||
...enumFiles
|
||||
...enumFiles,
|
||||
...unionFiles
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ module.exports = {
|
|||
return unions.map(union => {
|
||||
union.package = `${namespace}.${suffix}`
|
||||
union.name = utils.pascalcase(union.name)
|
||||
union.dir = union.package.replace(/\./g, '/')
|
||||
|
||||
union.types.forEach(type => {
|
||||
models.forEach(model => {
|
||||
|
|
|
@ -20,7 +20,7 @@ import lombok.*;
|
|||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implement.length}} {
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implements.length}} {
|
||||
|
||||
@TargetAggregateIdentifier
|
||||
private {{{aggregateId.type.name}}} {{aggregateId.name}};
|
||||
|
|
|
@ -21,13 +21,13 @@ import {{{.}}};
|
|||
{{/imports}}
|
||||
|
||||
/**
|
||||
* {{model.description}}
|
||||
* {{description}}
|
||||
* See <a href="https://app.apibuilder.io/{{service.organization.key}}/{{service.name}}/{{service.version}}#model-{{model.name}}">https://app.apibuilder.io/{{service.organization.key}}/{{service.name}}/{{service.version}}#model-{{model.name}}</a>
|
||||
*
|
||||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implement.length}}{
|
||||
public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implements.length}}{
|
||||
|
||||
{{#fields}}
|
||||
{{#description}}/** {{.}} **/{{/description}}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Auto-generated from apibuilder.io service specification.
|
||||
* apidoc-version : {{service.apidoc.version}}
|
||||
* organisation : {{service.organization.key}}
|
||||
* service-version : {{service.version}}
|
||||
*
|
||||
* Documentation at:
|
||||
* <a href="https://app.apibuilder.io/{{service.organization.key}}/{{service.name}}/{{service.version}}">https://app.apibuilder.io/{{service.organization.key}}/{{service.name}}/{{service.version}}</a>
|
||||
*
|
||||
**/
|
||||
package {{package}};
|
||||
|
||||
/**
|
||||
* {{description}}
|
||||
* See <a href="https://app.apibuilder.io/{{service.organization.key}}/{{service.name}}/{{service.version}}#model-{{model.name}}">https://app.apibuilder.io/{{service.organization.key}}/{{service.name}}/{{service.version}}#model-{{model.name}}</a>
|
||||
*
|
||||
**/
|
||||
public interface {{name}} {
|
||||
|
||||
}
|
Loading…
Reference in New Issue