1.GetMapping url中带参数
1.1 controller
// Request URL:http://127.0.0.1/user/userAddress/getCoinAddress/coinId
@GetMapping("/getCoi/user/userAddress/getCoinAddress/coinIdnAddress/{coinId}")
public R<String> getCoinAddress(@PathVariable("coinId") Long coinId){
String userId = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
UserAddress userAddress = userAddressService.getUserAddressByUserIdAndCoinId(userId,coinId) ;
return R.ok(userAddress.getAddress()) ;
}
1.2server
/**
* 使用用户的Id 和币种的Id 查询用户的充币地址
* @param userId
* @param coinId
* @return
*/
UserAddress getUserAddressByUserIdAndCoinId(String userId, Long coinId);
1.3serverimpl
/**
* 使用用户的Id 和币种的Id 查询用户的充币地址
*
* @param userId
* @param coinId
* @return
*/
@Override
public UserAddress getUserAddressByUserIdAndCoinId(String userId, Long coinId) {
return getOne(new LambdaQueryWrapper<UserAddress>()
.eq(UserAddress::getUserId,userId)
.eq(UserAddress::getCoinId,coinId)
);
}