Zero front-end code, a few lines of Java annotations, quickly build the background management system!

Posted by pistolfire99 on Tue, 08 Mar 2022 08:05:43 +0100

Erupt Framework # is a general background management framework. Erupt can quickly build the management page, with zero front-end code, zero CURD and automatic table creation. It can quickly develop the enterprise level Admin management background by only a single class file + Concise annotation configuration!

The background management system is very important, but there are some pain points in the development, such as low development efficiency, unsightly interface, unsatisfactory interaction, repeated workload, security vulnerabilities, back-end R & D forced to write front-end code, etc.

Erupt provides a full stack solution of enterprise level middle and back office management system, provides super many business components, simple and beautiful back office pages, supports 23 types of data components, supports multiple data sources, strict security policies, compresses the R & D cycle and reduces the R & D cost.

Note: I am not a code generator, and the code generator is not the optimal solution for background development. The essence of the code generator is to generate cumbersome background code. Once the code generated in the later stage is modified, it is difficult to merge. Although it reduces some work, the solution is not the best.

Features

  • Easy to use: you only need to understand the two annotations @ Erupt and @ EruptField to start development.
  • Simple code: zero code at the front end, no need for back-end template, controller, service and dao, just one entity class.
  • Agile Development: only single java file can realize the background management function and focus on the research and development of business and core functions.
  • Fast iteration: requirements change only needs to modify or add annotation configuration, and the iteration speed is faster than requirements discussion.
  • Powerful functions: dynamic condition processing, support functions such as addition, deletion, modification and query, agent interface, Session storage mechanism selection, behavior logging, etc.
  • High security: reliable security mechanism, login white list, menu authority verification, request header check, annotation item check, fine granularity authority control, escort your data.
  • Automatic table creation: relying on JPA, it can automatically help you complete the work related to database table creation.
  • Low intrusiveness: almost all functions are developed around annotations, which does not affect other functions of Spring Boot or the use of third-party libraries.
  • Multiple data sources: MySQL, Oracle, SQL Server, PostgreSQL, H2, and even MongoDB.
  • Various components: 23 types of components such as sliding input, time selection, switch, picture upload, code editor, automatic completion, tree, multiple selection box and map are supported
  • Rich display: ordinary text, QR code, links, pictures, HTML, code snippets, iframe, swf, etc
  • Code generation: the erupt code is concise enough, and the code generator can further improve the development efficiency.
  • Strong expansibility: support customized data source implementation, customized page, customized template, customized attachment upload mechanism, etc.
  • Beautiful interface: each interaction is carefully designed and polished for better operation experience.
  • Responsive layout: it supports PC terminal, mobile terminal and other devices of various specifications.

