Considering Code Generation[Cook receipe],

Why & what:

I wrote a simple single table ORM in JMVC, so, recently when I am wring a website, I found writing single table business logic really unnecessary, it takes much time, and this just keeps being repeated all the time since the database usually have too many tables, but saving everything in one table that has root is not a good thinking, and the sqlBuilder was written, I am considering using the template engine in Java to create a simple table module CRUD code generation tool, of course, if writng dynamic form, this kind of code could be configured with one table data source configure, but sometimes using multiple pages make more sense.

How:

Then how to draft such a tool,

1. Create List page, create page, save page templates

2. For each template, use entity properties as fields, add Ajax and route for backend interaction

3. Backend controller code generation

Prerequits:

1. Backend template, frontend template, reflectionHelper in Java to get info of a single entity

2. Template engine

3. Database connection

refs:

1. Retrieving fields from a Java class: https://www.baeldung.com/java-reflection-class-fields 

2. Thymeleaf: https://www.thymeleaf.org/doc/tutorials/3.1/usingthymeleaf.html#executing-the-template-engine

3. Java File and Path operations

4. Reading database table schemas and generate entities[already in JMVC]

留下你的评论
评论
2023-4-23 下午1:21
This just leads to thinking of code generation based on springboot and JPA, BE might be more stable,
2023-4-23 下午1:21
This just leads to thinking of code generation based on springboot and JPA, BE might be more stable,