Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import com.project.smartcab_api.dto.RegistrationRequest;
import com.project.smartcab_api.repository.SmartCabUsers;
import com.project.smartcab_api.repository.UserRepository;
import com.project.smartcab_api.service.SmartCabService;

@RestController("/smartcab")

public class SmartCabController {

@Autowired
private UserRepository userRepository;
private SmartCabService smartCabService;


@PostMapping("/login")
public ResponseEntity login(@RequestBody LoginRequest loginRequest )
Expand All @@ -30,18 +31,11 @@ public ResponseEntity login(@RequestBody LoginRequest loginRequest )
@PostMapping("/register")
public ResponseEntity register(@RequestBody RegistrationRequest regReq)
{
smartCabService.register(regReq);
System.out.println("Registration Request Details : " +regReq.toString());
SmartCabUsers smartCabUsers = new SmartCabUsers();
smartCabUsers.setEmail(regReq.getEmail());
smartCabUsers.setFirstname(regReq.getFirstName());
smartCabUsers.setLastname(regReq.getLastName());
smartCabUsers.setPhno(regReq.getPhno());
smartCabUsers.setConfirmPassword(regReq.getConfirmPassword());

userRepository.save(smartCabUsers);

ResponseEntity responseEntity = new ResponseEntity(HttpStatus.CREATED);
return null;



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ public class SmartCabUsers {
@Column(nullable = false , length =20)
private String password;

@Column(nullable = false , length =20)
private String confirmPassword;

@Column(name= "first_name" , nullable = false, length= 20 )
private String firstname;

@Column(name="last_name", nullable = false, length = 20)
private String lastname;

@Column(name="phone_number", nullable = false, length = 20)
private String phno;

public Long getId() {
return id;
Expand All @@ -58,6 +64,14 @@ public void setPassword(String password) {
this.password = password;
}

public String getConfirmPassword() {
return confirmPassword;
}

public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}

public String getFirstname() {
return firstname;
}
Expand All @@ -73,6 +87,14 @@ public String getLastname() {
public void setLastname(String lastname) {
this.lastname = lastname;
}

public String getPhno() {
return phno;
}

public void setPhno(String phno) {
this.phno = phno;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.project.smartcab_api.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import com.project.smartcab_api.dto.RegistrationRequest;
import com.project.smartcab_api.repository.SmartCabUsers;
import com.project.smartcab_api.repository.UserRepository;

@Component
public class SmartCabService {
@Autowired
private UserRepository userRepository;


public ResponseEntity register(RegistrationRequest regReq) {
SmartCabUsers smartCabUsers = new SmartCabUsers();
smartCabUsers.setEmail(regReq.getEmail());
smartCabUsers.setFirstname(regReq.getFirstName());
smartCabUsers.setLastname(regReq.getLastName());
smartCabUsers.setPhno(regReq.getPhno());
smartCabUsers.setConfirmPassword(regReq.getConfirmPassword());

userRepository.save(smartCabUsers);
ResponseEntity responseEntity = new ResponseEntity(HttpStatus.CREATED);
return responseEntity;
}
}