Erupt Framework:开源神器,助你无需前端代码搞定企业级后台管理系统_只适用于erupt 后端

而且,当今互联网流量被巨头瓜分,冰川表面的部分已经没有太大空间,而尚未完全被信息技术赋能的各行各业才是未来市场的爆发点。而对于这些行业来说,后台的需求才是核心。

如何提高后台开发的效率?

尽管对企业来说业务流程的细微差异影响巨大,但后台管理系统的设计与实现却可以遵循一定的规律。

因此,针对后台系统开发,市面上有不少成熟的前端 UI 模板,比如蚂蚁的 Ant Design,老派的 Ext.js 等,这些框架简化了前端人员的开发流程,但对整个系统来说,开发的成本依然很高,仍然是两套体系。有的公司可能没有条件养活两个团队,后端经常要被迫写前端代码。

那有没有可能更进一步,仅使用后端技术即可完成开发呢?

我相信看到这里,很多小伙伴想到了代码生成器,但是它真的是最好的解决方案吗?

它的本质还是通过类似全篇翻译的方式生成繁琐的代码,缺少足够的灵活性。后期需要修改时,生成的代码将很难完成合并,想想 Mybatis-Generator,基本上就是一次性的东西。

今天我们要介绍的神器,就是一个可以全程无需写任何前端代码,不需要写多层的 CURD 逻辑,也不需要手动建表,仅需一个类文件就可快速构建发企业级 Admin 管理后台的框架 —— Erupt Framework。

它不但能够提高效率,将后端小伙伴从被迫写前端的困境中解脱出来,还顺便解决了美观问题,上几张图你们感受一下:

login

code

log

tpl

chart

下面是项目演示地址,可以自行访问:

https://www.erupt.xyz/demo (自适应布局,支持手机端访问)

也可以动手试一下:

简单4步,搭建 0 前端代码的后台管理系统

I.创建 Spring Boot 项目 → Spring Initializr

II.在 pom.xml 中添加 erupt 依赖包

<!--用户权限管理-->
<dependency>
  <groupId>xyz.erupt</groupId>
  <artifactId>erupt-upms</artifactId>
  <version>1.5.2</version>
</dependency>
<!--接口数据安全-->
<dependency>
  <groupId>xyz.erupt</groupId>
  <artifactId>erupt-security</artifactId>
  <version>1.5.2</version>
</dependency>
<!--后台WEB界面-->
<dependency>
  <groupId>xyz.erupt</groupId>
  <artifactId>erupt-web</artifactId>
  <version>1.5.2</version>
</dependency>

III.在 application.yml / application.properties 中添加数据库配置与 JPA 配置

# 配置以mysql为例,当然erupt也支持其他管理型数据库,如Oracle、PostgreSQL、SQL Server等
spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/erupt
    username: root
    password: 1234567
  jpa:
    show-sql: true
    generate-ddl: true
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql

IV.修改 Spring Boot 入口类

package com.example.demo;

@SpringBootApplication                  // ↓ xyz.erupt必须有
@ComponentScan({"xyz.erupt","com.xxx"}) // ↓ com.xxx要替换成实际需要扫描的代码包
@EntityScan({"xyz.erupt","com.xxx"})    // ↓ 例如DemoApplication所在的包为 com.example.demo
@EruptScan({"xyz.erupt","com.xxx"})     // → 则:com.xxx → com.example.demo
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

大功告成😄

瞅瞅启动后的效果

1

2

3

无需手动执行初始化 sql 脚本,启动成功后,自带菜单维护、组织维护、角色维护、用户维护、字典维护、登录日志与操作日志功能!

再加点功能热热身

Hello World
@Erupt(name = "入门示例")         //erupt核心类注解
@Table(name = "t\_hello\_world")  //数据库表名
@Entity                        //JPA实体类标识
public class HelloWorld extends BaseModel { //BaseModel中仅定义了主键信息

    @EruptField(
            views = @View(title = "文本"),
            edit = @Edit(title = "文本")
    )
    private String input;

    @EruptField(
            views = @View(title = "数值"),
            edit = @Edit(title = "数值")
    )
    private Float number1;

    @EruptField(
            views = @View(title = "布尔"),
            edit = @Edit(title = "布尔")
    )
    private Boolean bool;


    @EruptField(
            views = @View(title = "时间"),
            edit = @Edit(title = "时间")
    )
    private Date dateField;

}

将类名 HelloWorld 添加至菜单、配置如下:

4

