Skip to content

Commit 429f1ea

Browse files
author
Dominik Grenz
committed
Merge branch 'main' into MUXDBS-101-checklist-detail-intro-area
2 parents 8df2107 + d5adfdc commit 429f1ea

File tree

53 files changed

+874
-595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+874
-595
lines changed

.github/workflows/maven-node-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
matrix:
1717
include:
1818
- app-path: personalization-service
19+
- app-path: personalization-webcomponents
1920

2021
steps:
2122
- uses: it-at-m/lhm_actions/action-templates/actions/action-checkout@9767179088fd2e344d1a24c17404ab809a60f1b6 # v1.0.20

.github/workflows/maven-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
- id: maven-release-step
3131
uses: it-at-m/lhm_actions/action-templates/actions/action-maven-release@9767179088fd2e344d1a24c17404ab809a60f1b6 # v1.0.20
3232
with:
33+
use-pr: true
3334
app-path: ${{ github.event.inputs.app-path }}
3435
releaseVersion: ${{ github.event.inputs.releaseVersion }}
3536
developmentVersion: ${{ github.event.inputs.developmentVersion }}

.github/workflows/npm-release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ on:
1515
type: choice
1616
description: "Select the node service to release"
1717
required: true
18-
default: refarch-frontend
18+
default: personalization-webcomponents
1919
options:
20-
- refarch-frontend # Add or modify frontend paths according to your project structure
20+
- personalization-webcomponents # Add or modify frontend paths according to your project structure
2121
skip-deployment:
2222
default: true
2323
type: boolean
@@ -38,6 +38,7 @@ jobs:
3838
- id: npm_release
3939
uses: it-at-m/lhm_actions/action-templates/actions/action-npm-release@9767179088fd2e344d1a24c17404ab809a60f1b6 # v1.0.20
4040
with:
41+
use-pr: true
4142
app-path: ${{ inputs.app-path }}
4243
releaseVersion: ${{ inputs.release-version }}
4344
- id: node

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "refarch-templates-docs",
2+
"name": "dbs-templates-docs",
33
"version": "0.0.0",
44
"type": "module",
55
"private": true,

personalization-service/pom.xml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
88
<version>3.4.5</version>
9-
<relativePath/>
9+
<relativePath />
1010
</parent>
1111

1212
<groupId>de.muenchen.dbs.personalization</groupId>
1313
<artifactId>personalization-service</artifactId>
14-
<version>0.0.1-SNAPSHOT</version>
14+
<version>0.0.2-SNAPSHOT</version>
1515
<name>personalization_service</name>
1616
<description>Personalization service for the digital citizen service of the City of Munich</description>
1717
<url>https://github.com/it-at-m/dbs</url>
@@ -53,6 +53,9 @@
5353

5454
<!-- Additional required dependencies -->
5555
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version> <!-- Needed to make MapStruct and Lombok work together -->
56+
<springdoc-openapi-starter-webmvc-ui.version>2.8.8</springdoc-openapi-starter-webmvc-ui.version>
57+
<springdoc-openapi-maven-plugin.version>1.5</springdoc-openapi-maven-plugin.version>
58+
<therapi-runtime-javadoc.version>0.15.0</therapi-runtime-javadoc.version>
5659

5760
<!-- Flyway maven plugin configuration for local stack database -->
5861
<flyway.url>jdbc:postgresql://localhost:5432/postgres</flyway.url>
@@ -163,6 +166,16 @@
163166
<artifactId>spotbugs-annotations</artifactId>
164167
<version>${spotbugs-annotations.version}</version>
165168
</dependency>
169+
<dependency>
170+
<groupId>org.springdoc</groupId>
171+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
172+
<version>${springdoc-openapi-starter-webmvc-ui.version}</version>
173+
</dependency>
174+
<dependency>
175+
<groupId>com.github.therapi</groupId>
176+
<artifactId>therapi-runtime-javadoc</artifactId>
177+
<version>${therapi-runtime-javadoc.version}</version>
178+
</dependency>
166179

167180
<!-- Testing -->
168181
<dependency>
@@ -270,6 +283,11 @@
270283
<artifactId>lombok-mapstruct-binding</artifactId>
271284
<version>${lombok-mapstruct-binding.version}</version>
272285
</path>
286+
<path>
287+
<groupId>com.github.therapi</groupId>
288+
<artifactId>therapi-runtime-javadoc-scribe</artifactId>
289+
<version>${therapi-runtime-javadoc.version}</version>
290+
</path>
273291
</annotationProcessorPaths>
274292
<showDeprecation>true</showDeprecation>
275293
<failOnWarning>false</failOnWarning>
@@ -288,6 +306,17 @@
288306
</executions>
289307
</plugin>
290308

