Merge branch 'features1.4/wallet' into develop-1.4
This commit is contained in:
commit
9504fff762
|
@ -42,7 +42,7 @@ public class UserImplementation {
|
|||
user.setApproved(false);
|
||||
|
||||
userDao.addUser(user);
|
||||
response.put("userHash",user.getUser_hash());
|
||||
response.put("user_hash",user.getUser_hash());
|
||||
response.put("response","true");
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ import java.util.Map;
|
|||
|
||||
public class WalletImplementation {
|
||||
|
||||
public Map<String,String> createWallet(Wallet wallet) throws Exception {
|
||||
Map<String,String> response = new HashMap<>();
|
||||
public Wallet createWallet(Wallet wallet) throws Exception {
|
||||
//Map<String,String> response = new HashMap<>();
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
UserDao userDao = new UserDao();
|
||||
|
@ -38,13 +38,15 @@ public class WalletImplementation {
|
|||
|
||||
walletDao.addWallet(wallet); // add wallet to replica DB
|
||||
|
||||
response.put("walletHash",wallet.getWallet_hash());
|
||||
response.put("walletType",wallet.getType());
|
||||
response.put("walletBalance",wallet.getBalance().toString());
|
||||
response.put("ownerHash",wallet.getUser_hash());
|
||||
/*
|
||||
response.put("wallet_hash",wallet.getWallet_hash());
|
||||
response.put("wallet_type",wallet.getType());
|
||||
response.put("wallet_balance",wallet.getBalance().toString());
|
||||
response.put("owner_hash",wallet.getUser_hash());
|
||||
response.put("response","true");
|
||||
*/
|
||||
|
||||
return response;
|
||||
return wallet;
|
||||
}
|
||||
|
||||
//getAllUserWallets
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Map;
|
|||
public class UserResource {
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity<StringResponse> registerUser(@Valid @RequestBody User user){
|
||||
public ResponseEntity registerUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
Map<String,String> userHashResponse = userImplementation.registerUser(user);
|
||||
|
@ -22,11 +22,11 @@ public class UserResource {
|
|||
if(Boolean.parseBoolean(userHashResponse.get("response"))){
|
||||
|
||||
//TEMPORARY AUTOMATIC APPROVE
|
||||
user.setUser_hash(userHashResponse.get("userHash"));
|
||||
user.setUser_hash(userHashResponse.get("user_hash"));
|
||||
userImplementation.approveUser(user);
|
||||
//
|
||||
|
||||
StringResponse responseS = new StringResponse("Ok",userHashResponse.get("userHash"));
|
||||
StringResponse responseS = new StringResponse("Ok",userHashResponse.get("user_hash"));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(responseS);
|
||||
}else {
|
||||
StringResponse responseS = new StringResponse("User already exist");
|
||||
|
|
|
@ -18,32 +18,37 @@ public class WalletResource {
|
|||
public ResponseEntity createWallet(@Valid @RequestBody Wallet wallet){
|
||||
try{
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
Map<String,String> walletResponse = walletImplementation.createWallet(wallet);
|
||||
Wallet walletResponse = walletImplementation.createWallet(wallet);
|
||||
|
||||
/*
|
||||
Wallet returnWallet = new Wallet();
|
||||
returnWallet.setWallet_hash(walletResponse.get("walletHash"));
|
||||
returnWallet.setWallet_hash(walletResponse.get("wallet_hash"));
|
||||
returnWallet.setUser_hash(wallet.getUser_hash());
|
||||
returnWallet.setBalance(Double.parseDouble(walletResponse.get("walletBalance")));
|
||||
returnWallet.setType(walletResponse.get("walletType"));
|
||||
returnWallet.setBalance(Double.parseDouble(walletResponse.get("wallet_balance")));
|
||||
returnWallet.setType(walletResponse.get("wallet_type"));
|
||||
*/
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(walletResponse);
|
||||
/*
|
||||
if(Boolean.parseBoolean(walletResponse.get("response"))){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(returnWallet);
|
||||
|
||||
}else {
|
||||
StringResponse responseS = new StringResponse("Wallet already exist");
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body(responseS);
|
||||
}
|
||||
*/
|
||||
}catch (Exception e){
|
||||
StringResponse responseS = new StringResponse(e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseS);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserWallets", method = RequestMethod.GET, params = {"userHash"}, produces = "application/json")
|
||||
@RequestMapping(value = "/getUserWallets", method = RequestMethod.GET, params = {"user_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWallets(@RequestParam(value = "userHash") String userHash){
|
||||
public ResponseEntity getWallets(@RequestParam(value = "user_hash") String user_hash){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
JsonArray wallets = walletImplementation.getAllUserWallets(userHash);
|
||||
JsonArray wallets = walletImplementation.getAllUserWallets(user_hash);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(wallets);
|
||||
} catch (Exception e){
|
||||
StringResponse responseS = new StringResponse(e.getMessage());
|
||||
|
@ -51,12 +56,12 @@ public class WalletResource {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getWallet", method = RequestMethod.GET, params = {"walletHash"}, produces = "application/json")
|
||||
@RequestMapping(value = "/getWallet", method = RequestMethod.GET, params = {"wallet_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWallet(@RequestParam(value = "walletHash") String walletHash){
|
||||
public ResponseEntity getWallet(@RequestParam(value = "wallet_hash") String wallet_hash){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
Wallet walletResponse = walletImplementation.getWallet(walletHash);
|
||||
Wallet walletResponse = walletImplementation.getWallet(wallet_hash);
|
||||
if(walletResponse!=null){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(walletResponse);
|
||||
}else{
|
||||
|
@ -96,8 +101,8 @@ public class WalletResource {
|
|||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public ResponseEntity deleteWallet(@RequestBody Map<String,String> requestParam){
|
||||
String userHash = requestParam.get("userHash");
|
||||
String walletHash = requestParam.get("walletHash");
|
||||
String userHash = requestParam.get("user_hash");
|
||||
String walletHash = requestParam.get("wallet_hash");
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.deleteWallet(walletHash,userHash);
|
||||
|
|
Loading…
Reference in a new issue