29 lines
1.1 KiB
Java
29 lines
1.1 KiB
Java
package restService;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import restImplementation.BlockchainQueryImplementation;
|
|
|
|
@RestController
|
|
@RequestMapping(value = "/api/rest/query")
|
|
public class BlockchainQueryResource {
|
|
|
|
@RequestMapping(value = "/balance", method = RequestMethod.GET ,params = {"userHash"},produces = "application/json")
|
|
@ResponseStatus(HttpStatus.OK)
|
|
public ResponseEntity<StringResponse> getUserBalance(@RequestParam(value = "userHash") String userHash){
|
|
try{
|
|
BlockchainQueryImplementation blockchainQueryImplementation = new BlockchainQueryImplementation();
|
|
Double result = blockchainQueryImplementation.getUserBalance(userHash);
|
|
StringResponse response = new StringResponse("Ok",result);
|
|
return ResponseEntity.status(HttpStatus.OK).body(response);
|
|
}catch (Exception e){
|
|
StringResponse response = new StringResponse("Error");
|
|
return ResponseEntity.status(HttpStatus.OK).body(response);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|