Change createAppeal method in AppealMapper to return UUID, adjust AppealController to construct Appeal with generated UUID.
This commit is contained in:
parent
24d7cfe913
commit
eaee31ab2b
|
|
@ -18,6 +18,7 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -44,9 +45,12 @@ public class AppealController implements AppealsApi {
|
|||
.runQuery(sqlSession -> {
|
||||
log.debug("Loading history by id");
|
||||
try {
|
||||
Appeal appeal = sqlSession.getMapper(AppealMapper.class)
|
||||
.createAppeal(mapper.minecraftAppealDtoToAppeal(minecraftAppealDto));
|
||||
appealCompletableFuture.complete(appeal);
|
||||
Appeal appeal = mapper.minecraftAppealDtoToAppeal(minecraftAppealDto);
|
||||
UUID appealId = sqlSession.getMapper(AppealMapper.class)
|
||||
.createAppeal(appeal);
|
||||
Appeal finalAppeal = new Appeal(appealId, appeal.uuid(), appeal.username(), appeal.reason(),
|
||||
appeal.createdAt(), appeal.sendAt(), appeal.email(), appeal.assignedTo());
|
||||
appealCompletableFuture.complete(finalAppeal);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to load history count", e);
|
||||
appealCompletableFuture.completeExceptionally(e);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package com.alttd.altitudeweb.database.web_db.forms;
|
||||
|
||||
import com.alttd.altitudeweb.model.MinecraftAppealDto;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface AppealMapper {
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ public interface AppealMapper {
|
|||
VALUES (#{uuid}, #{username}, #{reason}, #{createdAt}, #{sendAt}, #{email}, #{assignedTo})
|
||||
""")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
Appeal createAppeal(Appeal appeal);
|
||||
UUID createAppeal(Appeal appeal);
|
||||
|
||||
@Update("""
|
||||
UPDATE appeals
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user