@Api、@ApiOperation、@ApiParam
@RestController
@RequestMapping(value = "/account")
@Api(tags = "账号相关接口",description = "账号查询与修改")
public class AccountController {
@Autowired
private AccountService accountService;
@RequestMapping(value = "/find")
@ApiOperation(value = "账号查询",httpMethod ="GET", response = Account.class,notes = "account find")
public Account getAccountById(Long id){
return accountService.getAccountById(id);
}
@RequestMapping(value = "/update",method = RequestMethod.POST)
@ApiOperation(value = "修改年龄",httpMethod ="GET", response = String.class,notes = "modify age")
public Account updateAccountByName(Long accountId,Long age){
Account accont = accountService.getAccountById(accountId);
accont.setAge(age);
return accountService.update(accont);
}
}
验证添加注解后效果
swagger常用注解说明
一、用于Controller类上
1、@Api
属性:
tags (Stirng) 标签。
description(String)类描述。