104 Star 747 Fork 182

DtFlys / forest

通用字符串支持枚举或静态常量的形式

Backlog
lrvinye  Opened this issue

类似下面的代码

@Request(
        url = "http://localhost:8080/hello/user",
        type = "post",
        contentType = "application/json"    // 指定contentType为application/json
)
String postJson(@Body MyUser user);   // 自动将user对象序列化为JSON格式

希望可以支持使用以下方式

@Request(
        url = "http://localhost:8080/hello/user",
        type = "post",
        contentType = ContentType.JSON    // 指定contentType为application/json
)
String postJson(@Body MyUser user);   // 自动将user对象序列化为JSON格式

还有多处类似片段,希望框架能够内置支持

1216742 dt flys 1594991700 5334081 lrvinye 1604197692 total 2 participants

Comments (1)

1216742 dt flys 1594991700
DtFlys 2021-01-15 11:06 owner

有内置静态变量

import com.dtflys.forest.backend.ContentType;

@Request(
        url = "http://localhost:8080/hello/user",
        type = "post",
        contentType = ContentType.APPLICATION_JSON
)
String postJson(@Body MyUser user);   // 自动将user对象序列化为JSON格式

另外如果用 @JSONBody 注解可以省略填写 contentType 属性

@Request(
        url = "http://localhost:8080/hello/user",
        type = "post"
)
String postJson(@JSONBody MyUser user);   // 自动将user对象序列化为JSON格式

Sign in to comment

Assignees
Labels
Not set
Projects
Milestones
Branches
Planed to start
Not set
Planed to end
Not set
Top level
Priority
Java
1
https://gitee.com/dt_flys/forest.git
git@gitee.com:dt_flys/forest.git
dt_flys
forest
forest

Search