You are on page 1of 9

Topics

Link (Problem Statement)


Add sonarLint plugin to your IDE which will keep showing you the coding mistakes you do
while writing the code
Create a repository in git and create your feature branch for code management

Create a spring boot banking application


1. Create models/POJOs
a. User
b. Account

1. Create controller with REST APIs


2. Create a service layer which will have business logic: Mandatory param check, length
validations, dao(Repository) call, etc

1. Add database entities and repositories


2. Setup a mysql database connection with required tables:
a. Account
b. User
3. Use hibernate for database operations

Create a dao layer which will perform all the repository related operations
Add exception models

Implement proper exception handling


Add proper logging
Use postman to test your APIs

Topics
Databases

Rest APIs and spring boot


Duration

Day 0

Day 1

Day 1

Day 2

Day 3

Day 4
Day 5

Study Material
https://www.guru99.com/how-to-create-a-database.html#2
https://www.mysqltutorial.org/mysql-create-database/
https://www.w3schools.com/sql/sql_create_db.asp
https://spring.io/guides/gs/rest-service/
https://dzone.com/articles/build-rest-web-service-using-spring
https://spring.io/guides/tutorials/rest/
Comments

Details are provided in Problem Description-springBoot sheet


Note:
1. Keep pushing your code in the feature branch of git repo
2. Keep using Ctrl+shift+f for code formatting
3. Use lombok for getters and setters
4. Setup review mettings with your teammates
Problem Statement Operations Constraints/checks
Create Dynamic Web Application with two Perform CRUD operations: 1. User id is Primary
entities 1. Add User Key(Numeric)
1. Account 2. Update userDetails using 2. Name should not contain
2. User User id special chars
3. Delete an user using 3. Email id format should be
Note: user_id checked
User Can have multiple accounts 4. Get a single user using id 4. mobile number needs to be
5. Get all users of length 10
User Structure:- 5. DOB format should be "DD-
-- User_ID -- Primary Key -- numeric(5) MMM-YYYY"
-- Name -- 40 Chars 6. Gender should be M or F
-- Email_ID -- 100 cars 7. All fields are mandatory
-- Mobile number -- 10 char except secondary mobile
-- Secondary _Mobile -- 10 char
-- DOB --String format"DD-MMM-YYYY"
-- Gender -- (M/F) -- single Char

Account Structure:- Perform CRUD operations: 1. Account ID is Primary key


-- Account_id -- Numeric(10) 1. Add Account 2. User id should exists in
-- User_ID -- foreign key 2. Update AccountDetails Users table
-- Branch_name -- 40 chars using Accounnt ID 3. Branch name should be
-- Account_type -- (S-savings/C-current) 1 3. Delete an Account using atleast 3 and max 40 chars
-- Account_balance -- numeric (10,2) Account_id 4. Account type should be (S-
4. Get a single account using savings/C-current)
account id 5. Account Balance can not be
5. Get all account of user using -ve
user id, 6. All fields fields mandatory
6. Get all accounts

Details
1. Insert an user with user attributes like,
userId(primaryKey), userNumber,
userName, address, mobNo, etc.
Initially the list of accounts will be
empty, no account will be assigned. It's
simply an user creation
1. Insert an account with account
attributes like, accountId, accountName,
accountBranch, etc.
Initially the user will not be assigned
1. User details can be updated such as
userName, address, mobNo, etc.
(same with account entity)
1. Assign the account to an user (accept
userNumber as queryParam and
accountNumber in requestBody)
1. Delete user or account( accept
userNumber or accountNumber in path
param)
Operational Constraints Exception Handling
1. One user can have multiple 1. All exceptions should be properly
accounts handled.
2. User id should be auto 2. Standard HTTP status codes should be
generated/incrmented in range followed.
(10000- 99999) https://en.wikipedia.org/wiki/
3. User id should be created when List_of_HTTP_status_codes
insertin in backend
200 OK -- API success
201 Created -- for create/Add APIs
204 - if Data not found
500 Internal Server Error - if any
exception with proper mssage

If you feel any other should be used go


ahead

1. One account can belong to one Same as User operations


user only
2. account id should be auto
generated/incrmented in range
(1000000000- 9999999999)
3. Account id should be created
when insertin in backend
Success Responses Error Responses
1. GET For any exception HTTP status code should be 500
-- if records found HTTP 200 with Json body data
2. Insert/POST: 1. GET
-- if record created Return HTTP 201 -- if no records are present then HTTP 204 response
3. Update/PUT: with empty body
-- if record updated HTTP 200 2. Insert/POST:
4. Delete: -- if Error 500
-- Success HTTP 200 3. Update/PUT:
-- If record not found HTTP 204
4. Delete:
-- Record not present 204

{ {
data :{ response object as per req}, data :{ response object as per req},
success: true, success: false,
message: "Message String" message: " Error message String"
} }

Same as User operations Same as User operations


Standards Concepts to be explored

Logging What is logging and different types of log levels


Code formatters, method extractors, javaDoc
Formatting and code commenting
SonarLint plugin (can be downloaded from
Code quality eclipse marketplace)

How to install lombok for windows, lombok


dependency and annotations used
How we can use it in our spring boot project,
Lombok explore @Data annotation
jUnit/mockito Annotations and use
Details

Use of slf4j for adding proper log messages

Use default STS formatter (ctrl+shift+f)

How to add this plugin to your IDE and how to solve sonar issues

Lombok can be used for getter/setter and toString methods

You might also like