如何设置要查询的默认参数类型。当前为 body

How to set default paramType to query. current is body

如果我不设置paramType = "query",密码是body。怎么改?

@ApiOperation("登录")
@ApiImplicitParams({
        @ApiImplicitParam(name = "account", value = "用户名或手机号码", paramType = "query"),
        @ApiImplicitParam(name = "password", value = "密码")
})
@RequestMapping
public JR login(String account, String password) {
    if (StringUtils.isEmpty(account) || StringUtils.isEmpty(password)) {
        return JR.fail(2, "请填写完整信息");
    }
    User user = userRepository.findByAccountOrPhone(account, account);
    if (user != null && StringUtils.md5(password).equals(user.getPassword())) {
        ApiUtils.loginInfo(user, userRepository, true);
        return JR.success(user);
    }
    return JR.fail(1, "账号或密码错误");
}

与其在 swagger 注释中设置它,不如在 method 中使用 @RequestParam 指定查询参数,如下所示:

@ApiOperation("登录")
@RequestMapping
public JR login(@RequestParam("account")  String account, @RequestParam("password") String password) {
    if (StringUtils.isEmpty(account) || StringUtils.isEmpty(password)) {
        return JR.fail(2, "请填写完整信息");
    }
    User user = userRepository.findByAccountOrPhone(account, account);
    if (user != null && StringUtils.md5(password).equals(user.getPassword())) {
        ApiUtils.loginInfo(user, userRepository, true);
        return JR.success(user);
    }
    return JR.fail(1, "账号或密码错误");
}