Erupt 降维打击代码生成器,急速开发后台管理系统

原创
2020/12/12 21:33
阅读数 2.3K

环境搭建

编程语言:Java8+ 使用框架:Spring Boot,Erupt

1. 在spring boot项目基础上导入erupt依赖

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

2. 添加数据库配置

3. 修改入口类配置

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

4. 启动项目,浏览器访问:http://localhost:8080

效果演示:

现在开始开发第一个后台管理页面,优惠券管理,创建一个名为Coupon的实体类,代码如下

@Erupt(name = "优惠券管理")
@Table(name = "mall_goods_coupon")
@Entity
public class Coupon extends BaseModel {

    @EruptField(
            views = @View(title = "名称"),
            edit = @Edit(title = "名称", notNull = true, search = @Search, inputType = @InputType(fullSpan = true))
    )
    private String name;

    @EruptField(
            views = @View(title = "金额"),
            edit = @Edit(title = "金额", notNull = true, search = @Search)
    )
    private Double price;

    @EruptField(
            views = @View(title = "商品金额满多少可用"),
            edit = @Edit(title = "商品金额满多少可用", notNull = true, search = @Search)
    )
    private Double priceMax;

    @EruptField(
            views = @View(title = "发行量"),
            edit = @Edit(title = "发行量", notNull = true, search = @Search(vague = true))
    )
    private Integer maxCount;

    @EruptField(
            views = @View(title = "颜色", template = "'<div style=\"width:100%;height:20px;background:'+value+'\"></div>'"),
            edit = @Edit(title = "颜色", notNull = true, inputType = @InputType(type = "color"))
    )
    private String color;

    @EruptField(
            views = @View(title = "生效时间"),
            edit = @Edit(title = "生效时间", notNull = true, dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date startTime;

    @EruptField(
            views = @View(title = "失效时间"),
            edit = @Edit(title = "失效时间", notNull = true, dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date endTime;

}

开发完成效果如下:

仅使用了一个文件,加上少量注解完成了优惠券管理的后台功能!

Erupt 还有很多有趣的功能,如自定义模板,SQL图表,动态定时任务,MongoDB数据源管理等,欢迎体验,项目官网如下:https://www.erupt.xyz

开源仓库:

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

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

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部