添加成功后刷新页面即可看到入门示例菜单,效果如下:

5

6

生成的数据库表

create table demo_simple
(
    id         bigint auto\_increment primary key,
    bool       bit          null,
    date_field datetime     null,
    input      varchar(255) null,
    number1    float        null
);

7

增、删、改、查、列控制等功能全部都可以直接用,无需任何额外代码!

学生管理
@Erupt(name = "学生管理")
@Table(name = "demo\_student")
@Entity
public class Student extends BaseModel {

    @EruptField(
            views = @View(title = "姓名"),
            edit = @Edit(title = "姓名")
    )
    private String name;

    @EruptField(
            views = @View(title = "性别"),
            edit = @Edit(title = "性别",
                    boolType = @BoolType(trueText = "男", falseText = "女"))
    )
    private Boolean sex;

    @EruptField(
            views = @View(title = "出生日期"),
            edit = @Edit(title = "出生日期",
                    dateType = @DateType(pickerMode = DateType.PickerMode.HISTORY) //出生日期必须为过去时间
            ))
    private Date birthday;

    @EruptField(
            views = @View(title = "年级(高中)"),
            edit = @Edit(title = "年级(高中)", type = EditType.CHOICE,
                    choiceType = @ChoiceType(vl = {
                            @VL(value = "1", label = "一年级"),
                            @VL(value = "2", label = "二年级"),
                            @VL(value = "3", label = "三年级")
                    })  //下拉列表支持动态渲染,为了方便演示固定写了几个
            ))
    private Integer grade;
}

效果演示:

8
9

自动生成的数据库表结构

create table demo_student
(
    id       bigint auto\_increment primary key,
    birthday datetime     null,
    name     varchar(255) null,
    sex      bit          null,
    grade    int          null
);

10

商品管理(左树右表)
@Erupt(name = "商品管理", 
       linkTree = @LinkTree(field = "category") //左树右表配置
)
@Table(name = "mall\_goods")
@Entity
public class Goods extends BaseModel {

    @EruptField(
            views = @View(title = "商品图片"),
            edit = @Edit(title = "商品图片", notNull = true, type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE, maxLimit = 6)) //最多可上传六张
    )
    private String image;

    @EruptField(
            views = @View(title = "商品名称"),
            edit = @Edit(title = "商品名称", notNull = true, inputType = @InputType(fullSpan = true), search = @Search(vague = true)) //模糊查询配置
    )
    private String name;

    @ManyToOne
    @EruptField(
            views = @View(title = "所属分类", column = "name"),
            edit = @Edit(title = "所属分类", type = EditType.REFERENCE_TREE, search = @Search, notNull = true, referenceTreeType = @ReferenceTreeType(pid = "parent.id"))
    )
    private GoodsCategory category; //GoodsCategory类定义请往下看
    
    @EruptField(
            views = @View(title = "价格"),
            edit = @Edit(title = "价格", notNull = true , numberType = @NumberType(min = 0))
    )
    private Double price;

    @EruptField(
            views = @View(title = "运费"),
            edit = @Edit(title = "运费", notNull = true, search = @Search(vague = true))
    )
    private Double freight = 0D;

    @EruptField(
            views = @View(title = "商品状态"),
            edit = @Edit(title = "商品状态", notNull = true, boolType = @BoolType(trueText = "上架", falseText = "下架"), search = @Search)
    )
    private boolean status;

    @Lob //定义数据库类为大文本类型,支持存入更多的数据
    @EruptField(
            views = @View(title = "商品描述", type = ViewType.HTML),
            edit = @Edit(title = "商品描述", type = EditType.HTML_EDITOR) //定义为富文本编辑器
    )
    private String description;

}

//商品类别
@Erupt(name = "商品类别", tree = @Tree(pid = "parent.id"), orderBy = "GoodsCategory.sort")
@Table(name = "mall\_goods\_category")
@Entity
public class GoodsCategory extends BaseModel {

    @EruptField(
            edit = @Edit(title = "分类图片", type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE))
    )
    private String image;

    @EruptField(
            edit = @Edit(title = "类别名称", notNull = true)
    )
    private String name;

    @EruptField(
            edit = @Edit(title = "显示顺序")
    )
    private Integer sort;

    @ManyToOne
    @EruptField(
            edit = @Edit(title = "上级分类", type = EditType.REFERENCE_TREE, referenceTreeType = @ReferenceTreeType(pid = "parent.id"))
    )
    private GoodsCategory parent;


}


11

12

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值