Billing System registration flow using Spring Boot

Billing System using Spring Boot walkthrough of the Registration flow

Welcome back friends, in this story I will be going to explain what is the flow of User registration in our Billing System. It has the following three flows in the Registration flow.

Employee Registration
Vendor Registration
Customer Registration

Employee Registration

In I have defined the following Rest endpoint

@PostMapping("/employees") // http://localhost:9091/api/public/users/employees
public ResponseEntity<ResponseMessage<?>> saveEmployee(@Valid @RequestBody EmployeeDTO requestBody) throws Exception {
ResponseMessage responseMessage = registrationService.doRegistration(requestBody);
return new ResponseEntity<ResponseMessage<?>>(responseMessage, HttpStatus.CREATED);

This method calls the validate method which is my custom validation class. This method accepts the EmployeeDTO as Request Body. The validate method do all mandatory fields validation from the UserDTO object which defined in the EmployeeDTO class.
To understand code implementation of Custom validation, click the below link.
Custom validation code walkthrough

If there is no validation, it invokes the doRegistration method by passing EmployeeDTO as the request body. if the Type variable is “EMPLOYEE”, it is doing the following task and save the save employee info in the DB.
1. Converting EmployeeDTO to Employee object using MapStruct.
2. It set the default role name to the Employee. Generates the Unique
3. Employee code using “” and set it to the employeeCode attribute.
Once the above task is done successfully, it stores the employee information to the user, employee, and address table.
For further reading please click here. Registration code walkthrough