Skip to content

Commit

Permalink
feat: implement leave policy (#12)
Browse files Browse the repository at this point in the history
* feat: implement leave policy
  • Loading branch information
mohsenk authored Sep 29, 2024
1 parent e0dc25b commit 03cbd06
Show file tree
Hide file tree
Showing 60 changed files with 1,033 additions and 312 deletions.
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
networks:
- teamwize-network
ports:
- '5430:5432'
- '8002:5432'
environment:
POSTGRES_DB: teamwize-db
POSTGRES_USER: pg-admin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package app.teamwize.api.auth.controller;



import app.teamwize.api.auth.domain.request.LoginRequest;
import app.teamwize.api.auth.service.AuthenticationService;
import app.teamwize.api.leavepolicy.exception.LeaveTypeNotFoundException;
import app.teamwize.api.organization.exception.OrganizationNotFoundException;
import app.teamwize.api.team.domain.exception.TeamNotFoundException;
import app.teamwize.api.user.exception.UserAlreadyExistsException;
Expand All @@ -28,7 +28,8 @@ public class AuthenticationController {

@PostMapping("register")
@ResponseStatus(HttpStatus.CREATED)
public AuthenticationResponse register(@Valid @RequestBody RegistrationRequest request) throws UserAlreadyExistsException, OrganizationNotFoundException, TeamNotFoundException {
public AuthenticationResponse register(@Valid @RequestBody RegistrationRequest request)
throws UserAlreadyExistsException, OrganizationNotFoundException, TeamNotFoundException, LeaveTypeNotFoundException {
return authenticationService.register(request);
}

Expand All @@ -39,5 +40,4 @@ public AuthenticationResponse login(@Valid @RequestBody LoginRequest request) th
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import app.teamwize.api.auth.domain.request.LoginRequest;
import app.teamwize.api.base.exception.BaseException;
import app.teamwize.api.leavepolicy.exception.LeaveTypeNotFoundException;
import app.teamwize.api.leavepolicy.service.LeavePolicyService;
import app.teamwize.api.organization.service.OrganizationService;
import app.teamwize.api.user.domain.request.AdminUserCreateRequest;
import app.teamwize.api.user.exception.UserAlreadyExistsException;
Expand Down Expand Up @@ -39,23 +41,29 @@ public class AuthenticationService implements UserDetailsService {
private final ApplicationEventPublisher eventPublisher;
private final UserMapper userMapper;
private final TeamService teamService;
private final LeavePolicyService leavePolicyService;


@Transactional(rollbackFor = BaseException.class)
public AuthenticationResponse register(RegistrationRequest request) throws UserAlreadyExistsException, OrganizationNotFoundException, TeamNotFoundException {
var organization = organizationService.registerOrganization(new OrganizationCreateRequest(request.organizationName(),request.country(), request.timezone()));
public AuthenticationResponse register(RegistrationRequest request) throws UserAlreadyExistsException, OrganizationNotFoundException, TeamNotFoundException, LeaveTypeNotFoundException {
var organization = organizationService.registerOrganization(new OrganizationCreateRequest(request.organizationName(), request.country(), request.timezone()));
var leavePolicy = leavePolicyService.createDefaultLeavePolicy(organization.getId());
var team = teamService.createTeam(organization.getId(), new TeamCreateRequest("Default", null));
var registerRequest = new AdminUserCreateRequest(
request.email(),
request.password(),
request.firstName(),
request.lastName(),
request.phone(),
request.timezone()
request.timezone(),
request.country(),
leavePolicy.getId()
);
var user = userService.createOrganizationAdmin(organization.getId(), team.getId(),registerRequest);

var user = userService.createOrganizationAdmin(organization.getId(), team.getId(), registerRequest);
eventPublisher.publishEvent(new OrganizationCreatedEvent(organization, userMapper.toUserResponse(user)));


var accessToken = tokenService.generateAccessToken(
user.getId().toString(),
organization.getId(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package app.teamwize.api.base.domain.entity;

public enum EntityStatus {
ACTIVE,
ARCHIVED;
}

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions src/main/java/app/teamwize/api/dayoff/domain/DayOffType.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/app/teamwize/api/dayoff/mapper/DayOffMapper.java

This file was deleted.

This file was deleted.

90 changes: 0 additions & 90 deletions src/main/java/app/teamwize/api/dayoff/service/DayOffService.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public List<Holiday> getHolidays(Long organizationId, Integer year, String count
var endDate = startDate.plusYears(1);
return holidayRepository.findByOrganizationIdAndCountryAndDateIsBetween(organizationId, country, startDate, endDate);
}


public List<Holiday> getHolidays(Long organizationId, LocalDate startDate,LocalDate endDate, String country) {
return holidayRepository.findByOrganizationIdAndCountryAndDateIsBetween(organizationId, country, startDate, endDate);
}
}
Loading

0 comments on commit 03cbd06

Please sign in to comment.