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.bind.annotation.RestController;
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
@ -44,9 +45,12 @@ public class AppealController implements AppealsApi {
|
||||||
.runQuery(sqlSession -> {
|
.runQuery(sqlSession -> {
|
||||||
log.debug("Loading history by id");
|
log.debug("Loading history by id");
|
||||||
try {
|
try {
|
||||||
Appeal appeal = sqlSession.getMapper(AppealMapper.class)
|
Appeal appeal = mapper.minecraftAppealDtoToAppeal(minecraftAppealDto);
|
||||||
.createAppeal(mapper.minecraftAppealDtoToAppeal(minecraftAppealDto));
|
UUID appealId = sqlSession.getMapper(AppealMapper.class)
|
||||||
appealCompletableFuture.complete(appeal);
|
.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) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to load history count", e);
|
log.error("Failed to load history count", e);
|
||||||
appealCompletableFuture.completeExceptionally(e);
|
appealCompletableFuture.completeExceptionally(e);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
package com.alttd.altitudeweb.database.web_db.forms;
|
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.Insert;
|
||||||
import org.apache.ibatis.annotations.Options;
|
import org.apache.ibatis.annotations.Options;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface AppealMapper {
|
public interface AppealMapper {
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ public interface AppealMapper {
|
||||||
VALUES (#{uuid}, #{username}, #{reason}, #{createdAt}, #{sendAt}, #{email}, #{assignedTo})
|
VALUES (#{uuid}, #{username}, #{reason}, #{createdAt}, #{sendAt}, #{email}, #{assignedTo})
|
||||||
""")
|
""")
|
||||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||||
Appeal createAppeal(Appeal appeal);
|
UUID createAppeal(Appeal appeal);
|
||||||
|
|
||||||
@Update("""
|
@Update("""
|
||||||
UPDATE appeals
|
UPDATE appeals
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user