Enum 类型作为请求参数
作者:互联网
@PostMapping(value = "/user/list" , consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "获取用户信息列表", notes = "获取用户信息列表",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE, httpMethod = "POST")
public BaseResult<UserInfo> userList(@Valid @RequestBody UserFilterRequest request) {
return BaseResultUtils.buildBaseResult(userService.userList(request));
}
@Data
@NoArgsConstructor
@ApiModel(value = "userFilterRequest", description = "根据xxx过滤用户")
public class userFilterRequest extends PageRequest {
@ApiModelProperty("xxxx")
private List<HomeClassifyEnum> homeType;
@ApiModelProperty("xxx")
private List<SexClassifyEnum> sexType; !!!注意这里!!!!
@ApiModelProperty("xxxx")
private List<HeightClassifyEnum> heightType;
}
@Getter
public enum SexClassifyEnum{
MAN("MAN", 0, "男"), !!!注意这里!!!!
FEMALE("FEMALE", 1, "女");
private String type;
private int value;
private String remark;
SexClassifyEnum(String type, int value, String remark) {
this.type = type;
this.value = value;
this.remark = remark;
}
public String getType() {
return type;
}
}
请求示例
{
"homeType": ["MAN"], !!!注意这里!!!!
"sexType": [],
"heightType": [],
"pageSize": 10,
"pageNum": 1
}
总结
请求的参数
和是enum 类型的名字
进行匹配的,而不是 enum 类型的属性
标签:remark,请求,Enum,private,参数,value,type,public,String 来源: https://blog.csdn.net/qq_40813329/article/details/123094511