hzio / CoffeeMaker

A handy tool to generate universal code template.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CoffeeMaker

A convenient and well-designed tool for generating universal code.

Design

+----------+  JDBC     +---------------------+    TableMetadata      +------------------------+
|          | ------>   |                     |   ---------------->   |  DefinitionConverter   |
| Database |           |  MetadataProvider   |                       +------------------------+
|          |           |                     |                         |
|          |           |                     |                         | FileDefinition
+----------+           +---------------------+                         v
                                                                   +- - - - - - - - - - - - - - +
                                                                   ' Various of file wrappers   '
                                                                   '                            '
                                                                   ' +------------------------+ '
                                                                   ' |      FileWrapper       | '
                                                                   ' +------------------------+ '
                                                                   '                            '
                                                                   +- - - - - - - - - - - - - - +
                                                                       |
                                                                       |
                                                                       |
                     +- - - - - - - - - - - - -+                       |
                     ' OUTPUT:                 '                       |
                     '                         '                       |
                     ' XxxEntity.java          '                       |
                     ' XxxMapper.xml           '                       |
                     ' XxxDao.java             '                       |
                     ' XxxService.java         '                       |
                     ' XxxServiceImpl.java     '                       |
                     ' XxxController.java      '                       |
                     ' XxxVo.java              '                       |
                     '                         '                       v
                     ' +---------------------+ '  Parse & export     +------------------------+
                     ' | Ultimate Code Files | ' <----------------   |                        |
                     ' +---------------------+ '                     |       FileParser       |
                     '                         '                     |                        |
                     +- - - - - - - - - - - - -+                     +------------------------+

Usage

Step one. Configuration

  1. Config datasource properties src/main/resource/config.properties

  2. Config code generation rules

Configuration configuration = new Configuration();
        configuration.setTableName("t_user")
            .setTablePrefix("")
            .setPackageName("com.workholiday")
            .setPagerPackageName("com.workholiday.base.core.page")
            .setWithPager(true)
            .setOutputPath("/Users/hunterzhao/tmp/output");

Step two. Generation

Launch CoffeeMaker via main method of CoffeeMakerLauncher.

Step three. Enjoy :D

Generate code template list:

  • Entity file
  • DAO file
  • Mbatis mapper file
  • Service file
  • Service implementation file
  • VO file
  • Controller file

Scalability

To customize code generation template by adding(editing) self-defined(existing) FileWrapper and FileTemplate

About

A handy tool to generate universal code template.

License:Apache License 2.0


Languages

Language:Java 100.0%