TODO
This commit is contained in:
parent
26ed8856f2
commit
ecd98a7171
|
@ -55,6 +55,20 @@ public class User {
|
|||
this.approved = approved;
|
||||
}
|
||||
|
||||
public User(String name, String firstname,String user_hash, String email, String password, long creation_date, long modification_date, long phone, String association, boolean verified, boolean approved) {
|
||||
this.name = name;
|
||||
this.firstname = firstname;
|
||||
this.user_hash = user_hash;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.creation_date = creation_date;
|
||||
this.modification_date = modification_date;
|
||||
this.phone = phone;
|
||||
this.association = association;
|
||||
this.verified = verified;
|
||||
this.approved = approved;
|
||||
}
|
||||
|
||||
public User(String name, String firstname, String user_hash, int phone, String association){
|
||||
this.name = name;
|
||||
this.firstname = firstname;
|
||||
|
@ -68,25 +82,22 @@ public class User {
|
|||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {this.userId = userId;}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setUser_hash(String user_hash){this.user_hash = user_hash;}
|
||||
|
||||
public String getUser_hash(){return user_hash;}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUser_hash(){return user_hash;}
|
||||
public void setUser_hash(String user_hash){this.user_hash = user_hash;}
|
||||
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
@ -94,7 +105,6 @@ public class User {
|
|||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
@ -102,7 +112,6 @@ public class User {
|
|||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
@ -110,7 +119,6 @@ public class User {
|
|||
public long getCreation_date() {
|
||||
return creation_date;
|
||||
}
|
||||
|
||||
public void setCreation_date(long creation_date) {
|
||||
this.creation_date = creation_date;
|
||||
}
|
||||
|
@ -118,19 +126,19 @@ public class User {
|
|||
public long getModification_date() {
|
||||
return modification_date;
|
||||
}
|
||||
|
||||
public void setModification_date(long modification_date) {
|
||||
this.modification_date = modification_date;
|
||||
}
|
||||
|
||||
public long getPhone(){return phone;}
|
||||
|
||||
public void setPhone(int phone){this.phone=phone;}
|
||||
|
||||
public String getAssociation(){return association;}
|
||||
public void setAssociation(){this.association=association;}
|
||||
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
public void setVerified(boolean verified) {
|
||||
this.verified = verified;
|
||||
}
|
||||
|
@ -138,7 +146,6 @@ public class User {
|
|||
public boolean isApproved() {
|
||||
return approved;
|
||||
}
|
||||
|
||||
public void setApproved(boolean approved) {
|
||||
this.approved = approved;
|
||||
}
|
||||
|
@ -153,6 +160,8 @@ public class User {
|
|||
", password='" + password + '\'' +
|
||||
", creation_date=" + creation_date +
|
||||
", modification_date=" + modification_date +
|
||||
", phone= "+phone+
|
||||
", association= "+association+
|
||||
", verified=" + verified +
|
||||
", approved=" + approved +
|
||||
", user_hash='" + user_hash + '\'' +
|
||||
|
|
|
@ -3,7 +3,6 @@ package restImplementation;
|
|||
import blockchain.query.QueryWrapper;
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.hyperledger.fabric.sdk.BlockEvent;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
|
@ -72,9 +71,9 @@ public class BlockchainQueryImplementation {
|
|||
}
|
||||
|
||||
|
||||
public void registerUser(List<String> userInfo){
|
||||
public void registerUser(String[] userInfo){
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("registerUser",new String[]{userInfo.get(0),userInfo.get(1),userInfo.get(2),userInfo.get(3),userInfo.get(4)});
|
||||
transactionWrapper.sendTransaction("registerUser",userInfo);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,15 +27,28 @@ public class BlockchainQueryResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@RequestMapping(value = "/registerUser", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity<StringResponse> login(@Valid @RequestBody User user){
|
||||
|
||||
public ResponseEntity<StringResponse> registerUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
BlockchainQueryImplementation blockchainQueryImplementation = new BlockchainQueryImplementation();
|
||||
String[] userInfos = new String[]{user.getUser_hash(),user.getName(),user.getFirstname(),""+user.getPhone(),user.getAssociation()};
|
||||
blockchainQueryImplementation.registerUser(userInfos);
|
||||
StringResponse response = new StringResponse("OK");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}catch (Exception e){
|
||||
StringResponse response = new StringResponse("Error: "+e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import database.user.User;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.BlockchainQueryImplementation;
|
||||
import restImplementation.DatabaseUserImplementation;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -20,10 +21,16 @@ public class DatabaseUserResource {
|
|||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity<StringResponse> saveUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
|
||||
DatabaseUserImplementation databaseUserImplementation = new DatabaseUserImplementation();
|
||||
Map<String,String> response = databaseUserImplementation.saveUser(user);
|
||||
if(Boolean.parseBoolean(response.get("response"))){
|
||||
StringResponse responseS = new StringResponse("Ok",response.get("userHash"));
|
||||
|
||||
BlockchainQueryImplementation blockchainQueryImplementation = new BlockchainQueryImplementation();
|
||||
String[] userInfos = new String[]{response.get("userHash"),user.getName(),user.getFirstname(),""+user.getPhone(),user.getAssociation()};
|
||||
blockchainQueryImplementation.registerUser(userInfos);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(responseS);
|
||||
}else {
|
||||
StringResponse responseS = new StringResponse("User already exist");
|
||||
|
|
Loading…
Reference in a new issue