使用Erupt Framework管理MongoDB数据源

364 阅读1分钟

本文介绍如何使用erupt管理MongoDB数据源

在导入erupt前提下增加erupt-mongodb依赖

<dependency>
     <groupId>xyz.erupt</groupId>
     <artifactId>erupt-mongodb</artifactId>
     <version>${erupt.version}</version>
</dependency>

接下来注解配置,仅需添加@EruptDataProcessor注解与@Document注解即可,与Mysql数据源配置差别并不大!

@EruptDataProcessor(EruptMongodbImpl.MONGODB_PROCESS)
@Document(collection = "book") 
@Erupt(
        name = "图书管理",
        orderBy = "sort",
        power = @Power(export = true, importable = true)
)
public class Book {

    @Id
    @EruptField
    private String id;

    @EruptField(
            views = @View(title = "书名", sortable = true),
            edit = @Edit(title = "书名", search = @Search(vague = true))
    )
    private String name;

    @EruptField(
            views = @View(title = "价格", sortable = true),
            edit = @Edit(title = "价格", search = @Search(vague = true))
    )
    private Double price;

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

    @EruptField(
            views = @View(title = "进货日期", sortable = true),
            edit = @Edit(title = "进货日期", search = @Search(vague = true))
    )
    private Date date;

}

页面效果

erupt通用后台管理框架,零前端代码,仅使用注解快速开发管理后台

官网地址:www.erupt.xyz