Erupt Framework 基于 Spring Boot 零前端代码,构建通用后台管理框架

4 篇文章 0 订阅
1 篇文章 0 订阅

在这里插入图片描述

代码生成器的本质还是生成繁琐的后台代码,一旦修改后期生成的代码很难合并,虽然减轻部分工作,但解决方式并非最佳,后台管理系统开发是否还有更好的解决方案?

框架简介

Erupt Framework通用的后台管理框架,零前端代码,零CURD,快速开发企业级管理后台 !

无需创建 template 、 controller 、 service 、 dao 、 entity 、 mapper 效率提升1000%

无需生成任何代码,仅需单个实体类文件,配合erupt所提供的注解,就可快速开发完成后台管理功能 !

支持数据库:MySQL、Oracle、SQL Server、PostgreSQL、H2、DB2、MongoDB等。

摒弃重复的CURD,专注于核心业务逻辑 !

使用方法

是不是想说学不动了? 但是erupt真的非常简单,花几分钟了解一下,后期可以为你节省大量的后台开发时间!

仅需4四步快速搭建运行环境:

  1. 在Java 8 及以上的环境下创建Spring Boot项目,
  2. 添加数据库连接配置与JPA配置
  3. 添加依赖
<!--用户权限管理-->
<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>

  1. 修改入口类配置

@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);
    }
}

仅需四步就可完成部署,且自带用户管理相关功能,启动成功:

下面使用erupt开发各行业后台管理功能

学生管理系统
@Erupt(name = "学生管理")      //erupt类注解
@Table(name = "t_student")    //数据库表名
@Entity                       //hibernate实体类标识
public class Student extends BaseModel {

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

    @EruptField(
        views = @View(title = "年龄"),
        edit = @Edit(title = "年龄")
    )
    private Integer age;

    @EruptField(
            views = @View(title = "出生日期"),
            edit = @Edit(title = "出生日期", 
                dateType = @DateType(pickerMode = DateType.PickerMode.HISTORY)
            ))
    )
    private Date birthday;

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

效果预览


可见代码十分简洁,实际场景中学生管理系统涉及字段会很多,仅需添加字段与配置就相关注解就可以了

现在电商系统十分流行,那就使用erupt实现商品管理的后台功能
@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;

    @EruptField(
            views = @View(title = "运费"),
            edit = @Edit(title = "运费", notNull = true, search = @Search(vague = true))
    )
    private final 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;

    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "goods_id")
    @EruptField(
            edit = @Edit(title = "商品型号", type = EditType.TAB_TABLE_ADD)
    )
    private Set<GoodsSpec> goodsSpecs;

}

效果预览:

erupt支持23类表单录入方式,15种展示形式,满足各种复杂场景的需求!


希望您从此摆脱枯燥的后台代码,早点下班做自己喜欢的事情!适度Coding益脑,过度Coding伤身,合理安排时间,享受健康生活!


更多示例详见框架官网:

https://www.erupt.xyz

创作不易,点击下方👇链接,给框架作者star鼓励

Gitee: https://gitee.com/erupt/erupt

Github: https://github.com/erupts/erupt

Erupt 框架中,可以通过 `@Button` 注解来实现自定义按钮的功能。下面是一个简单的示例,以实现一个“清空数据”按钮为例: 1. 首先,在你要自定义按钮的实体类中,添加一个`@Button`注解,并且指定按钮的名称和图标: ```java @Entity @Table(name = "t_user") @Erupt(name = "用户管理") public class User { // 省略其他字段 @Button("清空数据") @Icon(value = "fa fa-trash", color = Icon.Color.RED) public void clearData() { // 清空数据的具体实现逻辑 } } ``` 2. 在 `EruptConfig` 中,需要添加一个 `EruptButtonModel` 来对按钮进行配置: ```java @Configuration public class EruptConfig { @Bean public EruptButtonModel clearDataButton() { return EruptButtonModel.builder() .setTitle("清空数据") .setFetchMethod("/erupt-api/user/clearData") .setType(EruptButtonModel.Type.TIPS) .setMessage("你确认要清空所有数据吗?此操作不可恢复!") .setIcon(new FontAwesomeIcon("fa fa-trash", Icon.Color.RED)) .build(); } } ``` 注意,这里的 `fetchMethod` 属性是指定了按钮点击后将会触发的请求的路径。在这个路径中,需要定义一个处理请求的控制器方法。 3. 在控制器中,添加一个处理按钮请求的方法: ```java @RestController @RequestMapping("/erupt-api/user") public class UserController { @Autowired private UserService userService; @PostMapping("/clearData") public void clearData() { userService.clearData(); } } ``` 这里的 `UserService` 是你自己定义的服务类,用于处理具体的业务逻辑。 4. 最后,在你的页面中,使用 `erupt-buttons` 标签来渲染按钮: ```html <erupt-buttons :buttons="buttons"></erupt-buttons> ``` 在对应的 Vue 实例中,需要定义一个 `buttons` 对象,来指定要显示的按钮。在这个对象中,可以引用前面在 `EruptConfig` 中定义的 `EruptButtonModel`: ```javascript data() { return { buttons: [ clearDataButton ] } } ``` 至此,一个简单的自定义按钮就实现了。当用户点击按钮时,将会弹出提示框,询问用户是否确认进行清空数据操作。如果用户确认操作,将会触发后台的 `clearData` 方法进行清空数据的操作。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值