309+
<plugin>
310+
<groupId>org.springdoc</groupId>
311+
<artifactId>springdoc-openapi-maven-plugin</artifactId>
312+
<version>${springdoc-openapi-maven-plugin.version}</version>
313+
<configuration>
314+
<apiDocsUrl>http://localhost:39146/v3/api-docs</apiDocsUrl>
315+
<outputFileName>${project.name}.yaml</outputFileName>
316+
<failOnError>true</failOnError>
317+
</configuration>
318+
</plugin>
319+
291320
<!-- Testing -->
292321
<plugin>
293322
<groupId>org.apache.maven.plugins</groupId>

personalization-service/spotbugs-exclude-rules.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
<Match>
77
<Bug pattern="EI_EXPOSE_REP2"/> <!-- Rule is ignored because spring uses dependency injection. The classes that are injected will be managed by Spring, meaning they do not need to be immutable. See https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-collaborators.html -->
88
</Match>
9+
<Match>
10+
<Bug pattern="EI_EXPOSE_REP"/> <!-- Rule is ignored because spring uses dependency injection. The classes that are injected will be managed by Spring, meaning they do not need to be immutable. See https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-collaborators.html -->
11+
</Match>
912
</FindBugsFilter>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package de.muenchen.dbs.personalization.checklist;
2+
3+
import de.muenchen.dbs.personalization.checklist.domain.Checklist;
4+
import de.muenchen.dbs.personalization.checklist.domain.ChecklistCreateDTO;
5+
import de.muenchen.dbs.personalization.checklist.domain.ChecklistMapper;
6+
import de.muenchen.dbs.personalization.checklist.domain.ChecklistReadDTO;
7+
import de.muenchen.dbs.personalization.checklist.domain.ChecklistUpdateDTO;
8+
import io.swagger.v3.oas.annotations.Operation;
9+
import io.swagger.v3.oas.annotations.tags.Tag;
10+
import jakarta.validation.Valid;
11+
import java.util.List;
12+
import java.util.UUID;
13+
import lombok.RequiredArgsConstructor;
14+
import lombok.extern.slf4j.Slf4j;
15+
import org.springframework.http.HttpStatus;
16+
import org.springframework.web.bind.annotation.*;
17+
18+
@RestController
19+
@RequestMapping("/checklist")
20+
@Slf4j
21+
@RequiredArgsConstructor
22+
@Tag(name = "Checklists", description = "Creating, reading and deleting Checklists.")
23+
public class ChecklistController {
24+
25+
private final ChecklistService checklistService;
26+
private final ChecklistMapper checklistMapper;
27+
28+
@GetMapping
29+
@Operation(summary = "Get all checklists by user.", description = "Returns all checklists of an user by lhmExtId")
30+
@ResponseStatus(HttpStatus.OK)
31+
public List<ChecklistReadDTO> getChecklists(@RequestHeader("lhmExtID") final String lhmExtID) {
32+
final List<Checklist> checklists = checklistService.getChecklists(lhmExtID);
33+
return checklists.stream().map(checklistMapper::toReadDTO).toList();
34+
}
35+
36+
@GetMapping(path = "/{checklistID}")
37+
@Operation(summary = "Get specific checklist by checklist-id.", description = "Returns a checklist by checklistId")
38+
@ResponseStatus(HttpStatus.OK)
39+
public ChecklistReadDTO getChecklist(@PathVariable("checklistID") final UUID checklistID) {
40+
return checklistMapper.toReadDTO(checklistService.getChecklist(checklistID));
41+
}
42+
43+
@PostMapping
44+
@Operation(summary = "Create a new checklist", description = "Creates a new checklist using the provided checklist details.")
45+
@ResponseStatus(HttpStatus.CREATED)
46+
public ChecklistReadDTO createChecklist(@Valid @RequestBody final ChecklistCreateDTO checklistCreateDTO) {
47+
return checklistMapper
48+
.toReadDTO(checklistService.createChecklist(checklistMapper.toCreateChecklist(checklistCreateDTO)));
49+
}
50+
51+
@PutMapping("/{checklistID}")
52+
@Operation(summary = "Update a checklist", description = "Updates a checklist using the provided checklist details.")
53+
@ResponseStatus(HttpStatus.OK)
54+
public ChecklistReadDTO updateChecklist(@Valid @RequestBody final ChecklistUpdateDTO checklistUpdateDTO,
55+
@PathVariable("checklistID") final UUID checklistID) {
56+
return checklistMapper.toReadDTO(checklistService.updateChecklist(checklistMapper.toUpdateChecklist(checklistUpdateDTO), checklistID));
57+
}
58+
59+
@DeleteMapping("/{checklistID}")
60+
@Operation(summary = "Delete a checklist", description = "Deletes a checklist by checklistId.")
61+
@ResponseStatus(HttpStatus.OK)
62+
public void deleteChecklist(@PathVariable("checklistID") final UUID checklistID) {
63+
checklistService.deleteChecklist(checklistID);
64+
}
65+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package de.muenchen.dbs.personalization.checklist;
2+
3+
import de.muenchen.dbs.personalization.checklist.domain.Checklist;
4+
import java.util.List;
5+
import java.util.UUID;
6+
import org.springframework.data.jpa.repository.JpaRepository;
7+
import org.springframework.stereotype.Repository;
8+
9+
@Repository
10+
public interface ChecklistRepository extends JpaRepository<Checklist, UUID> {
11+
12+
List<Checklist> findChecklistByLhmExtId(String lhmExtId);
13+
14+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package de.muenchen.dbs.personalization.checklist;
2+
3+
import static de.muenchen.dbs.personalization.common.ExceptionMessageConstants.MSG_NOT_FOUND;
4+
5+
import de.muenchen.dbs.personalization.checklist.domain.Checklist;
6+
import de.muenchen.dbs.personalization.common.NotFoundException;
7+
import de.muenchen.dbs.personalization.security.Authorities;
8+
import java.time.ZonedDateTime;
9+
import java.util.List;
10+
import java.util.UUID;
11+
import lombok.RequiredArgsConstructor;
12+
import lombok.extern.slf4j.Slf4j;
13+
import org.springframework.security.access.prepost.PreAuthorize;
14+
import org.springframework.stereotype.Service;
15+
16+
@Service
17+
@Slf4j
18+
@RequiredArgsConstructor
19+
public class ChecklistService {
20+
21+
private final ChecklistRepository checklistRepository;
22+
23+
@PreAuthorize(Authorities.CHECKLIST_CREATE)
24+
public Checklist createChecklist(final Checklist checklist) {
25+
log.debug("Create Checklist {}", checklist);
26+
return checklistRepository.save(checklist);
27+
}
28+
29+
@PreAuthorize(Authorities.CHECKLIST_GET_ALL)
30+
public List<Checklist> getChecklists(final String userId) {
31+
log.debug("Get all checklists of {}", userId);
32+
return checklistRepository.findChecklistByLhmExtId(userId);
33+
}
34+
35+
@PreAuthorize(Authorities.CHECKLIST_GET)
36+
public Checklist getChecklist(final UUID checklistId) {
37+
log.debug("Get checklist with ID {}", checklistId);
38+
return getChecklistOrThrowException(checklistId);
39+
}
40+
41+
@PreAuthorize(Authorities.CHECKLIST_UPDATE)
42+
public Checklist updateChecklist(final Checklist checklist, final UUID checklistId) {
43+
final Checklist foundChecklist = getChecklistOrThrowException(checklistId);
44+
foundChecklist.setChecklistItems(checklist.getChecklistItems());
45+
foundChecklist.setLastUpdate(ZonedDateTime.now());
46+
log.debug("Update Checklist {}", foundChecklist);
47+
return checklistRepository.save(foundChecklist);
48+
}
49+
50+
@PreAuthorize(Authorities.CHECKLIST_DELETE)
51+
public void deleteChecklist(final UUID checklistId) {
52+
log.debug("Delete Checklist with ID {}", checklistId);
53+
checklistRepository.deleteById(checklistId);
54+
}
55+
56+
private Checklist getChecklistOrThrowException(final UUID checklistId) {
57+
return checklistRepository
58+
.findById(checklistId)
59+
.orElseThrow(() -> new NotFoundException(String.format(MSG_NOT_FOUND, checklistId)));
60+
}
61+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package de.muenchen.dbs.personalization.checklist.domain;
2+
3+
import de.muenchen.dbs.personalization.common.BaseEntity;
4+
import jakarta.persistence.CollectionTable;
5+
import jakarta.persistence.Column;
6+
import jakarta.persistence.ElementCollection;
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.JoinColumn;
9+
import jakarta.validation.constraints.NotNull;
10+
import java.io.Serial;
11+
import java.time.ZonedDateTime;
12+
import java.util.List;
13+
import lombok.AllArgsConstructor;
14+
import lombok.Data;
15+
import lombok.EqualsAndHashCode;
16+
import lombok.NoArgsConstructor;
17+
18+
@Entity
19+
@Data
20+
@EqualsAndHashCode(callSuper = true)
21+
@NoArgsConstructor
22+
@AllArgsConstructor
23+
public class Checklist extends BaseEntity {
24+
25+
@Serial
26+
private static final long serialVersionUID = 1L;
27+
28+
@Column(name = "lhm_ext_id", nullable = false)
29+
@NotNull
30+
private String lhmExtId;
31+
32+
@Column(name = "title")
33+
@NotNull
34+
private String title;
35+
36+
@Column(name = "last_update")
37+
private ZonedDateTime lastUpdate;
38+
39+
@ElementCollection
40+
@CollectionTable(name = "checklist_item", joinColumns = @JoinColumn(name = "checklist_id"))
41+
private List<ChecklistItem> checklistItems;
42+
}

0 commit comments

Comments
 (0)