-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
both: create user and refactor admin panel
- Loading branch information
Showing
28 changed files
with
590 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...d/spring-boot/src/main/java/org/bootstrapbugz/backend/user/controller/RoleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.bootstrapbugz.backend.user.controller; | ||
|
||
import java.util.List; | ||
import org.bootstrapbugz.backend.shared.constants.Path; | ||
import org.bootstrapbugz.backend.user.payload.dto.RoleDTO; | ||
import org.bootstrapbugz.backend.user.service.RoleService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping(Path.ROLES) | ||
public class RoleController { | ||
private final RoleService roleService; | ||
|
||
public RoleController(RoleService roleService) { | ||
this.roleService = roleService; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<RoleDTO>> findAll() { | ||
return ResponseEntity.ok(roleService.findAll()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
backend/spring-boot/src/main/java/org/bootstrapbugz/backend/user/service/RoleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.bootstrapbugz.backend.user.service; | ||
|
||
import java.util.List; | ||
import org.bootstrapbugz.backend.user.payload.dto.RoleDTO; | ||
|
||
public interface RoleService { | ||
List<RoleDTO> findAll(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...pring-boot/src/main/java/org/bootstrapbugz/backend/user/service/impl/RoleServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.bootstrapbugz.backend.user.service.impl; | ||
|
||
import java.util.List; | ||
import org.bootstrapbugz.backend.user.mapper.UserMapper; | ||
import org.bootstrapbugz.backend.user.payload.dto.RoleDTO; | ||
import org.bootstrapbugz.backend.user.repository.RoleRepository; | ||
import org.bootstrapbugz.backend.user.service.RoleService; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@PreAuthorize("hasAuthority('ADMIN')") | ||
public class RoleServiceImpl implements RoleService { | ||
private final RoleRepository roleRepository; | ||
|
||
public RoleServiceImpl(RoleRepository roleRepository) { | ||
this.roleRepository = roleRepository; | ||
} | ||
|
||
@Override | ||
public List<RoleDTO> findAll() { | ||
return roleRepository.findAll().stream().map(UserMapper.INSTANCE::roleToRoleDTO).toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...pring-boot/src/test/java/org/bootstrapbugz/backend/user/integration/RoleControllerIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.bootstrapbugz.backend.user.integration; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.bootstrapbugz.backend.shared.config.DatabaseContainers; | ||
import org.bootstrapbugz.backend.shared.constants.Path; | ||
import org.bootstrapbugz.backend.shared.util.IntegrationTestUtil; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
@DirtiesContext | ||
@AutoConfigureMockMvc | ||
@ActiveProfiles("test") | ||
@SpringBootTest | ||
public class RoleControllerIT extends DatabaseContainers { | ||
@Autowired private MockMvc mockMvc; | ||
@Autowired private ObjectMapper objectMapper; | ||
|
||
@Test | ||
void findAllRoles() throws Exception { | ||
final var authTokens = IntegrationTestUtil.authTokens(mockMvc, objectMapper, "admin"); | ||
mockMvc | ||
.perform( | ||
get(Path.ROLES) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.headers(IntegrationTestUtil.authHeader(authTokens.accessToken()))) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.length()").value(2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
frontend/svelte-kit/src/lib/components/ui/dialog/dialog-content.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
import { Dialog as DialogPrimitive, type WithoutChildrenOrChild } from 'bits-ui'; | ||
import X from 'lucide-svelte/icons/x'; | ||
import type { Snippet } from 'svelte'; | ||
import * as Dialog from './index.js'; | ||
import { cn } from '$lib/utils.js'; | ||
let { | ||
ref = $bindable(null), | ||
class: className, | ||
portalProps, | ||
children, | ||
...restProps | ||
}: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & { | ||
portalProps?: DialogPrimitive.PortalProps; | ||
children: Snippet; | ||
} = $props(); | ||
</script> | ||
|
||
<Dialog.Portal {...portalProps}> | ||
<Dialog.Overlay /> | ||
<DialogPrimitive.Content | ||
bind:ref | ||
class={cn( | ||
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg', | ||
className, | ||
)} | ||
{...restProps} | ||
> | ||
{@render children?.()} | ||
<DialogPrimitive.Close | ||
class="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground" | ||
> | ||
<X class="size-4" /> | ||
<span class="sr-only">Close</span> | ||
</DialogPrimitive.Close> | ||
</DialogPrimitive.Content> | ||
</Dialog.Portal> |
16 changes: 16 additions & 0 deletions
16
frontend/svelte-kit/src/lib/components/ui/dialog/dialog-description.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script lang="ts"> | ||
import { Dialog as DialogPrimitive } from 'bits-ui'; | ||
import { cn } from '$lib/utils.js'; | ||
let { | ||
ref = $bindable(null), | ||
class: className, | ||
...restProps | ||
}: DialogPrimitive.DescriptionProps = $props(); | ||
</script> | ||
|
||
<DialogPrimitive.Description | ||
bind:ref | ||
class={cn('text-sm text-muted-foreground', className)} | ||
{...restProps} | ||
/> |
20 changes: 20 additions & 0 deletions
20
frontend/svelte-kit/src/lib/components/ui/dialog/dialog-footer.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import type { WithElementRef } from 'bits-ui'; | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
import { cn } from '$lib/utils.js'; | ||
let { | ||
ref = $bindable(null), | ||
class: className, | ||
children, | ||
...restProps | ||
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props(); | ||
</script> | ||
|
||
<div | ||
bind:this={ref} | ||
class={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)} | ||
{...restProps} | ||
> | ||
{@render children?.()} | ||
</div> |
20 changes: 20 additions & 0 deletions
20
frontend/svelte-kit/src/lib/components/ui/dialog/dialog-header.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
import type { WithElementRef } from 'bits-ui'; | ||
import { cn } from '$lib/utils.js'; | ||
let { | ||
ref = $bindable(null), | ||
class: className, | ||
children, | ||
...restProps | ||
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props(); | ||
</script> | ||
|
||
<div | ||
bind:this={ref} | ||
class={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)} | ||
{...restProps} | ||
> | ||
{@render children?.()} | ||
</div> |
19 changes: 19 additions & 0 deletions
19
frontend/svelte-kit/src/lib/components/ui/dialog/dialog-overlay.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script lang="ts"> | ||
import { Dialog as DialogPrimitive } from 'bits-ui'; | ||
import { cn } from '$lib/utils.js'; | ||
let { | ||
ref = $bindable(null), | ||
class: className, | ||
...restProps | ||
}: DialogPrimitive.OverlayProps = $props(); | ||
</script> | ||
|
||
<DialogPrimitive.Overlay | ||
bind:ref | ||
class={cn( | ||
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', | ||
className, | ||
)} | ||
{...restProps} | ||
/> |
Oops, something went wrong.