Skip to content

Commit ba56321

Browse files
Ashish MishraAshish Mishra
authored andcommitted
staring the employee management system
1 parent 1824fc0 commit ba56321

15 files changed

Lines changed: 170 additions & 11 deletions

docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ services:
1717
# - "8082:3306" removing port mapping since by default the 3306 will expose the functionality
1818
volumes:
1919
- ./src/main/resources/dockerizedEntireApp/init-script:/docker-entrypoint-initdb.d
20-
# - ./src/main/resources/dockerizedEntireApp/volumes/mysql_data:/var/lib/mysql
20+
- ./src/main/resources/dockerizedEntireApp/volumes/mysql_data:/var/lib/mysql
2121
healthcheck:
2222
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
2323
interval: 10s
@@ -39,7 +39,7 @@ services:
3939
- "8082:3306"
4040
volumes:
4141
- ./src/main/resources/dockerizedEntireApp/init-script:/docker-entrypoint-initdb.d
42-
# - ./src/main/resources/dockerizedEntireApp/volumes/mysql_data:/var/lib/mysql
42+
- ./src/main/resources/dockerizedEntireApp/volumes/mysql_data:/var/lib/mysql
4343
profiles:
4444
- onlyDb
4545
networks:

src/main/java/com/beneite/SpringWithDocker/constants/GlobalConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ private GlobalConstants(){}
99
public static final String CREATE = "create";
1010
public static final String EMPLOYEE_RECORD_SUCCESS = "Employee record created successfully";
1111
public static final String GET_EMPLOYEE = "getEmployee";
12+
public static final String DESIGNATIONS = "designations";
13+
public static final String BANDS = "bands";
14+
public static final String DEPARTMENTS = "departments";
15+
public static final String BUSINESS_UNITS = "businessUnits";
1216
}

