Skip to content

Commit

Permalink
Merge branch 'feature/GAP-1850-spadmin' of github.com:cabinetoffice/g…
Browse files Browse the repository at this point in the history
…ap-user-service into feature/GAP-1850-spadmin
  • Loading branch information
dylanwrightAND committed Jul 17, 2023
2 parents 0653f3b + 441b91d commit b6aaa76
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gov.cabinetofice.gapuserservice.dto;

import gov.cabinetofice.gapuserservice.model.User;
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class ChangeDepartmentPageDto {
private User user;
private List<DepartmentDto> departments;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ public WebSecurityCustomizer webSecurityCustomizer() {
"/redirect-after-cola-login",
"/error/**",
"/.well-known/jwks.json",
"/logout",
"/super-admin-dashboard",
"/user/**",
"/user/**/department"
"/logout"
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package gov.cabinetofice.gapuserservice.web;

import gov.cabinetofice.gapuserservice.dto.ChangeDepartmentPageDto;
import gov.cabinetofice.gapuserservice.dto.DepartmentDto;
import gov.cabinetofice.gapuserservice.model.User;
import gov.cabinetofice.gapuserservice.service.DepartmentService;
import gov.cabinetofice.gapuserservice.service.user.OneLoginUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -11,13 +14,16 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


@RequiredArgsConstructor
@Controller
@ConditionalOnProperty(value = "feature.onelogin.enabled", havingValue = "true")
public class UserController {

private final OneLoginUserService oneLoginUserService;
private final DepartmentService departmentService;


@GetMapping("/user/{id}")
Expand All @@ -32,4 +38,14 @@ public ResponseEntity<User> updateDepartment(@PathVariable("id") Integer id,
return ResponseEntity.ok(user);
}

@GetMapping("/page/user/{userId}/change-department")
public ResponseEntity<ChangeDepartmentPageDto> getChangeDepartmentPage(@PathVariable("userId") Integer userId) {
final User user = oneLoginUserService.getUserById(userId);
final List<DepartmentDto> departments = departmentService.getAllDepartments();
return ResponseEntity.ok(ChangeDepartmentPageDto.builder()
.departments(departments)
.user(user)
.build());
}

}

0 comments on commit b6aaa76

Please sign in to comment.