Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new user & 'roles' entities #200

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package uk.gov.hmcts.opal.controllers;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.hmcts.opal.dto.search.ApplicationFunctionSearchDto;
import uk.gov.hmcts.opal.entity.ApplicationFunctionEntity;
import uk.gov.hmcts.opal.service.ApplicationFunctionServiceInterface;

import java.util.List;

import static uk.gov.hmcts.opal.util.ResponseUtil.buildResponse;


@RestController
@RequestMapping("/api/application-function")
@Slf4j(topic = "ApplicationFunctionController")
@Tag(name = "ApplicationFunction Controller")
public class ApplicationFunctionController {

private final ApplicationFunctionServiceInterface applicationFunctionService;

public ApplicationFunctionController(
@Qualifier("applicationFunctionServiceProxy") ApplicationFunctionServiceInterface applicationFunctionService) {
this.applicationFunctionService = applicationFunctionService;
}

@GetMapping(value = "/{applicationFunctionId}")
@Operation(summary = "Returns the ApplicationFunction for the given applicationFunctionId.")
public ResponseEntity<ApplicationFunctionEntity> getApplicationFunctionById(
@PathVariable Long applicationFunctionId) {

log.info(":GET:getApplicationFunctionById: applicationFunctionId: {}", applicationFunctionId);

ApplicationFunctionEntity response = applicationFunctionService.getApplicationFunction(applicationFunctionId);

return buildResponse(response);
}

@PostMapping(value = "/search", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Searches ApplicationFunctions based upon criteria in request body")
public ResponseEntity<List<ApplicationFunctionEntity>> postApplicationFunctionsSearch(
@RequestBody ApplicationFunctionSearchDto criteria) {
log.info(":POST:postApplicationFunctionsSearch: query: \n{}", criteria);

List<ApplicationFunctionEntity> response = applicationFunctionService.searchApplicationFunctions(criteria);

return buildResponse(response);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package uk.gov.hmcts.opal.controllers;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.hmcts.opal.dto.search.BusinessUnitUserSearchDto;
import uk.gov.hmcts.opal.entity.BusinessUnitUserEntity;
import uk.gov.hmcts.opal.service.BusinessUnitUserServiceInterface;

import java.util.List;

import static uk.gov.hmcts.opal.util.ResponseUtil.buildResponse;


@RestController
@RequestMapping("/api/business-unit-user")
@Slf4j(topic = "BusinessUnitUserController")
@Tag(name = "BusinessUnitUser Controller")
public class BusinessUnitUserController {

private final BusinessUnitUserServiceInterface businessUnitUserService;

public BusinessUnitUserController(
@Qualifier("businessUnitUserServiceProxy") BusinessUnitUserServiceInterface businessUnitUserService) {
this.businessUnitUserService = businessUnitUserService;
}

@GetMapping(value = "/{businessUnitUserId}")
@Operation(summary = "Returns the BusinessUnitUser for the given businessUnitUserId.")
public ResponseEntity<BusinessUnitUserEntity> getBusinessUnitUserById(@PathVariable String businessUnitUserId) {

log.info(":GET:getBusinessUnitUserById: businessUnitUserId: {}", businessUnitUserId);

BusinessUnitUserEntity response = businessUnitUserService.getBusinessUnitUser(businessUnitUserId);

return buildResponse(response);
}

@PostMapping(value = "/search", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Searches BusinessUnitUsers based upon criteria in request body")
public ResponseEntity<List<BusinessUnitUserEntity>> postBusinessUnitUsersSearch(
@RequestBody BusinessUnitUserSearchDto criteria) {
log.info(":POST:postBusinessUnitUsersSearch: query: \n{}", criteria);

List<BusinessUnitUserEntity> response = businessUnitUserService.searchBusinessUnitUsers(criteria);

return buildResponse(response);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package uk.gov.hmcts.opal.controllers;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.hmcts.opal.dto.search.TemplateSearchDto;
import uk.gov.hmcts.opal.entity.TemplateEntity;
import uk.gov.hmcts.opal.service.TemplateServiceInterface;

import java.util.List;

import static uk.gov.hmcts.opal.util.ResponseUtil.buildResponse;


@RestController
@RequestMapping("/api/template")
@Slf4j(topic = "TemplateController")
@Tag(name = "Template Controller")
public class TemplateController {

private final TemplateServiceInterface templateService;

public TemplateController(@Qualifier("templateServiceProxy") TemplateServiceInterface templateService) {
this.templateService = templateService;
}

@GetMapping(value = "/{templateId}")
@Operation(summary = "Returns the Template for the given templateId.")
public ResponseEntity<TemplateEntity> getTemplateById(@PathVariable Long templateId) {

log.info(":GET:getTemplateById: templateId: {}", templateId);

TemplateEntity response = templateService.getTemplate(templateId);

return buildResponse(response);
}

@PostMapping(value = "/search", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Searches Templates based upon criteria in request body")
public ResponseEntity<List<TemplateEntity>> postTemplatesSearch(@RequestBody TemplateSearchDto criteria) {
log.info(":POST:postTemplatesSearch: query: \n{}", criteria);

List<TemplateEntity> response = templateService.searchTemplates(criteria);

return buildResponse(response);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package uk.gov.hmcts.opal.controllers;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.hmcts.opal.dto.search.TemplateMappingSearchDto;
import uk.gov.hmcts.opal.entity.TemplateMappingEntity;
import uk.gov.hmcts.opal.entity.TemplateMappingEntity.MappingId;
import uk.gov.hmcts.opal.service.TemplateMappingServiceInterface;

import java.util.List;

import static uk.gov.hmcts.opal.util.ResponseUtil.buildResponse;


@RestController
@RequestMapping("/api/template-mapping")
@Slf4j(topic = "TemplateMappingController")
@Tag(name = "TemplateMapping Controller")
public class TemplateMappingController {

private final TemplateMappingServiceInterface templateMappingService;

public TemplateMappingController(
@Qualifier("templateMappingServiceProxy") TemplateMappingServiceInterface templateMappingService) {
this.templateMappingService = templateMappingService;
}

@GetMapping(value = "/{templateId}/{applicationFunctionId}")
@Operation(summary = "Returns the TemplateMapping for the given templateMappingId.")
public ResponseEntity<TemplateMappingEntity> getTemplateMappingById(@PathVariable Long templateId,
@PathVariable Long applicationFunctionId) {

MappingId mappingId = new MappingId(templateId, applicationFunctionId);
log.info(":GET:getTemplateMappingById: mappingId: {}", mappingId);

TemplateMappingEntity response = templateMappingService.getTemplateMapping(mappingId);

return buildResponse(response);
}

@PostMapping(value = "/search", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Searches TemplateMappings based upon criteria in request body")
public ResponseEntity<List<TemplateMappingEntity>> postTemplateMappingsSearch(
@RequestBody TemplateMappingSearchDto criteria) {
log.info(":POST:postTemplateMappingsSearch: query: \n{}", criteria);

List<TemplateMappingEntity> response = templateMappingService.searchTemplateMappings(criteria);

return buildResponse(response);
}


}
58 changes: 58 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/controllers/UserController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package uk.gov.hmcts.opal.controllers;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.hmcts.opal.dto.search.UserSearchDto;
import uk.gov.hmcts.opal.entity.UserEntity;
import uk.gov.hmcts.opal.service.UserServiceInterface;

import java.util.List;

import static uk.gov.hmcts.opal.util.ResponseUtil.buildResponse;


@RestController
@RequestMapping("/api/user")
@Slf4j(topic = "UserController")
@Tag(name = "User Controller")
public class UserController {

private final UserServiceInterface userService;

public UserController(@Qualifier("userServiceProxy") UserServiceInterface userService) {
this.userService = userService;
}

@GetMapping(value = "/{userId}")
@Operation(summary = "Returns the User for the given userId.")
public ResponseEntity<UserEntity> getUserById(@PathVariable String userId) {

log.info(":GET:getUserById: userId: {}", userId);

UserEntity response = userService.getUser(userId);

return buildResponse(response);
}

@PostMapping(value = "/search", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Searches Users based upon criteria in request body")
public ResponseEntity<List<UserEntity>> postUsersSearch(@RequestBody UserSearchDto criteria) {
log.info(":POST:postUsersSearch: query: \n{}", criteria);

List<UserEntity> response = userService.searchUsers(criteria);

return buildResponse(response);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package uk.gov.hmcts.opal.controllers;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import uk.gov.hmcts.opal.dto.search.UserEntitlementSearchDto;
import uk.gov.hmcts.opal.entity.UserEntitlementEntity;
import uk.gov.hmcts.opal.service.UserEntitlementServiceInterface;

import java.util.List;

import static uk.gov.hmcts.opal.util.ResponseUtil.buildResponse;


@RestController
@RequestMapping("/api/user-entitlement")
@Slf4j(topic = "UserEntitlementController")
@Tag(name = "UserEntitlement Controller")
public class UserEntitlementController {

private final UserEntitlementServiceInterface userEntitlementService;

public UserEntitlementController(
@Qualifier("userEntitlementServiceProxy") UserEntitlementServiceInterface userEntitlementService) {
this.userEntitlementService = userEntitlementService;
}

@GetMapping(value = "/{userEntitlementId}")
@Operation(summary = "Returns the UserEntitlement for the given userEntitlementId.")
public ResponseEntity<UserEntitlementEntity> getUserEntitlementById(@PathVariable Long userEntitlementId) {

log.info(":GET:getUserEntitlementById: userEntitlementId: {}", userEntitlementId);

UserEntitlementEntity response = userEntitlementService.getUserEntitlement(userEntitlementId);

return buildResponse(response);
}

@PostMapping(value = "/search", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Searches UserEntitlements based upon criteria in request body")
public ResponseEntity<List<UserEntitlementEntity>> postUserEntitlementsSearch(
@RequestBody UserEntitlementSearchDto criteria) {
log.info(":POST:postUserEntitlementsSearch: query: \n{}", criteria);

List<UserEntitlementEntity> response = userEntitlementService.searchUserEntitlements(criteria);

return buildResponse(response);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.hmcts.opal.dto.search;

import lombok.Builder;
import lombok.Data;
import uk.gov.hmcts.opal.dto.ToJsonString;

@Data
@Builder
public class ApplicationFunctionSearchDto implements ToJsonString {

private String applicationFunctionId;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.hmcts.opal.dto.search;

import lombok.Builder;
import lombok.Data;
import uk.gov.hmcts.opal.dto.ToJsonString;

@Data
@Builder
public class BusinessUnitUserSearchDto implements ToJsonString {

private String businessUnitUserId;

}
Loading