Erupt is a general background management framework. It is said that it has the characteristics of {ultra-low code volume, zero front-end code, zero CURD operation, no need to build tables, pure Java annotation development and so on. It is said that a complete background management system can be built in three minutes.

Er ~ it sounds like a lot of criticism. Is it so magical? Let's use it together and feel it.

First, let's build an environment. At present, Erupt supports Java version 1.8.0 and above and Spring Boot version 2.0 and above.

Build easy

pom.xml introduces the necessary jar packages

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!--User rights management-->
        <dependency>
            <groupId>xyz.erupt</groupId>
            <artifactId>erupt-upms</artifactId>
            <version>1.6.7</version>
        </dependency>
        <!--Interface data security-->
        <dependency>
            <groupId>xyz.erupt</groupId>
            <artifactId>erupt-security</artifactId>
            <version>1.6.7</version>
        </dependency>
        <!--backstage WEB Interface-->
        <dependency>
            <groupId>xyz.erupt</groupId>
            <artifactId>erupt-web</artifactId>
            <version>1.6.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>compile</scope>
        </dependency>
    </dependencies>

application.yml # file simply configure the data source, and prepare a database in advance.

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/erupt?characterEncoding=UTF8&allowMultiQueries=true        
    username: root
    password: 123456
  jpa:
    show-sql: true
    generate-ddl: true
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
  profiles:
    active: dev
  mail:
    username: xxxx@qq.com
    password: xxxxxxx
    host: smtp.qq.com
    properties:
      mail.smtp.ssl.auth: true
      mail.smtp.ssl.enable: true
      mail.smtp.ssl.required: true
server:
  port: 8888

In fact, Erupt's environment will be built here. Er ~, is it over?

We haven't done anything. The project is an empty shell. We haven't written a line of code. It seems that we haven't even built a table!

Don't worry. Let's start the project first and see a lot of table creation and insertion statements printed on the console. This is because JPA persistence is applied at the bottom of Erupt framework, and some system tables and data are preset and created.

Note: the erupt preset table will only be built once when the project is started for the first time. If you want to recreate it, you need to delete it Erupt file (usually in the workspace of the project), how to obtain the file location

System.getProperty("user.dir")

Look at the 16 system tables created in the database, of which E_ upms_ The user table is a user table. By default, there is only one administrator account, and the user name and password are erupt.

Then we visited http://127.0.0.1:8888/ , let's see what the effect is. There is a complete login page.

Log in directly with the above user name and password. erupt has realized complete permission control and other functions in advance. We have hardly written any code here. They are all encapsulated by the framework. All menu data are dynamically obtained from the database. A basic background management system is built. It's a little wow.

Interesting pages

So here comes the question...? What if you want to customize the page?

At the beginning, we said that erupt is zero front-end code, which is all developed based on Java annotations. Next, write a simple page with Java annotations to experience.

Erupt has two core annotations @ erupt and @ EruptField

  • @Erupt annotation modification class, representing the definition of a page

  • @The EruptField annotation modifies the field and represents the field name displayed on the page

  • @Power annotation controls whether to operate buttons, such as add, delete, modify, query, import, export, etc

  • @The Search annotation indicates that the field is a Search condition

  • @The Table annotation indicates that the page takes the Table corresponding to the data. If it is not set, a Table name consistent with the class name will be automatically created according to the class field value when the page is initialized for the first time.

"

There are many annotation types, which are not listed one by one. More of them can be found on the official website: https://www.erupt.xyz

Next, we define a Student class with @ Erupt and @ EruptField annotations, so that even if the page and elements are finished, is it a bit subversive.

/*
 *  @Erupt The annotation is modified on the class, and the @ EruptField annotation is modified on the field
 *  Other notes are Jpa notes
 */
@Getter
@Setter
@Erupt(name = "Student list",
        power = @Power(importable = true, export = true)
)
@Entity
//@Table(name = "t_student")
public class Student extends BaseModel {

    @EruptField(
            views = @View(title = "Student name"),
            edit = @Edit(title = "Student name", notNull = true, search = @Search(vague = true))
    )
    private String studentName;

    @EruptField(
            views = @View(title = "Class"),
            edit = @Edit(title = "Class", notNull = true)
    )
    private String studentClass;

    @EruptField(
            views = @View(title = "Student age"),
            edit = @Edit(title = "Student age", notNull = true)
    )
    private String studentAge;

    @Lob
    @EruptField(
            views = @View(title = "Student gender"),
            edit = @Edit(title = "Student gender", notNull = true)
    )
    private String studentSex;

    @EruptField(
            views = @View(title = "Assessment status"),
            edit = @Edit(title = "Assessment status", notNull = true, boolType = @BoolType(trueText = "adopt", falseText = "fail"), search = @Search)
    )
    private Boolean status;
}

However, the newly created page will not be displayed at this time. We need to manually make a mapping relationship. Customize a menu in menu maintenance. The type value must be the newly created class name # Student.

After saving and refreshing, we will see that our new page appears, and the function of the page is very complete. The basic operation, query, import and export functions are automatically realized.

A new Student information is added to the page, and the corresponding Student table has more records, and this persistence process is completely done by the framework.

Although Erupt} framework deeply encapsulates the front and back-end code, it provides rich and flexible user-defined interfaces to meet our personalized needs.

For example, when we enter new student information, we want to block the students whose name is Zhang San. We can proxy the page button function, dataProxy, and realize the custom logic. We can implement the corresponding method for which button proxy. For example, beforeAdd and afterAdd are the agents of the new buttons.

@Getter
@Setter
@Erupt(name = "Student list",dataProxy = {StudentDataProxy.class},
        power = @Power(importable = true, export = true)
)
@Entity
//@Table(name = "t_student")
public class Student extends BaseModel {

}
public class StudentDataProxy implements DataProxy<Student> {

    @Override
    public void beforeAdd(Student student) {
        //Background field verification
        if ("Zhang San".equals(student.getStudentName())) {
            throw new EruptApiErrorTip("The name cannot be Zhang San!");
        }
    }

    @Override
    public void afterAdd(Student student) {

    }
    @Override
    public void afterUpdate(Student student) {

    }

    @Override
    public void afterDelete(Student student) {
    }
 }

When we entered a classmate named Zhang San on the page, it was successfully blocked. There are many other similar functions. I won't give examples one by one here. Look at the documents~

If we want to develop the interface in the traditional way, we don't have to worry that it will conflict with Erupt's page generation rules and will not be affected at all. Moreover, Erupt integrates JPA internally and provides a ready-made dao interface, which can be developed by calling the corresponding API.

If you don't want to handwrite java code, it doesn't matter. Erupt also provides a code generator to customize Java class name and field name. You can generate code and copy it directly.

Speaking of this, I only introduced the basic features of Erupt yidui, mainly to let my friends know that there is such an agile weapon.

Not only that, it also supports rich data types. It has built-in many practical functions, such as scheduled task management, multi table joint query, front and back-end separate deployment, interface permissions, operation records, multiple data sources, mail system, black-and-white list, etc. it can be used by directly calling the API.

Say in the back

The advantages of Erupt # framework are obvious. It is fast, efficient, easy to use and quite friendly to novices. However, in the actual production environment, I just use it to do some data management of configuration dictionary.

Although its deep encapsulation makes the development simple and efficient, the Erupt framework is inadequate for systems with relatively complex business and high customization. More importantly, its community is not particularly active. After all, it is a niche framework.

However, technology always serves the business. If your business matches Erupt's temperament, don't hesitate to use it!