Skip to main content

Exploring Customer Services Controllers

Overview of Customer Services Controllers

Controllers in the Customer Services Interface are responsible for handling HTTP requests and mapping them to the appropriate service methods. They manage the flow of data between the model and the view, ensuring that user inputs are processed and the correct responses are generated.

WebController Class

The WebController class is a central component that defines various endpoints for customer and account-related operations. It includes methods for handling GET and POST requests for actions such as account and customer inquiries, listing accounts, creating, updating, and deleting accounts and customers.


The showCreateAccForm method handles GET requests to display the account creation form. This method sets up the form for user input to create a new account.

	// 4. Create an account
@GetMapping("/createacc")
public String showCreateAccForm(CreateAccountForm createAccForm,
Model model)
{
model.addAttribute(ACCOUNT_TYPES, AccountType.values());
return CREATE_ACCOUNT_FORM;
}

Handling Form Submissions

The processCreateAcc method processes the form submission via a POST request, validates the input, and interacts with the service layer.


The processCreateAcc method handles the form submission for creating a new account. It validates the input, serializes the data to JSON, and sends it to the service layer.

	@PostMapping("/createacc")
public String processCreateAcc(@Valid CreateAccountForm createAccForm,
BindingResult bindingResult, Model model)
throws JsonProcessingException
{
if (bindingResult.hasErrors())
{
model.addAttribute(ACCOUNT_TYPES, AccountType.values());
return CREATE_ACCOUNT_FORM;
}
CreateAccountJson transferjson = new CreateAccountJson(createAccForm);

// Serialise the object to JSON
log.info("{}", transferjson);
String jsonString = new ObjectMapper().writeValueAsString(transferjson);
log.info(jsonString);

WebClient client = WebClient
.create(ConnectionInfo.getAddressAndPort() + "/creacc/insert");

try

Customer Services Interface Endpoints

The Customer Services Interface includes several endpoints for handling different operations related to customer and account management.

/enqacct

The /enqacct endpoint handles GET requests to display the account inquiry form. This method initializes the form and prepares it for user input.


The showAcctForm method handles GET requests to display the account inquiry form.

	@GetMapping("/enqacct")
public String showAcctForm(AccountEnquiryForm accountEnquiryForm)
{
// String relates to the page template found in
// /src/main/resources/templates
return ACCOUNT_ENQUIRY_FORM;
}

/createacc

The /createacc endpoint handles GET requests to display the form for creating a new account. This method sets up the form for user input to create a new account.

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human