added jpa entity generator
This commit is contained in:
parent
c29498eb96
commit
0e617b6fdc
|
@ -12,7 +12,7 @@ module.exports = {
|
||||||
model.dir = model.package.replace(/\./g, '/')
|
model.dir = model.package.replace(/\./g, '/')
|
||||||
model.fields = model.fields.map(field => {
|
model.fields = model.fields.map(field => {
|
||||||
field.name = utils.camelcase(field.name)
|
field.name = utils.camelcase(field.name)
|
||||||
field.type = javaType.mapJavaType(field.type, namespace)
|
field.type = javaType.mapJavaType(field.type, namespace, 'Entity')
|
||||||
|
|
||||||
if(field.type.fullQualifiedName && field.type.fullQualifiedName.includes('models')) {
|
if(field.type.fullQualifiedName && field.type.fullQualifiedName.includes('models')) {
|
||||||
field.type.fullQualifiedName = field.type.fullQualifiedName.replace('models', 'db')
|
field.type.fullQualifiedName = field.type.fullQualifiedName.replace('models', 'db')
|
||||||
|
|
|
@ -50,19 +50,17 @@ const SUPPORTED_TYPES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getCustomType(type, namespace) {
|
function getCustomType(type, namespace, suffix) {
|
||||||
|
|
||||||
console.log("====== CUSTOM: " + type)
|
|
||||||
|
|
||||||
let match = LAST_ELEMENT_REGEX.exec(type)
|
let match = LAST_ELEMENT_REGEX.exec(type)
|
||||||
let name = ''
|
let name = ''
|
||||||
let importstatement = null
|
let importstatement = null
|
||||||
if(match) {
|
if(match) {
|
||||||
name = utils.pascalcase(match[2])
|
name = utils.pascalcase(match[2])
|
||||||
importstatement = `${match[1].replace('enums', 'models')}.${name}`
|
importstatement = `${match[1].replace('enums', 'models')}.${name}${suffix}`
|
||||||
}else {
|
}else {
|
||||||
name = utils.pascalcase(type)
|
name = utils.pascalcase(type)
|
||||||
importstatement = `${namespace}.models.${name}`
|
importstatement = `${namespace}.models.${name}${suffix}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -86,9 +84,9 @@ function mapCollection(type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mapJavaType: (type, namespace) => {
|
mapJavaType: (type, namespace, suffix) => {
|
||||||
const baseType = COLLECTION_REGEX.exec(type)[1]
|
const baseType = COLLECTION_REGEX.exec(type)[1]
|
||||||
let javaType = SUPPORTED_TYPES[baseType] || getCustomType(baseType, namespace)
|
let javaType = SUPPORTED_TYPES[baseType] || getCustomType(baseType, namespace, suffix)
|
||||||
|
|
||||||
if(type.startsWith('[')) {
|
if(type.startsWith('[')) {
|
||||||
javaType = mapCollection(javaType);
|
javaType = mapCollection(javaType);
|
||||||
|
|
Loading…
Reference in a new issue