Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
</dependency>

<!-- liquibase dependency-->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.31.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ApiExceptionHandler {
@ExceptionHandler(BadRequestException.class)
public ResponseEntity<ErrorResponseModel> handleBadRequestException(RuntimeException ex) {
log.info("Runtime exception occurred: ", ex);
ErrorResponseModel errorResponse = ResponseUtil.error("Bad Request", HttpStatus.BAD_REQUEST, new ErrorDetails(
ErrorResponseModel errorResponse = ResponseUtil.error(ex.getMessage(), HttpStatus.BAD_REQUEST, new ErrorDetails(
ErrorCode.INVALID_REQUEST.getCode(),
ErrorCode.INVALID_REQUEST.getMessage()
));
Expand All @@ -39,7 +39,7 @@ public ResponseEntity<ErrorResponseModel> handleRefreshTokenInvalidException(Ref
@ExceptionHandler(DataNotFoundException.class)
public ResponseEntity<ErrorResponseModel> handleDataNotFoundException(DataNotFoundException ex) {
log.info("DataNotFoundException occurred: ", ex);
ErrorResponseModel errorResponse = ResponseUtil.error("Data Not Found", HttpStatus.NOT_FOUND, new ErrorDetails(
ErrorResponseModel errorResponse = ResponseUtil.error(ex.getMessage(), HttpStatus.NOT_FOUND, new ErrorDetails(
ErrorCode.ENTITY_NOT_FOUND.getCode(),
ErrorCode.ENTITY_NOT_FOUND.getMessage()
));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.satwik.splitora.persistence.dto.expense;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.satwik.splitora.persistence.dto.user.OwerDTO;
import jakarta.validation.constraints.NotNull;
import lombok.*;
Expand All @@ -24,6 +25,7 @@ public class ExpenseDTO {
@NotNull
private String description;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime date;

private List<OwerDTO> owers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class User extends BaseEntity {
private String password;

@Enumerated(EnumType.STRING)
@Column(name = "registrationMethod")
@Column(name = "registration_method")
private RegistrationMethod registrationMethod;

@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
public interface UserRepository extends JpaRepository<User, UUID> {

Optional<User> findByEmail(String email);

boolean existsByEmail(String email);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public List<UserDTO> findMembers(UUID groupId) {
List<UserDTO> userDTOS = new ArrayList<>();
for (GroupMembers groupMembers : groupMembersList) {
UserDTO userDTO = new UserDTO();
userDTO.setUserId(groupMembers.getMember().getId());
userDTO.setEmail(groupMembers.getMember().getEmail());
userDTO.setUsername(groupMembers.getMember().getUsername());
userDTO.setPhone(new PhoneDTO(groupMembers.getMember().getCountryCode(), groupMembers.getMember().getPhoneNumber()));
Expand Down
36 changes: 0 additions & 36 deletions src/main/resources/application.properties

This file was deleted.

66 changes: 66 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Connection of spring application with database
spring:
datasource:
url: jdbc:mysql://localhost:3306/Splitora
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver

jpa:
hibernate:
ddl-auto: none
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy

liquibase:
enabled: true
change-log: classpath:db/changelog/db.changelog-master.yaml
# show-sql: true # Uncomment to enable SQL logging

security:
oauth2:
client:
registration:
google:
client-id: abc123
client-secret: good123
scope:
- openid
- email
- profile
redirect-uri: http://localhost:3000/callback
provider:
google:
authorization-uri: https://accounts.google.com/o/oauth2/auth
token-uri: https://oauth2.googleapis.com/token
user-info-uri: https://www.googleapis.com/oauth2/v3/userinfo
user-name-attribute: name

server:
port: 8081

# JWT security
jwt:
access:
secretKey: SuP9ErKeY
expirationTimeInMinutes: 150
refresh:
secretKey: wUP89ErKie
expirationTimeInMinutes: 2000

# File path for the report
my:
reportFilePath: /home/ongraph/Downloads/

app:
initial-users:
super-admin:
username: ${SUPERADMIN_USERNAME}
password: ${SUPERADMIN_PASSWORD}
email: ${SUPERADMIN_EMAIL}
regular-users:
- username: ${USER1_USERNAME}
password: ${USER1_PASSWORD}
email: ${USER1_EMAIL}
- username: ${USER2_USERNAME}
password: ${USER2_PASSWORD}
email: ${USER2_EMAIL}
24 changes: 24 additions & 0 deletions src/main/resources/db/changelog/data/seed-groups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
databaseChangeLog:
- changeSet:
id: 2025-05-31-load-groups
author: splitora
changes:
- sql:
splitStatements: false
stripComments: true
sql: |
INSERT IGNORE INTO group_table (
id, created_by, created_on, modified_by, modified_on, default_group, group_name, user_id
) VALUES
(
UNHEX('a1b2c3d4e5f60123456789abcdef0001'), NULL, '2025-05-26 13:24:27.589321', NULL, '2025-05-26 13:24:27.589321',
1, 'Non Grouped Expenses', UNHEX('3719917506b14643afc7b8815fdc81cf')
),
(
UNHEX('a1b2c3d4e5f60123456789abcdef0002'), NULL, '2025-05-26 13:24:27.596714', NULL, '2025-05-26 13:24:27.596714',
1, 'Non Grouped Expenses', UNHEX('5790c07ad90e4df6a062e6465f658127')
),
(
UNHEX('a1b2c3d4e5f60123456789abcdef0003'), NULL, '2025-05-26 13:24:27.601860', NULL, '2025-05-26 13:24:27.601864',
1, 'Non Grouped Expenses', UNHEX('784ad2e326344ba58c5028c8ee56bcd8')
);
29 changes: 29 additions & 0 deletions src/main/resources/db/changelog/data/seed-users.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
databaseChangeLog:
- changeSet:
id: 2025-05-31-load-users
author: splitora
changes:
- sql:
splitStatements: false
stripComments: true
sql: |
INSERT IGNORE INTO user (
id, created_by, created_on, modified_by, modified_on,
username, email, phone_country_code, phone_number,
password, registration_method, user_role
) VALUES
(
UNHEX('3719917506b14643afc7b8815fdc81cf'), NULL, '2025-05-26 13:24:27', NULL, '2025-05-26 13:24:27',
'nakul_test_90', 'nakul@example.com', '+91', '0',
'$2a$10$txo1PsQ7M.2uLv/HO.S0TuRHWJPvV8X2oO4gEh/QBNfTX8KIHEuma', 'NORMAL', 'USER'
),
(
UNHEX('5790c07ad90e4df6a062e6465f658127'), NULL, '2025-05-26 13:24:27', NULL, '2025-05-26 13:24:27',
'superadmin', 'superadmin@example.com', '+91', '99',
'$2a$10$ndZUrGTuqXw1buq9/MF34eM1XnrnFzwx9227xCGockloaFq.zPb8K', 'NORMAL', 'ADMIN'
),
(
UNHEX('784ad2e326344ba58c5028c8ee56bcd8'), NULL, '2025-05-26 13:24:27', NULL, '2025-05-26 13:24:27',
'gaurav_test_22', 'gaurav@example.com', '+91', '1',
'$2a$10$ILSK/k88Rd6SUbiMBHg/IOhuWGk3N5WqRDLz3gDL0.ne.6nANMeaG', 'NORMAL', 'USER'
) ;
15 changes: 15 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
databaseChangeLog:
- include:
file: db/changelog/schema/user-create.yaml
- include:
file: db/changelog/schema/group-create.yaml
- include:
file: db/changelog/schema/groupmembers-create.yaml
- include:
file: db/changelog/schema/expense-create.yaml
- include:
file: db/changelog/schema/expenseshare-create.yaml
- include:
file: db/changelog/data/seed-users.yaml
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a secret file path. Change it using cicd

- include:
file: db/changelog/data/seed-groups.yaml
45 changes: 45 additions & 0 deletions src/main/resources/db/changelog/schema/expense-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
databaseChangeLog:
- changeSet:
id: create-expense-table
author: splitora
changes:
- createTable:
tableName: expense
columns:
- column:
name: id
type: BINARY(16)
constraints:
primaryKey: true
- column:
name: created_by
type: BINARY(16)
- column:
name: created_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: modified_by
type: BINARY(16)
- column:
name: modified_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: group_id
type: BINARY(16)
constraints:
foreignKeyName: fk_expense_group
references: group_table(id)
- column:
name: payer_id
type: BINARY(16)
constraints:
foreignKeyName: fk_expense_payer
references: user(id)
- column:
name: amount
type: DOUBLE
- column:
name: description
type: VARCHAR(255)
42 changes: 42 additions & 0 deletions src/main/resources/db/changelog/schema/expenseshare-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
databaseChangeLog:
- changeSet:
id: create-expenseshare-table
author: splitora
changes:
- createTable:
tableName: expense_share
columns:
- column:
name: id
type: BINARY(16)
constraints:
primaryKey: true
- column:
name: created_by
type: BINARY(16)
- column:
name: created_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: modified_by
type: BINARY(16)
- column:
name: modified_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: expense_id
type: BINARY(16)
constraints:
foreignKeyName: fk_expenseshare_expense
references: expense(id)
- column:
name: user_id
type: BINARY(16)
constraints:
foreignKeyName: fk_expenseshare_user
references: user(id)
- column:
name: shared_amount
type: DOUBLE
39 changes: 39 additions & 0 deletions src/main/resources/db/changelog/schema/group-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
databaseChangeLog:
- changeSet:
id: create-group-table
author: splitora
changes:
- createTable:
tableName: group_table
columns:
- column:
name: id
type: BINARY(16)
constraints:
primaryKey: true
- column:
name: created_by
type: BINARY(16)
- column:
name: created_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: modified_by
type: BINARY(16)
- column:
name: modified_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: group_name
type: VARCHAR(255)
- column:
name: default_group
type: BIT
- column:
name: user_id
type: BINARY(16)
constraints:
foreignKeyName: fk_group_user
references: user(id)
Loading