starting impl
This commit is contained in:
130
.gitignore
vendored
Normal file
130
.gitignore
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
# Directories #
|
||||
/build/
|
||||
bin/
|
||||
repos/
|
||||
/repos/
|
||||
doc/
|
||||
/doc/
|
||||
.gradle/
|
||||
/bin/
|
||||
target/
|
||||
|
||||
# OS Files #
|
||||
.DS_Store
|
||||
|
||||
# JetBrain's Idea specific stuff #
|
||||
|
||||
.idea*
|
||||
*.iml
|
||||
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
|
||||
*.class
|
||||
browscap.csv
|
||||
gradle/wrapper
|
||||
gradlew.bat
|
||||
gradlew
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.db
|
||||
|
||||
######################
|
||||
# Windows
|
||||
######################
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
######################
|
||||
# OSX
|
||||
######################
|
||||
|
||||
.DS_Store
|
||||
.svn
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
|
||||
######################
|
||||
# Eclipse
|
||||
######################
|
||||
|
||||
*.pydevproject
|
||||
.project
|
||||
.metadata
|
||||
bin/**
|
||||
tmp/**
|
||||
tmp/**/*
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
/src/main/resources/rebel.xml
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
36
build.gradle
Normal file
36
build.gradle
Normal file
@@ -0,0 +1,36 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.3.4.RELEASE'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'io.freefair.lombok' version "4.1.6" //questo
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group = 'com.gae.piaz'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '11'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' // questo
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web' // questo
|
||||
implementation 'org.mapstruct:mapstruct:1.3.1.Final' // questo
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.2' // questo
|
||||
|
||||
annotationProcessor "org.mapstruct:mapstruct-processor:1.3.1.Final"
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.12'
|
||||
|
||||
testImplementation('org.springframework.boot:spring-boot-starter-test') {
|
||||
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
2
lombok.config
Normal file
2
lombok.config
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is generated by the 'io.freefair.lombok' Gradle plugin
|
||||
config.stopBubbling = true
|
||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@@ -0,0 +1 @@
|
||||
rootProject.name = 'autogen'
|
||||
13
src/main/java/com/gae/piaz/autogen/AutogenApplication.java
Normal file
13
src/main/java/com/gae/piaz/autogen/AutogenApplication.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.gae.piaz.autogen;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class AutogenApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AutogenApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gae.piaz.autogen.controller;
|
||||
|
||||
import com.gae.piaz.autogen.model.Books;
|
||||
import com.gae.piaz.autogen.service.BooksService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/books/")
|
||||
public class BooksController implements CrudController<Books,Integer>{
|
||||
|
||||
@Autowired
|
||||
private BooksService booksService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Books> create(@RequestBody Books entity) {
|
||||
return ResponseEntity.ok(booksService.create(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Books> update(@RequestBody Books entity) {
|
||||
return ResponseEntity.ok(booksService.update(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Page<Books>> read(
|
||||
@RequestBody Books entity,
|
||||
@RequestParam("page") Integer page,
|
||||
@RequestParam("size") Integer size) {
|
||||
Pageable pageable = PageRequest.of(page,size);
|
||||
return ResponseEntity.ok(booksService.read(entity,pageable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Books> readOne(@PathVariable("id") Integer primaryKey) {
|
||||
return ResponseEntity.ok(booksService.readOne(primaryKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer primaryKey) {
|
||||
booksService.delete(primaryKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.gae.piaz.autogen.controller;
|
||||
|
||||
import com.gae.piaz.autogen.controller.dto.BooksDTO;
|
||||
import com.gae.piaz.autogen.mapper.BooksMapper;
|
||||
import com.gae.piaz.autogen.model.Books;
|
||||
import com.gae.piaz.autogen.service.BooksService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/books-dto/")
|
||||
public class BooksDTOController implements CrudController<BooksDTO,Integer>{
|
||||
|
||||
@Autowired
|
||||
private BooksService booksService;
|
||||
|
||||
@Autowired
|
||||
private BooksMapper booksMapper;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<BooksDTO> create(@RequestBody BooksDTO dto) {
|
||||
Books entity = booksMapper.toEntity(dto);
|
||||
entity = booksService.create(entity);
|
||||
return ResponseEntity.ok(booksMapper.toDto(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<BooksDTO> update(@RequestBody BooksDTO dto) {
|
||||
Books entity = booksMapper.toEntity(dto);
|
||||
entity = booksService.update(entity);
|
||||
return ResponseEntity.ok(booksMapper.toDto(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Page<BooksDTO>> read(
|
||||
@RequestBody BooksDTO dto,
|
||||
@RequestParam("page") Integer page,
|
||||
@RequestParam("size") Integer size) {
|
||||
Pageable pageable = PageRequest.of(page,size);
|
||||
Books entity = booksMapper.toEntity(dto);
|
||||
Page<BooksDTO> pages = booksService.read(entity, pageable).map(booksMapper::toDto);
|
||||
return ResponseEntity.ok(pages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<BooksDTO> readOne(@PathVariable("id") Integer primaryKey) {
|
||||
Books entity = booksService.readOne(primaryKey);
|
||||
return ResponseEntity.ok(booksMapper.toDto(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer primaryKey) {
|
||||
booksService.delete(primaryKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.gae.piaz.autogen.controller;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
||||
public interface CrudController<O,P>{
|
||||
|
||||
@PostMapping
|
||||
ResponseEntity<O> create(O object);
|
||||
|
||||
@PutMapping
|
||||
ResponseEntity<O> update(O object);
|
||||
|
||||
@PostMapping("find")
|
||||
ResponseEntity<Page<O>> read(O object, Integer page, Integer size);
|
||||
@GetMapping("{id}")
|
||||
ResponseEntity<O> readOne(P primaryKey);
|
||||
|
||||
@DeleteMapping
|
||||
void delete(P primaryKey);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.gae.piaz.autogen.controller.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BooksDTO {
|
||||
|
||||
private Integer bookId;
|
||||
|
||||
private String title;
|
||||
|
||||
private String author;
|
||||
|
||||
private String isbn;
|
||||
|
||||
private Integer year;
|
||||
|
||||
}
|
||||
14
src/main/java/com/gae/piaz/autogen/mapper/BooksMapper.java
Normal file
14
src/main/java/com/gae/piaz/autogen/mapper/BooksMapper.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.gae.piaz.autogen.mapper;
|
||||
|
||||
import com.gae.piaz.autogen.controller.dto.BooksDTO;
|
||||
import com.gae.piaz.autogen.model.Books;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface BooksMapper {
|
||||
|
||||
Books toEntity(BooksDTO dto);
|
||||
|
||||
BooksDTO toDto(Books entity);
|
||||
|
||||
}
|
||||
24
src/main/java/com/gae/piaz/autogen/model/Books.java
Normal file
24
src/main/java/com/gae/piaz/autogen/model/Books.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.gae.piaz.autogen.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity(name = "com.gae.piaz.autogen.entities.Books")
|
||||
@Table(name = "books")
|
||||
public class Books {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "\"book_id\"", nullable = false)
|
||||
private Integer bookId;
|
||||
@Column(name = "\"title\"", nullable = false)
|
||||
private String title;
|
||||
@Column(name = "\"author\"", nullable = false)
|
||||
private String author;
|
||||
@Column(name = "\"isbn\"", nullable = false)
|
||||
private String isbn;
|
||||
@Column(name = "\"year\"", nullable = false)
|
||||
private Integer year;
|
||||
|
||||
}
|
||||
27
src/main/java/com/gae/piaz/autogen/model/Carts.java
Normal file
27
src/main/java/com/gae/piaz/autogen/model/Carts.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.gae.piaz.autogen.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Entity(name = "com.gae.piaz.autogen.entities.Carts")
|
||||
@Table(name = "carts")
|
||||
@IdClass(Carts.PrimaryKeys.class)
|
||||
public class Carts {
|
||||
@Data
|
||||
public static class PrimaryKeys implements Serializable {
|
||||
private Integer userId;
|
||||
private Integer bookId;
|
||||
}
|
||||
|
||||
@Id
|
||||
@Column(name = "\"user_id\"", nullable = false)
|
||||
private Integer userId;
|
||||
@Id
|
||||
@Column(name = "\"book_id\"", nullable = false)
|
||||
private Integer bookId;
|
||||
@Column(name = "\"quantity\"", nullable = false)
|
||||
private Integer quantity;
|
||||
}
|
||||
21
src/main/java/com/gae/piaz/autogen/model/Orders.java
Normal file
21
src/main/java/com/gae/piaz/autogen/model/Orders.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.gae.piaz.autogen.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity(name = "com.gae.piaz.autogen.entities.Orders")
|
||||
@Table(name = "orders")
|
||||
public class Orders {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "\"order_id\"", nullable = false)
|
||||
private Integer orderId;
|
||||
@Column(name = "\"user_id\"", nullable = false)
|
||||
private Integer userId;
|
||||
@Column(name = "\"book_id\"", nullable = false)
|
||||
private Integer bookId;
|
||||
@Column(name = "\"quantity\"", nullable = false)
|
||||
private Integer quantity;
|
||||
}
|
||||
21
src/main/java/com/gae/piaz/autogen/model/Personphone.java
Normal file
21
src/main/java/com/gae/piaz/autogen/model/Personphone.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.gae.piaz.autogen.model;
|
||||
|
||||
import java.sql.*;
|
||||
import javax.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity(name = "com.gae.piaz.autogen.entities.Personphone")
|
||||
@Table(name = "personphone")
|
||||
public class Personphone {
|
||||
|
||||
@Column(name = "\"businessentityid\"", nullable = false)
|
||||
private Integer businessentityid;
|
||||
@Id
|
||||
@Column(name = "\"phonenumber\"", nullable = false)
|
||||
private Integer phonenumber;
|
||||
@Column(name = "\"phonenumbertypeid\"", nullable = false)
|
||||
private Integer phonenumbertypeid;
|
||||
@Column(name = "\"modifieddate\"", nullable = false)
|
||||
private Timestamp modifieddate;
|
||||
}
|
||||
19
src/main/java/com/gae/piaz/autogen/model/Users.java
Normal file
19
src/main/java/com/gae/piaz/autogen/model/Users.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.gae.piaz.autogen.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity(name = "com.gae.piaz.autogen.entities.Users")
|
||||
@Table(name = "users")
|
||||
public class Users {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "\"user_id\"", nullable = false)
|
||||
private Integer userId;
|
||||
@Column(name = "\"first_name\"", nullable = false)
|
||||
private String firstName;
|
||||
@Column(name = "\"last_name\"", nullable = false)
|
||||
private String lastName;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.gae.piaz.autogen.repository;
|
||||
|
||||
import com.gae.piaz.autogen.model.Books;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface BooksRepository extends JpaRepository<Books, Integer> {
|
||||
|
||||
}
|
||||
42
src/main/java/com/gae/piaz/autogen/service/BooksService.java
Normal file
42
src/main/java/com/gae/piaz/autogen/service/BooksService.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.gae.piaz.autogen.service;
|
||||
|
||||
import com.gae.piaz.autogen.model.Books;
|
||||
import com.gae.piaz.autogen.repository.BooksRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class BooksService implements CrudService<Books,Integer> {
|
||||
|
||||
@Autowired
|
||||
private BooksRepository repository;
|
||||
|
||||
@Override
|
||||
public Books create(Books entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Books update(Books entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Books> read(Books entity, Pageable pageable) {
|
||||
Example<Books> booksExample = Example.of(entity);
|
||||
return repository.findAll(booksExample,pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Books readOne(Integer primaryKey) {
|
||||
return repository.getOne(primaryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer primaryKey) {
|
||||
repository.deleteById(primaryKey);
|
||||
}
|
||||
}
|
||||
17
src/main/java/com/gae/piaz/autogen/service/CrudService.java
Normal file
17
src/main/java/com/gae/piaz/autogen/service/CrudService.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.gae.piaz.autogen.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface CrudService<E,P> {
|
||||
|
||||
E create(E entity);
|
||||
|
||||
E update(E entity);
|
||||
|
||||
Page<E> read(E entity, Pageable pageable);
|
||||
E readOne(P primaryKey);
|
||||
|
||||
void delete(P primaryKey);
|
||||
|
||||
}
|
||||
16
src/main/java/gae/piaz/spring3layergen/Main.java
Normal file
16
src/main/java/gae/piaz/spring3layergen/Main.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package gae.piaz.spring3layergen;
|
||||
|
||||
import gae.piaz.spring3layergen.config.CodeGeneratorConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
CodeGeneratorConfig config = CodeGeneratorConfig.load(args[0]);
|
||||
System.out.println(config);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
25
src/main/java/gae/piaz/spring3layergen/ResourceReader.java
Normal file
25
src/main/java/gae/piaz/spring3layergen/ResourceReader.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package gae.piaz.spring3layergen;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Utility to reader classpath resources.
|
||||
*/
|
||||
public class ResourceReader {
|
||||
|
||||
private ResourceReader() {
|
||||
}
|
||||
|
||||
public static InputStream getResourceAsStream(String path) throws IOException {
|
||||
InputStream classPathResource = ResourceReader.class.getClassLoader().getResourceAsStream(path);
|
||||
if (classPathResource != null) {
|
||||
return classPathResource;
|
||||
}
|
||||
InputStream fileResource = new FileInputStream(new File(path));
|
||||
return fileResource;
|
||||
}
|
||||
|
||||
}
|
||||
4
src/main/java/gae/piaz/spring3layergen/YMLSettings.java
Normal file
4
src/main/java/gae/piaz/spring3layergen/YMLSettings.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package gae.piaz.spring3layergen;
|
||||
|
||||
public class YMLSettings {
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package gae.piaz.spring3layergen.config;
|
||||
|
||||
import gae.piaz.spring3layergen.ResourceReader;
|
||||
import lombok.Data;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* projectPath: /home/tano/workspace_autogenerate/autogen
|
||||
* outputDirectory: /src/main/java
|
||||
*
|
||||
* options:
|
||||
* dtoLayer : true
|
||||
*
|
||||
* inputPackages:
|
||||
* jpaEntities : com.gae.piaz.autogen.model
|
||||
*
|
||||
* outputPackages:
|
||||
* repositories : com.gae.piaz.autogen.repository
|
||||
* services: com.gae.piaz.autogen.service
|
||||
* controllers: com.gae.piaz.autogen.controller
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class CodeGeneratorConfig implements Serializable {
|
||||
|
||||
private String projectPath;
|
||||
private String outputDirectory;
|
||||
private Options options;
|
||||
private InputPackages inputPackages;
|
||||
private OutputPackages outputPackages;
|
||||
|
||||
private static final Yaml YAML = new Yaml();
|
||||
|
||||
public static CodeGeneratorConfig load(String path) throws IOException {
|
||||
try (InputStream is = ResourceReader.getResourceAsStream(path)) {
|
||||
try (Reader reader = new InputStreamReader(is)) {
|
||||
return YAML.loadAs(reader, CodeGeneratorConfig.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package gae.piaz.spring3layergen.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class InputPackages {
|
||||
private String jpaEntities;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package gae.piaz.spring3layergen.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Options {
|
||||
private Boolean dtoLayer;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package gae.piaz.spring3layergen.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OutputPackages {
|
||||
private String repositories;
|
||||
private String services;
|
||||
private String controllers;
|
||||
}
|
||||
1
src/main/resources/application.properties
Normal file
1
src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
7
src/main/resources/entityGenConfig.yml
Normal file
7
src/main/resources/entityGenConfig.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
jdbcSettings:
|
||||
url: "jdbc:postgresql://localhost:5432/postgres"
|
||||
username: "postgres"
|
||||
password: "postgres"
|
||||
driverClassName: "org.postgresql.Driver"
|
||||
|
||||
packageName: "com.gae.piaz.autogen.model"
|
||||
16
src/main/resources/settings.yml
Normal file
16
src/main/resources/settings.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
projectPath: /home/tano/workspace_autogenerate/autogen
|
||||
outputDirectory : /src/main/java
|
||||
options:
|
||||
dtoLayer : true
|
||||
|
||||
inputPackages:
|
||||
jpaEntities : com.gae.piaz.autogen.model
|
||||
|
||||
outputPackages:
|
||||
repositories : com.gae.piaz.autogen.repository
|
||||
services: com.gae.piaz.autogen.service
|
||||
controllers: com.gae.piaz.autogen.controller
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gae.piaz.autogen;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class AutogenApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user