Refactor createAppeal in AppealMapper to void return type, adjust AppealController to remove redundant UUID handling. Optimize AppealDataMapper to use UUID.randomUUID().
This commit is contained in:
parent
eaee31ab2b
commit
f026f24263
|
|
@ -46,11 +46,8 @@ public class AppealController implements AppealsApi {
|
|||
log.debug("Loading history by id");
|
||||
try {
|
||||
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);
|
||||
sqlSession.getMapper(AppealMapper.class).createAppeal(appeal);
|
||||
appealCompletableFuture.complete(appeal);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to load history count", e);
|
||||
appealCompletableFuture.completeExceptionally(e);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.alttd.altitudeweb.database.web_db.forms.Appeal;
|
|||
import com.alttd.altitudeweb.model.MinecraftAppealDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class AppealDataMapper {
|
||||
public MinecraftAppealDto appealToMinecraftAppealDto(Appeal appeal) {
|
||||
|
|
@ -17,7 +19,7 @@ public class AppealDataMapper {
|
|||
|
||||
public Appeal minecraftAppealDtoToAppeal(MinecraftAppealDto minecraftAppealDto) {
|
||||
return new Appeal(
|
||||
null,
|
||||
UUID.randomUUID(),
|
||||
minecraftAppealDto.getUuid(),
|
||||
minecraftAppealDto.getUsername(),
|
||||
minecraftAppealDto.getAppeal(),
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
package com.alttd.altitudeweb.database.web_db.forms;
|
||||
|
||||
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 {
|
||||
|
||||
|
|
@ -14,8 +12,7 @@ public interface AppealMapper {
|
|||
INSERT INTO appeals (uuid, username, reason, created_at, send_at, e_mail, assigned_to)
|
||||
VALUES (#{uuid}, #{username}, #{reason}, #{createdAt}, #{sendAt}, #{email}, #{assignedTo})
|
||||
""")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
UUID createAppeal(Appeal appeal);
|
||||
void createAppeal(Appeal appeal);
|
||||
|
||||
@Update("""
|
||||
UPDATE appeals
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user