如果我没有设置paramType ="查询",则密码为正文。如何改变?
@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, "账号或密码错误");
}
答案 0 :(得分: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, "账号或密码错误");
}