Spring:通过枚举来传递参数

发布于 2021-12-10  897 次阅读


数据库类型:entry_type char(1) NOT NULL DEFAULT '1'

1、定义枚举实体

private EntryType entryType;

2、 EntryType 枚举类型

public enum EntryType implements BaseEnum {
    CLOSE("0", "关闭"), PROTOGENESIS("1", "原生"), H5("2", "H5");

    private String code;

    private String name;

    private EntryType(String code, String name) {
        this.code = code;
        this.name = name;
    }
}

3、参数传递

"entryType": "PROTOGENESIS"

4、获取具体的code参数,重新封装后保存到数据库

orderGrid.setEntryType(orderGridDto.getEntryType().getCode());


欢迎欢迎~热烈欢迎~