环境搭建
编程语言:Java8+ 使用框架:Spring Boot,Erupt
1. 在spring boot项目基础上导入erupt依赖
1<!--用户权限管理--> 2<dependency> 3 <groupId>xyz.erupt</groupId> 4 <artifactId>erupt-upms</artifactId> 5 <version>1.5.1</version> 6</dependency> 7<!--接口数据安全--> 8<dependency> 9 <groupId>xyz.erupt</groupId> 10 <artifactId>erupt-security</artifactId> 11 <version>1.5.1</version> 12</dependency> 13<!--后台WEB界面--> 14<dependency> 15 <groupId>xyz.erupt</groupId> 16 <artifactId>erupt-web</artifactId> 17 <version>1.5.1</version> 18</dependency> 19
2. 添加数据库配置
3. 修改入口类配置
1@SpringBootApplication // ↓ xyz.erupt必须有 2@ComponentScan({"xyz.erupt","com.xxx"}) // ↓ com.xxx要替换成实际需要扫描的代码包 3@EntityScan({"xyz.erupt","com.xxx"}) // ↓ 例如DemoApplication所在的包为 com.example.demo 4@EruptScan({"xyz.erupt","com.xxx"}) // → 则:com.xxx → com.example.demo 5public class DemoApplication { 6 public static void main(String[] args) { 7 SpringApplication.run(DemoApplication.class, args); 8 } 9} 10
4. 启动项目,浏览器访问:http://localhost:8080
效果演示:

现在开始开发第一个后台管理页面,优惠券管理,创建一个名为Coupon的实体类,代码如下
1@Erupt(name = "优惠券管理") 2@Table(name = "mall_goods_coupon") 3@Entity 4public class Coupon extends BaseModel { 5 6 @EruptField( 7 views = @View(title = "名称"), 8 edit = @Edit(title = "名称", notNull = true, search = @Search, inputType = @InputType(fullSpan = true)) 9 ) 10 private String name; 11 12 @EruptField( 13 views = @View(title = "金额"), 14 edit = @Edit(title = "金额", notNull = true, search = @Search) 15 ) 16 private Double price; 17 18 @EruptField( 19 views = @View(title = "商品金额满多少可用"), 20 edit = @Edit(title = "商品金额满多少可用", notNull = true, search = @Search) 21 ) 22 private Double priceMax; 23 24 @EruptField( 25 views = @View(title = "发行量"), 26 edit = @Edit(title = "发行量", notNull = true, search = @Search(vague = true)) 27 ) 28 private Integer maxCount; 29 30 @EruptField( 31 views = @View(title = "颜色", template = "'<div style=\"width:100%;height:20px;background:'+value+'\"></div>'"), 32 edit = @Edit(title = "颜色", notNull = true, inputType = @InputType(type = "color")) 33 ) 34 private String color; 35 36 @EruptField( 37 views = @View(title = "生效时间"), 38 edit = @Edit(title = "生效时间", notNull = true, dateType = @DateType(type = DateType.Type.DATE_TIME)) 39 ) 40 private Date startTime; 41 42 @EruptField( 43 views = @View(title = "失效时间"), 44 edit = @Edit(title = "失效时间", notNull = true, dateType = @DateType(type = DateType.Type.DATE_TIME)) 45 ) 46 private Date endTime; 47 48} 49
开发完成效果如下:

仅使用了一个文件,加上少量注解完成了优惠券管理的后台功能!
Erupt 还有很多有趣的功能,如自定义模板,SQL图表,动态定时任务,MongoDB数据源管理等,欢迎体验,项目官网如下:https://www.erupt.xyz
开源仓库: