Custom GenerateMysqlEntity class

Singleton mode:

Entry:

Generate method next

Database information:

DataBaseUtils

Reference: juejin. Cn/post / 699434…

Static data used:

Generate entity class file:

Generate all contents of class:

StringBuffer class

Construct a characterless string buffer with an initial capacity of 16 characters

CommonUtils.getTransStr

Reference: juejin. Cn/post / 699585…

getKeyStringList

Generate a Key list (a list of fields in a database table)

Generated effect:

getKeyLabelList

Generate comments corresponding to keys

Generated effect:

processAllAttrs

Generate all member variables

Generated effect:

sqlType2JavaType

Find the Java type corresponding to the SQL field type

Summary steps:
  1. Get table information. (Use DataBaseUtils)

  2. Gets the root directory path. (File type)

  3. Return the absolute path of packageOutPath (com.api.johnzeng.Entity).

  4. Generate file instance of packageOutPath (com.api.johnzeng.Entity).

  5. Generate packageOutPath (com.api.johnzeng.Entity) directory.

  6. Traverse tableInfoList.

    1. Generate file content.
    2. Use FileWriter, PrintWriter, write content, output to Entity (com.api.johnzeng.Entity) directory

Use of entity classes:

Configuration MyBatisPlugsConfig

Create mapper

Place mapper in the Mapper directory and MapperScan will scan for it

The service layer using

  1. Inject mapper using @autoWired
  2. Initialize the QueryWrapper class for the singleton
  3. Refer to the Documentation of Maybatis Plus for instructions