src/main/java/com/beneite/SpringWithDocker/controller/EmployeeController.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public ResponseEntity<CreateEmployeeResponseDto> createUserApi(@Valid @RequestBo
5252

5353
@Operation(
5454
summary = "Get All Employee API",
55-
description = "this API get all student record"
55+
description = "this API get all Employee record"
5656
)
5757
@ApiResponse(
5858
responseCode = "200",
@@ -66,16 +66,29 @@ public ResponseEntity<List<GetEmployeeResponseDto>> getAllUsersApi(){
6666

6767
@Operation(
6868
summary = "Get User API",
69-
description = "this API get a student record by id"
69+
description = "this API get a Employee record by id"
7070
)
7171
@ApiResponse(
7272
responseCode = "200",
73-
description = "200-success, display the student record created"
73+
description = "200-success, display the Employee record created"
7474
)
75-
// Api to get the user by id, end point: http://localhost:8080/api/user/getUserById/2
76-
@GetMapping(GET_EMPLOYEE+"/{id}")
75+
@GetMapping(GET_EMPLOYEE+"/id/{id}")
7776
public ResponseEntity<GetEmployeeResponseDto> getUserByIdApi(@PathVariable("id") Long userId){
7877
GetEmployeeResponseDto getEmployeeResponseDto = employeeServiceImpl.getEmployeeImplementation(userId);
7978
return new ResponseEntity<>(getEmployeeResponseDto, HttpStatus.OK);
8079
}
80+
81+
@Operation(
82+
summary = "Get Employee API with company email id",
83+
description = "this API get a Employee record by id"
84+
)
85+
@ApiResponse(
86+
responseCode = "200",
87+
description = "200-success, display the Employee record created"
88+
)
89+
@GetMapping(GET_EMPLOYEE+"/companyEmail/{email}")
90+
public ResponseEntity<GetEmployeeResponseDto> getUserByCompanyEmailIdApi(@PathVariable("email") String companyEmailId){
91+
GetEmployeeResponseDto getEmployeeResponseDto = employeeServiceImpl.getEmployeeByCompanyEmailId(companyEmailId);
92+
return new ResponseEntity<>(getEmployeeResponseDto, HttpStatus.OK);
93+
}
8194
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.beneite.SpringWithDocker.dto.responseDto;
2+
3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import lombok.Setter;
9+
10+
@Schema(
11+
description = "Config DTO model information"
12+
)
13+
@Getter
14+
@Setter
15+
@NoArgsConstructor
16+
@AllArgsConstructor
17+
@Builder
18+
public class ConfigEntityDto {
19+
20+
@Schema(
21+
description = "Config Id"
22+
)
23+
private Long id;
24+
25+
@Schema(
26+
description = "Config key name"
27+
)
28+
private String key;
29+
30+
@Schema(
31+
description = "Config value"
32+
)
33+
private String values; // store as JSON string
34+
}

src/main/java/com/beneite/SpringWithDocker/entity/ConfigEntity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import jakarta.persistence.Id;
88
import jakarta.persistence.Table;
99
import jakarta.persistence.Lob;
10+
import lombok.Getter;
1011

12+
@Getter
1113
@Entity
1214
@Table(name = "config")
1315
public class ConfigEntity {

src/main/java/com/beneite/SpringWithDocker/exception/DuplicateEmailException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class DuplicateEmailException extends RuntimeException{
1212

1313
private String message;
1414

15-
public DuplicateEmailException(String message) {
16-
super(message);
15+
public DuplicateEmailException(String email) {
16+
super(String.format("Email: %s, already available.", email));
1717
this.message = message;
1818
}
1919
}

src/main/java/com/beneite/SpringWithDocker/exception/ResourceNotFoundException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ public ResourceNotFoundException(String resourceName, String fieldName, Long fie
2020
this.fieldName = fieldName;
2121
this.fieldValue = fieldValue;
2222
}
23+
24+
public ResourceNotFoundException(String resourceName) {
25+
super(String.format("%s not found.",resourceName));
26+
this.resourceName = resourceName;
27+
}
2328
}

src/main/java/com/beneite/SpringWithDocker/mapper/AutoUserMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import com.beneite.SpringWithDocker.dto.requestDto.CreateEmployeeRequestDto;
44
import com.beneite.SpringWithDocker.dto.requestDto.UserDto;
5+
import com.beneite.SpringWithDocker.dto.responseDto.ConfigEntityDto;
56
import com.beneite.SpringWithDocker.dto.responseDto.CreateEmployeeResponseDto;
67
import com.beneite.SpringWithDocker.dto.responseDto.GetEmployeeResponseDto;
8+
import com.beneite.SpringWithDocker.entity.ConfigEntity;
79
import com.beneite.SpringWithDocker.entity.EmployeeEntity;
810
import com.beneite.SpringWithDocker.entity.UserEntity;
911
import org.mapstruct.Mapper;
@@ -25,4 +27,6 @@ public interface AutoUserMapper {
2527
GetEmployeeResponseDto mapToGetAllEmployeeResponseDto(EmployeeEntity employeeEntity);
2628

2729
GetEmployeeResponseDto mapToGetEmployeeResponseDto(EmployeeEntity employeeEntity);
30+
31+
ConfigEntityDto mapToDto(ConfigEntity configEntity);
2832
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.beneite.SpringWithDocker.repository;
2+
3+
import com.beneite.SpringWithDocker.entity.ConfigEntity;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
import java.util.Optional;
7+
8+
public interface ConfigRepository extends JpaRepository<ConfigEntity, Long> {
9+
10+
Optional<ConfigEntity> findByKey(String configKey);
11+
12+
}

src/main/java/com/beneite/SpringWithDocker/repository/EmployeeRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
import com.beneite.SpringWithDocker.entity.EmployeeEntity;
44
import org.springframework.data.jpa.repository.JpaRepository;
55

6+
import java.util.Optional;
7+
68
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Long> {
9+
10+
Optional<EmployeeEntity> findByCompanyEmail(String email);
711
}

0 commit comments

Comments
 (0)