diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/entity/base/EchoEntity.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/EchoDto.java similarity index 95% rename from app/adapter/src/main/java/net/averak/gsync/adapter/dao/entity/base/EchoEntity.java rename to app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/EchoDto.java index 99c8e19..6ef8419 100644 --- a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/entity/base/EchoEntity.java +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/EchoDto.java @@ -1,10 +1,10 @@ -package net.averak.gsync.adapter.dao.entity.base; +package net.averak.gsync.adapter.dao.dto.base; import java.time.LocalDateTime; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class EchoEntity { +public class EchoDto { /** * * This field was generated by MyBatis Generator. This field corresponds to the @@ -56,7 +56,7 @@ public class EchoEntity { * * @mbg.generated */ - public EchoEntity(@Nonnull String echoId, @Nonnull String message, @Nonnull LocalDateTime timestamp, + public EchoDto(@Nonnull String echoId, @Nonnull String message, @Nonnull LocalDateTime timestamp, @Nonnull LocalDateTime createdAt, @Nonnull LocalDateTime updatedAt) { this.echoId = echoId; this.message = message; @@ -71,7 +71,7 @@ public EchoEntity(@Nonnull String echoId, @Nonnull String message, @Nonnull Loca * * @mbg.generated */ - public EchoEntity() { + public EchoDto() { super(); } diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/entity/base/EchoExample.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/EchoExample.java similarity index 99% rename from app/adapter/src/main/java/net/averak/gsync/adapter/dao/entity/base/EchoExample.java rename to app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/EchoExample.java index 2b11e54..b61bea2 100644 --- a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/entity/base/EchoExample.java +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/EchoExample.java @@ -1,4 +1,4 @@ -package net.averak.gsync.adapter.dao.entity.base; +package net.averak.gsync.adapter.dao.dto.base; import java.time.LocalDateTime; import java.util.ArrayList; diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerDto.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerDto.java new file mode 100644 index 0000000..5d12be0 --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerDto.java @@ -0,0 +1,207 @@ +package net.averak.gsync.adapter.dao.dto.base; + +import java.time.LocalDateTime; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class PlayerDto { + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player.player_id + * + * @mbg.generated + */ + private String playerId; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player.friend_id + * + * @mbg.generated + */ + private String friendId; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player.is_banned + * + * @mbg.generated + */ + private Boolean isBanned; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player.created_at + * + * @mbg.generated + */ + private LocalDateTime createdAt; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player.updated_at + * + * @mbg.generated + */ + private LocalDateTime updatedAt; + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public PlayerDto(@Nonnull String playerId, @Nonnull String friendId, @Nonnull Boolean isBanned, + @Nonnull LocalDateTime createdAt, @Nonnull LocalDateTime updatedAt) { + this.playerId = playerId; + this.friendId = friendId; + this.isBanned = isBanned; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public PlayerDto() { + super(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player.player_id + * + * @return the value of gsync_player.player_id + * + * @mbg.generated + */ + @Nonnull + public String getPlayerId() { + return playerId; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player.player_id + * + * @param playerId + * the value for gsync_player.player_id + * + * @mbg.generated + */ + public void setPlayerId(@Nonnull String playerId) { + this.playerId = playerId; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player.friend_id + * + * @return the value of gsync_player.friend_id + * + * @mbg.generated + */ + @Nonnull + public String getFriendId() { + return friendId; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player.friend_id + * + * @param friendId + * the value for gsync_player.friend_id + * + * @mbg.generated + */ + public void setFriendId(@Nonnull String friendId) { + this.friendId = friendId; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player.is_banned + * + * @return the value of gsync_player.is_banned + * + * @mbg.generated + */ + @Nonnull + public Boolean getIsBanned() { + return isBanned; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player.is_banned + * + * @param isBanned + * the value for gsync_player.is_banned + * + * @mbg.generated + */ + public void setIsBanned(@Nonnull Boolean isBanned) { + this.isBanned = isBanned; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player.created_at + * + * @return the value of gsync_player.created_at + * + * @mbg.generated + */ + @Nonnull + public LocalDateTime getCreatedAt() { + return createdAt; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player.created_at + * + * @param createdAt + * the value for gsync_player.created_at + * + * @mbg.generated + */ + public void setCreatedAt(@Nonnull LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player.updated_at + * + * @return the value of gsync_player.updated_at + * + * @mbg.generated + */ + @Nonnull + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player.updated_at + * + * @param updatedAt + * the value for gsync_player.updated_at + * + * @mbg.generated + */ + public void setUpdatedAt(@Nonnull LocalDateTime updatedAt) { + this.updatedAt = updatedAt; + } +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerExample.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerExample.java new file mode 100644 index 0000000..0206707 --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerExample.java @@ -0,0 +1,622 @@ +package net.averak.gsync.adapter.dao.dto.base; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +public class PlayerExample { + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player + * + * @mbg.generated + */ + protected List oredCriteria; + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public PlayerExample() { + oredCriteria = new ArrayList<>(); + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andPlayerIdIsNull() { + addCriterion("`player_id` is null"); + return (Criteria) this; + } + + public Criteria andPlayerIdIsNotNull() { + addCriterion("`player_id` is not null"); + return (Criteria) this; + } + + public Criteria andPlayerIdEqualTo(String value) { + addCriterion("`player_id` =", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotEqualTo(String value) { + addCriterion("`player_id` <>", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdGreaterThan(String value) { + addCriterion("`player_id` >", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdGreaterThanOrEqualTo(String value) { + addCriterion("`player_id` >=", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLessThan(String value) { + addCriterion("`player_id` <", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLessThanOrEqualTo(String value) { + addCriterion("`player_id` <=", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLike(String value) { + addCriterion("`player_id` like", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotLike(String value) { + addCriterion("`player_id` not like", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdIn(List values) { + addCriterion("`player_id` in", values, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotIn(List values) { + addCriterion("`player_id` not in", values, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdBetween(String value1, String value2) { + addCriterion("`player_id` between", value1, value2, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotBetween(String value1, String value2) { + addCriterion("`player_id` not between", value1, value2, "playerId"); + return (Criteria) this; + } + + public Criteria andFriendIdIsNull() { + addCriterion("`friend_id` is null"); + return (Criteria) this; + } + + public Criteria andFriendIdIsNotNull() { + addCriterion("`friend_id` is not null"); + return (Criteria) this; + } + + public Criteria andFriendIdEqualTo(String value) { + addCriterion("`friend_id` =", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdNotEqualTo(String value) { + addCriterion("`friend_id` <>", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdGreaterThan(String value) { + addCriterion("`friend_id` >", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdGreaterThanOrEqualTo(String value) { + addCriterion("`friend_id` >=", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdLessThan(String value) { + addCriterion("`friend_id` <", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdLessThanOrEqualTo(String value) { + addCriterion("`friend_id` <=", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdLike(String value) { + addCriterion("`friend_id` like", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdNotLike(String value) { + addCriterion("`friend_id` not like", value, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdIn(List values) { + addCriterion("`friend_id` in", values, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdNotIn(List values) { + addCriterion("`friend_id` not in", values, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdBetween(String value1, String value2) { + addCriterion("`friend_id` between", value1, value2, "friendId"); + return (Criteria) this; + } + + public Criteria andFriendIdNotBetween(String value1, String value2) { + addCriterion("`friend_id` not between", value1, value2, "friendId"); + return (Criteria) this; + } + + public Criteria andIsBannedIsNull() { + addCriterion("`is_banned` is null"); + return (Criteria) this; + } + + public Criteria andIsBannedIsNotNull() { + addCriterion("`is_banned` is not null"); + return (Criteria) this; + } + + public Criteria andIsBannedEqualTo(Boolean value) { + addCriterion("`is_banned` =", value, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedNotEqualTo(Boolean value) { + addCriterion("`is_banned` <>", value, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedGreaterThan(Boolean value) { + addCriterion("`is_banned` >", value, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedGreaterThanOrEqualTo(Boolean value) { + addCriterion("`is_banned` >=", value, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedLessThan(Boolean value) { + addCriterion("`is_banned` <", value, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedLessThanOrEqualTo(Boolean value) { + addCriterion("`is_banned` <=", value, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedIn(List values) { + addCriterion("`is_banned` in", values, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedNotIn(List values) { + addCriterion("`is_banned` not in", values, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedBetween(Boolean value1, Boolean value2) { + addCriterion("`is_banned` between", value1, value2, "isBanned"); + return (Criteria) this; + } + + public Criteria andIsBannedNotBetween(Boolean value1, Boolean value2) { + addCriterion("`is_banned` not between", value1, value2, "isBanned"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("`created_at` is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("`created_at` is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(LocalDateTime value) { + addCriterion("`created_at` =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(LocalDateTime value) { + addCriterion("`created_at` <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(LocalDateTime value) { + addCriterion("`created_at` >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`created_at` >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(LocalDateTime value) { + addCriterion("`created_at` <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`created_at` <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("`created_at` in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("`created_at` not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`created_at` between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`created_at` not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("`updated_at` is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("`updated_at` is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(LocalDateTime value) { + addCriterion("`updated_at` =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(LocalDateTime value) { + addCriterion("`updated_at` <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(LocalDateTime value) { + addCriterion("`updated_at` >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`updated_at` >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(LocalDateTime value) { + addCriterion("`updated_at` <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`updated_at` <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("`updated_at` in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("`updated_at` not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`updated_at` between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`updated_at` not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player + * + * @mbg.generated + */ + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerLoginDto.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerLoginDto.java new file mode 100644 index 0000000..d33b5b9 --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerLoginDto.java @@ -0,0 +1,207 @@ +package net.averak.gsync.adapter.dao.dto.base; + +import java.time.LocalDateTime; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class PlayerLoginDto { + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_login.player_id + * + * @mbg.generated + */ + private String playerId; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_login.total_login_days + * + * @mbg.generated + */ + private Long totalLoginDays; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_login.last_logged_in_at + * + * @mbg.generated + */ + private LocalDateTime lastLoggedInAt; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_login.created_at + * + * @mbg.generated + */ + private LocalDateTime createdAt; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_login.updated_at + * + * @mbg.generated + */ + private LocalDateTime updatedAt; + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public PlayerLoginDto(@Nonnull String playerId, @Nonnull Long totalLoginDays, @Nonnull LocalDateTime lastLoggedInAt, + @Nonnull LocalDateTime createdAt, @Nonnull LocalDateTime updatedAt) { + this.playerId = playerId; + this.totalLoginDays = totalLoginDays; + this.lastLoggedInAt = lastLoggedInAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public PlayerLoginDto() { + super(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_login.player_id + * + * @return the value of gsync_player_login.player_id + * + * @mbg.generated + */ + @Nonnull + public String getPlayerId() { + return playerId; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_login.player_id + * + * @param playerId + * the value for gsync_player_login.player_id + * + * @mbg.generated + */ + public void setPlayerId(@Nonnull String playerId) { + this.playerId = playerId; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_login.total_login_days + * + * @return the value of gsync_player_login.total_login_days + * + * @mbg.generated + */ + @Nonnull + public Long getTotalLoginDays() { + return totalLoginDays; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_login.total_login_days + * + * @param totalLoginDays + * the value for gsync_player_login.total_login_days + * + * @mbg.generated + */ + public void setTotalLoginDays(@Nonnull Long totalLoginDays) { + this.totalLoginDays = totalLoginDays; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_login.last_logged_in_at + * + * @return the value of gsync_player_login.last_logged_in_at + * + * @mbg.generated + */ + @Nonnull + public LocalDateTime getLastLoggedInAt() { + return lastLoggedInAt; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_login.last_logged_in_at + * + * @param lastLoggedInAt + * the value for gsync_player_login.last_logged_in_at + * + * @mbg.generated + */ + public void setLastLoggedInAt(@Nonnull LocalDateTime lastLoggedInAt) { + this.lastLoggedInAt = lastLoggedInAt; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_login.created_at + * + * @return the value of gsync_player_login.created_at + * + * @mbg.generated + */ + @Nonnull + public LocalDateTime getCreatedAt() { + return createdAt; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_login.created_at + * + * @param createdAt + * the value for gsync_player_login.created_at + * + * @mbg.generated + */ + public void setCreatedAt(@Nonnull LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_login.updated_at + * + * @return the value of gsync_player_login.updated_at + * + * @mbg.generated + */ + @Nonnull + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_login.updated_at + * + * @param updatedAt + * the value for gsync_player_login.updated_at + * + * @mbg.generated + */ + public void setUpdatedAt(@Nonnull LocalDateTime updatedAt) { + this.updatedAt = updatedAt; + } +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerLoginExample.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerLoginExample.java new file mode 100644 index 0000000..d300139 --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerLoginExample.java @@ -0,0 +1,612 @@ +package net.averak.gsync.adapter.dao.dto.base; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +public class PlayerLoginExample { + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player_login + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player_login + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player_login + * + * @mbg.generated + */ + protected List oredCriteria; + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public PlayerLoginExample() { + oredCriteria = new ArrayList<>(); + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player_login + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andPlayerIdIsNull() { + addCriterion("`player_id` is null"); + return (Criteria) this; + } + + public Criteria andPlayerIdIsNotNull() { + addCriterion("`player_id` is not null"); + return (Criteria) this; + } + + public Criteria andPlayerIdEqualTo(String value) { + addCriterion("`player_id` =", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotEqualTo(String value) { + addCriterion("`player_id` <>", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdGreaterThan(String value) { + addCriterion("`player_id` >", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdGreaterThanOrEqualTo(String value) { + addCriterion("`player_id` >=", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLessThan(String value) { + addCriterion("`player_id` <", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLessThanOrEqualTo(String value) { + addCriterion("`player_id` <=", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLike(String value) { + addCriterion("`player_id` like", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotLike(String value) { + addCriterion("`player_id` not like", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdIn(List values) { + addCriterion("`player_id` in", values, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotIn(List values) { + addCriterion("`player_id` not in", values, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdBetween(String value1, String value2) { + addCriterion("`player_id` between", value1, value2, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotBetween(String value1, String value2) { + addCriterion("`player_id` not between", value1, value2, "playerId"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysIsNull() { + addCriterion("`total_login_days` is null"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysIsNotNull() { + addCriterion("`total_login_days` is not null"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysEqualTo(Long value) { + addCriterion("`total_login_days` =", value, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysNotEqualTo(Long value) { + addCriterion("`total_login_days` <>", value, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysGreaterThan(Long value) { + addCriterion("`total_login_days` >", value, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysGreaterThanOrEqualTo(Long value) { + addCriterion("`total_login_days` >=", value, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysLessThan(Long value) { + addCriterion("`total_login_days` <", value, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysLessThanOrEqualTo(Long value) { + addCriterion("`total_login_days` <=", value, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysIn(List values) { + addCriterion("`total_login_days` in", values, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysNotIn(List values) { + addCriterion("`total_login_days` not in", values, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysBetween(Long value1, Long value2) { + addCriterion("`total_login_days` between", value1, value2, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andTotalLoginDaysNotBetween(Long value1, Long value2) { + addCriterion("`total_login_days` not between", value1, value2, "totalLoginDays"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtIsNull() { + addCriterion("`last_logged_in_at` is null"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtIsNotNull() { + addCriterion("`last_logged_in_at` is not null"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtEqualTo(LocalDateTime value) { + addCriterion("`last_logged_in_at` =", value, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtNotEqualTo(LocalDateTime value) { + addCriterion("`last_logged_in_at` <>", value, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtGreaterThan(LocalDateTime value) { + addCriterion("`last_logged_in_at` >", value, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`last_logged_in_at` >=", value, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtLessThan(LocalDateTime value) { + addCriterion("`last_logged_in_at` <", value, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`last_logged_in_at` <=", value, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtIn(List values) { + addCriterion("`last_logged_in_at` in", values, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtNotIn(List values) { + addCriterion("`last_logged_in_at` not in", values, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`last_logged_in_at` between", value1, value2, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andLastLoggedInAtNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`last_logged_in_at` not between", value1, value2, "lastLoggedInAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("`created_at` is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("`created_at` is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(LocalDateTime value) { + addCriterion("`created_at` =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(LocalDateTime value) { + addCriterion("`created_at` <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(LocalDateTime value) { + addCriterion("`created_at` >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`created_at` >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(LocalDateTime value) { + addCriterion("`created_at` <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`created_at` <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("`created_at` in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("`created_at` not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`created_at` between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`created_at` not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("`updated_at` is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("`updated_at` is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(LocalDateTime value) { + addCriterion("`updated_at` =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(LocalDateTime value) { + addCriterion("`updated_at` <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(LocalDateTime value) { + addCriterion("`updated_at` >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`updated_at` >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(LocalDateTime value) { + addCriterion("`updated_at` <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`updated_at` <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("`updated_at` in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("`updated_at` not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`updated_at` between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`updated_at` not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player_login + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player_login + * + * @mbg.generated + */ + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerProfileDto.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerProfileDto.java new file mode 100644 index 0000000..289dd2c --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerProfileDto.java @@ -0,0 +1,207 @@ +package net.averak.gsync.adapter.dao.dto.base; + +import java.time.LocalDateTime; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class PlayerProfileDto { + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_profile.player_id + * + * @mbg.generated + */ + private String playerId; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_profile.nickname + * + * @mbg.generated + */ + private String nickname; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_profile.icon_id + * + * @mbg.generated + */ + private String iconId; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_profile.created_at + * + * @mbg.generated + */ + private LocalDateTime createdAt; + + /** + * + * This field was generated by MyBatis Generator. This field corresponds to the + * database column gsync_player_profile.updated_at + * + * @mbg.generated + */ + private LocalDateTime updatedAt; + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public PlayerProfileDto(@Nonnull String playerId, @Nonnull String nickname, @Nonnull String iconId, + @Nonnull LocalDateTime createdAt, @Nonnull LocalDateTime updatedAt) { + this.playerId = playerId; + this.nickname = nickname; + this.iconId = iconId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public PlayerProfileDto() { + super(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_profile.player_id + * + * @return the value of gsync_player_profile.player_id + * + * @mbg.generated + */ + @Nonnull + public String getPlayerId() { + return playerId; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_profile.player_id + * + * @param playerId + * the value for gsync_player_profile.player_id + * + * @mbg.generated + */ + public void setPlayerId(@Nonnull String playerId) { + this.playerId = playerId; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_profile.nickname + * + * @return the value of gsync_player_profile.nickname + * + * @mbg.generated + */ + @Nonnull + public String getNickname() { + return nickname; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_profile.nickname + * + * @param nickname + * the value for gsync_player_profile.nickname + * + * @mbg.generated + */ + public void setNickname(@Nonnull String nickname) { + this.nickname = nickname; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_profile.icon_id + * + * @return the value of gsync_player_profile.icon_id + * + * @mbg.generated + */ + @Nonnull + public String getIconId() { + return iconId; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_profile.icon_id + * + * @param iconId + * the value for gsync_player_profile.icon_id + * + * @mbg.generated + */ + public void setIconId(@Nonnull String iconId) { + this.iconId = iconId; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_profile.created_at + * + * @return the value of gsync_player_profile.created_at + * + * @mbg.generated + */ + @Nonnull + public LocalDateTime getCreatedAt() { + return createdAt; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_profile.created_at + * + * @param createdAt + * the value for gsync_player_profile.created_at + * + * @mbg.generated + */ + public void setCreatedAt(@Nonnull LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + /** + * This method was generated by MyBatis Generator. This method returns the value + * of the database column gsync_player_profile.updated_at + * + * @return the value of gsync_player_profile.updated_at + * + * @mbg.generated + */ + @Nonnull + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of + * the database column gsync_player_profile.updated_at + * + * @param updatedAt + * the value for gsync_player_profile.updated_at + * + * @mbg.generated + */ + public void setUpdatedAt(@Nonnull LocalDateTime updatedAt) { + this.updatedAt = updatedAt; + } +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerProfileExample.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerProfileExample.java new file mode 100644 index 0000000..4dd86cb --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/base/PlayerProfileExample.java @@ -0,0 +1,632 @@ +package net.averak.gsync.adapter.dao.dto.base; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +public class PlayerProfileExample { + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player_profile + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player_profile + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. This field corresponds to the + * database table gsync_player_profile + * + * @mbg.generated + */ + protected List oredCriteria; + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public PlayerProfileExample() { + oredCriteria = new ArrayList<>(); + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player_profile + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andPlayerIdIsNull() { + addCriterion("`player_id` is null"); + return (Criteria) this; + } + + public Criteria andPlayerIdIsNotNull() { + addCriterion("`player_id` is not null"); + return (Criteria) this; + } + + public Criteria andPlayerIdEqualTo(String value) { + addCriterion("`player_id` =", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotEqualTo(String value) { + addCriterion("`player_id` <>", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdGreaterThan(String value) { + addCriterion("`player_id` >", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdGreaterThanOrEqualTo(String value) { + addCriterion("`player_id` >=", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLessThan(String value) { + addCriterion("`player_id` <", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLessThanOrEqualTo(String value) { + addCriterion("`player_id` <=", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdLike(String value) { + addCriterion("`player_id` like", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotLike(String value) { + addCriterion("`player_id` not like", value, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdIn(List values) { + addCriterion("`player_id` in", values, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotIn(List values) { + addCriterion("`player_id` not in", values, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdBetween(String value1, String value2) { + addCriterion("`player_id` between", value1, value2, "playerId"); + return (Criteria) this; + } + + public Criteria andPlayerIdNotBetween(String value1, String value2) { + addCriterion("`player_id` not between", value1, value2, "playerId"); + return (Criteria) this; + } + + public Criteria andNicknameIsNull() { + addCriterion("`nickname` is null"); + return (Criteria) this; + } + + public Criteria andNicknameIsNotNull() { + addCriterion("`nickname` is not null"); + return (Criteria) this; + } + + public Criteria andNicknameEqualTo(String value) { + addCriterion("`nickname` =", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameNotEqualTo(String value) { + addCriterion("`nickname` <>", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameGreaterThan(String value) { + addCriterion("`nickname` >", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameGreaterThanOrEqualTo(String value) { + addCriterion("`nickname` >=", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameLessThan(String value) { + addCriterion("`nickname` <", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameLessThanOrEqualTo(String value) { + addCriterion("`nickname` <=", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameLike(String value) { + addCriterion("`nickname` like", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameNotLike(String value) { + addCriterion("`nickname` not like", value, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameIn(List values) { + addCriterion("`nickname` in", values, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameNotIn(List values) { + addCriterion("`nickname` not in", values, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameBetween(String value1, String value2) { + addCriterion("`nickname` between", value1, value2, "nickname"); + return (Criteria) this; + } + + public Criteria andNicknameNotBetween(String value1, String value2) { + addCriterion("`nickname` not between", value1, value2, "nickname"); + return (Criteria) this; + } + + public Criteria andIconIdIsNull() { + addCriterion("`icon_id` is null"); + return (Criteria) this; + } + + public Criteria andIconIdIsNotNull() { + addCriterion("`icon_id` is not null"); + return (Criteria) this; + } + + public Criteria andIconIdEqualTo(String value) { + addCriterion("`icon_id` =", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdNotEqualTo(String value) { + addCriterion("`icon_id` <>", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdGreaterThan(String value) { + addCriterion("`icon_id` >", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdGreaterThanOrEqualTo(String value) { + addCriterion("`icon_id` >=", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdLessThan(String value) { + addCriterion("`icon_id` <", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdLessThanOrEqualTo(String value) { + addCriterion("`icon_id` <=", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdLike(String value) { + addCriterion("`icon_id` like", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdNotLike(String value) { + addCriterion("`icon_id` not like", value, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdIn(List values) { + addCriterion("`icon_id` in", values, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdNotIn(List values) { + addCriterion("`icon_id` not in", values, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdBetween(String value1, String value2) { + addCriterion("`icon_id` between", value1, value2, "iconId"); + return (Criteria) this; + } + + public Criteria andIconIdNotBetween(String value1, String value2) { + addCriterion("`icon_id` not between", value1, value2, "iconId"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("`created_at` is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("`created_at` is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(LocalDateTime value) { + addCriterion("`created_at` =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(LocalDateTime value) { + addCriterion("`created_at` <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(LocalDateTime value) { + addCriterion("`created_at` >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`created_at` >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(LocalDateTime value) { + addCriterion("`created_at` <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`created_at` <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("`created_at` in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("`created_at` not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`created_at` between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`created_at` not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("`updated_at` is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("`updated_at` is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(LocalDateTime value) { + addCriterion("`updated_at` =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(LocalDateTime value) { + addCriterion("`updated_at` <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(LocalDateTime value) { + addCriterion("`updated_at` >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`updated_at` >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(LocalDateTime value) { + addCriterion("`updated_at` <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`updated_at` <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("`updated_at` in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("`updated_at` not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`updated_at` between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`updated_at` not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player_profile + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. This class corresponds to the + * database table gsync_player_profile + * + * @mbg.generated + */ + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/extend/PlayerILDto.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/extend/PlayerILDto.java new file mode 100644 index 0000000..298c081 --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/dto/extend/PlayerILDto.java @@ -0,0 +1,43 @@ +package net.averak.gsync.adapter.dao.dto.extend; + +import net.averak.gsync.adapter.dao.dto.base.PlayerDto; +import net.averak.gsync.adapter.dao.dto.base.PlayerLoginDto; +import net.averak.gsync.adapter.dao.dto.base.PlayerProfileDto; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.time.LocalDateTime; + +@SuppressWarnings("NotNullFieldNotInitialized") +public class PlayerILDto extends PlayerDto { + + @Nonnull + PlayerProfileDto playerProfile; + + @Nullable + PlayerLoginDto playerLogin; + + public PlayerILDto(@NotNull String playerId, @NotNull String friendId, @NotNull Boolean isBanned, + @NotNull LocalDateTime createdAt, @NotNull LocalDateTime updatedAt) { + super(playerId, friendId, isBanned, createdAt, updatedAt); + } + + @Nonnull + public PlayerProfileDto getPlayerProfile() { + return playerProfile; + } + + public void setPlayerProfile(@Nonnull PlayerProfileDto playerProfile) { + this.playerProfile = playerProfile; + } + + @Nullable + public PlayerLoginDto getPlayerLogin() { + return playerLogin; + } + + public void setPlayerLogin(@Nullable PlayerLoginDto playerLogin) { + this.playerLogin = playerLogin; + } +} diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/EchoBaseMapper.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/EchoBaseMapper.java index b0537a6..64cce12 100644 --- a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/EchoBaseMapper.java +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/EchoBaseMapper.java @@ -1,8 +1,8 @@ package net.averak.gsync.adapter.dao.mapper.base; import java.util.List; -import net.averak.gsync.adapter.dao.entity.base.EchoEntity; -import net.averak.gsync.adapter.dao.entity.base.EchoExample; +import net.averak.gsync.adapter.dao.dto.base.EchoDto; +import net.averak.gsync.adapter.dao.dto.base.EchoExample; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.session.RowBounds; @@ -39,7 +39,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - int insert(EchoEntity row); + int insert(EchoDto row); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -47,7 +47,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - int insertSelective(EchoEntity row); + int insertSelective(EchoDto row); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -55,7 +55,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - List selectByExampleWithRowbounds(EchoExample example, RowBounds rowBounds); + List selectByExampleWithRowbounds(EchoExample example, RowBounds rowBounds); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -63,7 +63,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - List selectByExample(EchoExample example); + List selectByExample(EchoExample example); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -71,7 +71,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - EchoEntity selectByPrimaryKey(String echoId); + EchoDto selectByPrimaryKey(String echoId); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -79,7 +79,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - int updateByExampleSelective(@Param("row") EchoEntity row, @Param("example") EchoExample example); + int updateByExampleSelective(@Param("row") EchoDto row, @Param("example") EchoExample example); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -87,7 +87,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - int updateByExample(@Param("row") EchoEntity row, @Param("example") EchoExample example); + int updateByExample(@Param("row") EchoDto row, @Param("example") EchoExample example); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -95,7 +95,7 @@ public interface EchoBaseMapper { * * @mbg.generated */ - int updateByPrimaryKeySelective(EchoEntity row); + int updateByPrimaryKeySelective(EchoDto row); /** * This method was generated by MyBatis Generator. This method corresponds to @@ -103,5 +103,5 @@ public interface EchoBaseMapper { * * @mbg.generated */ - int updateByPrimaryKey(EchoEntity row); + int updateByPrimaryKey(EchoDto row); } \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerBaseMapper.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerBaseMapper.java new file mode 100644 index 0000000..5433c6b --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerBaseMapper.java @@ -0,0 +1,107 @@ +package net.averak.gsync.adapter.dao.mapper.base; + +import java.util.List; +import net.averak.gsync.adapter.dao.dto.base.PlayerDto; +import net.averak.gsync.adapter.dao.dto.base.PlayerExample; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.session.RowBounds; + +@Mapper +public interface PlayerBaseMapper { + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + long countByExample(PlayerExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int deleteByExample(PlayerExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int deleteByPrimaryKey(String playerId); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int insert(PlayerDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int insertSelective(PlayerDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + List selectByExampleWithRowbounds(PlayerExample example, RowBounds rowBounds); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + List selectByExample(PlayerExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + PlayerDto selectByPrimaryKey(String playerId); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("row") PlayerDto row, @Param("example") PlayerExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int updateByExample(@Param("row") PlayerDto row, @Param("example") PlayerExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(PlayerDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player + * + * @mbg.generated + */ + int updateByPrimaryKey(PlayerDto row); +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerLoginBaseMapper.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerLoginBaseMapper.java new file mode 100644 index 0000000..343e973 --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerLoginBaseMapper.java @@ -0,0 +1,107 @@ +package net.averak.gsync.adapter.dao.mapper.base; + +import java.util.List; +import net.averak.gsync.adapter.dao.dto.base.PlayerLoginDto; +import net.averak.gsync.adapter.dao.dto.base.PlayerLoginExample; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.session.RowBounds; + +@Mapper +public interface PlayerLoginBaseMapper { + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + long countByExample(PlayerLoginExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int deleteByExample(PlayerLoginExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int deleteByPrimaryKey(String playerId); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int insert(PlayerLoginDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int insertSelective(PlayerLoginDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + List selectByExampleWithRowbounds(PlayerLoginExample example, RowBounds rowBounds); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + List selectByExample(PlayerLoginExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + PlayerLoginDto selectByPrimaryKey(String playerId); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("row") PlayerLoginDto row, @Param("example") PlayerLoginExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int updateByExample(@Param("row") PlayerLoginDto row, @Param("example") PlayerLoginExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(PlayerLoginDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_login + * + * @mbg.generated + */ + int updateByPrimaryKey(PlayerLoginDto row); +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerProfileBaseMapper.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerProfileBaseMapper.java new file mode 100644 index 0000000..81d1a48 --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/base/PlayerProfileBaseMapper.java @@ -0,0 +1,107 @@ +package net.averak.gsync.adapter.dao.mapper.base; + +import java.util.List; +import net.averak.gsync.adapter.dao.dto.base.PlayerProfileDto; +import net.averak.gsync.adapter.dao.dto.base.PlayerProfileExample; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.session.RowBounds; + +@Mapper +public interface PlayerProfileBaseMapper { + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + long countByExample(PlayerProfileExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int deleteByExample(PlayerProfileExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int deleteByPrimaryKey(String playerId); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int insert(PlayerProfileDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int insertSelective(PlayerProfileDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + List selectByExampleWithRowbounds(PlayerProfileExample example, RowBounds rowBounds); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + List selectByExample(PlayerProfileExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + PlayerProfileDto selectByPrimaryKey(String playerId); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("row") PlayerProfileDto row, @Param("example") PlayerProfileExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int updateByExample(@Param("row") PlayerProfileDto row, @Param("example") PlayerProfileExample example); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(PlayerProfileDto row); + + /** + * This method was generated by MyBatis Generator. This method corresponds to + * the database table gsync_player_profile + * + * @mbg.generated + */ + int updateByPrimaryKey(PlayerProfileDto row); +} \ No newline at end of file diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/extend/EchoMapper.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/extend/EchoMapper.java deleted file mode 100644 index 2854bdd..0000000 --- a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/extend/EchoMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.averak.gsync.adapter.dao.mapper.extend; - -import net.averak.gsync.adapter.dao.mapper.base.EchoBaseMapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface EchoMapper extends EchoBaseMapper { - -} diff --git a/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/extend/PlayerMapper.java b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/extend/PlayerMapper.java new file mode 100644 index 0000000..a17a03d --- /dev/null +++ b/app/adapter/src/main/java/net/averak/gsync/adapter/dao/mapper/extend/PlayerMapper.java @@ -0,0 +1,14 @@ +package net.averak.gsync.adapter.dao.mapper.extend; + +import net.averak.gsync.adapter.dao.dto.extend.PlayerILDto; +import net.averak.gsync.adapter.dao.mapper.base.PlayerBaseMapper; +import org.apache.ibatis.annotations.Mapper; + +import javax.annotation.Nullable; + +@Mapper +public interface PlayerMapper extends PlayerBaseMapper { + + @Nullable + PlayerILDto selectByPlayerId(String playerId); +} diff --git a/app/adapter/src/main/kotlin/net/averak/gsync/adapter/repository/EchoRepository.kt b/app/adapter/src/main/kotlin/net/averak/gsync/adapter/repository/EchoRepository.kt index 01c40df..7d5973a 100644 --- a/app/adapter/src/main/kotlin/net/averak/gsync/adapter/repository/EchoRepository.kt +++ b/app/adapter/src/main/kotlin/net/averak/gsync/adapter/repository/EchoRepository.kt @@ -1,7 +1,7 @@ package net.averak.gsync.adapter.repository -import net.averak.gsync.adapter.dao.entity.base.EchoEntity -import net.averak.gsync.adapter.dao.mapper.extend.EchoMapper +import net.averak.gsync.adapter.dao.dto.base.EchoDto +import net.averak.gsync.adapter.dao.mapper.base.EchoBaseMapper import net.averak.gsync.core.game_context.GameContext import net.averak.gsync.domain.model.Echo import net.averak.gsync.domain.repository.IEchoRepository @@ -10,14 +10,14 @@ import java.util.* @Repository open class EchoRepository( - private val echoMapper: EchoMapper, + private val echoMapper: EchoBaseMapper, ) : IEchoRepository { override fun save(gctx: GameContext, echo: Echo) { - val entity = echoMapper.selectByPrimaryKey(echo.id.toString()) - if (entity == null) { + val dto = echoMapper.selectByPrimaryKey(echo.id.toString()) + if (dto == null) { echoMapper.insert( - EchoEntity( + EchoDto( echo.id.toString(), echo.message, echo.timestamp, @@ -26,19 +26,24 @@ open class EchoRepository( ), ) } else { - entity.message = echo.message - entity.timestamp = echo.timestamp - entity.updatedAt = gctx.currentTime - echoMapper.updateByPrimaryKey(entity) + echoMapper.updateByPrimaryKey( + EchoDto( + echo.id.toString(), + echo.message, + echo.timestamp, + dto.createdAt, + gctx.currentTime, + ), + ) } } override fun findByID(gctx: GameContext, id: UUID): Echo? { return echoMapper.selectByPrimaryKey(id.toString())?.let { Echo( - UUID.fromString(it.echoId), - it.message, - it.timestamp, + id = UUID.fromString(it.echoId), + message = it.message, + timestamp = it.timestamp, ) } } diff --git a/app/adapter/src/main/kotlin/net/averak/gsync/adapter/repository/PlayerRepository.kt b/app/adapter/src/main/kotlin/net/averak/gsync/adapter/repository/PlayerRepository.kt new file mode 100644 index 0000000..a8a3c5b --- /dev/null +++ b/app/adapter/src/main/kotlin/net/averak/gsync/adapter/repository/PlayerRepository.kt @@ -0,0 +1,122 @@ +package net.averak.gsync.adapter.repository + +import net.averak.gsync.adapter.dao.dto.base.PlayerDto +import net.averak.gsync.adapter.dao.dto.base.PlayerLoginDto +import net.averak.gsync.adapter.dao.dto.base.PlayerProfileDto +import net.averak.gsync.adapter.dao.mapper.base.PlayerLoginBaseMapper +import net.averak.gsync.adapter.dao.mapper.base.PlayerProfileBaseMapper +import net.averak.gsync.adapter.dao.mapper.extend.PlayerMapper +import net.averak.gsync.core.game_context.GameContext +import net.averak.gsync.domain.model.Player +import net.averak.gsync.domain.model.PlayerLogin +import net.averak.gsync.domain.model.PlayerProfile +import net.averak.gsync.domain.repository.IPlayerRepository +import org.springframework.stereotype.Repository +import java.util.* + +@Repository +open class PlayerRepository( + private val playerMapper: PlayerMapper, + private val playerProfileMapper: PlayerProfileBaseMapper, + private val playerLoginMapper: PlayerLoginBaseMapper, +) : IPlayerRepository { + + override fun findByID(gctx: GameContext, id: UUID): Player? { + val dto = playerMapper.selectByPlayerId(id.toString()) + return if (dto == null) { + null + } else { + val loginDto = dto.playerLogin + Player( + id = UUID.fromString(dto.playerId), + friendID = UUID.fromString(dto.friendId), + isBanned = dto.isBanned, + profile = PlayerProfile( + nickname = dto.playerProfile.nickname, + iconID = dto.playerProfile.iconId, + ), + login = loginDto?.let { + PlayerLogin( + totalLoginDays = loginDto.totalLoginDays.toInt(), + lastLoggedInAt = loginDto.lastLoggedInAt, + ) + }, + ) + } + } + + override fun save(gctx: GameContext, player: Player) { + // クエリ数が多いので、プロフィールとログイン履歴は別モデルに切り出した方が良いかもしれない + val dto = playerMapper.selectByPrimaryKey(player.id.toString()) + if (dto == null) { + playerMapper.insert( + PlayerDto( + player.id.toString(), + player.friendID.toString(), + player.isBanned, + gctx.currentTime, + gctx.currentTime, + ), + ) + } else { + playerMapper.updateByPrimaryKey( + PlayerDto( + player.id.toString(), + player.friendID.toString(), + player.isBanned, + dto.createdAt, + gctx.currentTime, + ), + ) + } + + val profileDto = playerProfileMapper.selectByPrimaryKey(player.id.toString()) + if (profileDto == null) { + playerProfileMapper.insert( + PlayerProfileDto( + player.id.toString(), + player.profile.nickname, + player.profile.iconID, + gctx.currentTime, + gctx.currentTime, + ), + ) + } else { + playerProfileMapper.updateByPrimaryKey( + PlayerProfileDto( + player.id.toString(), + player.profile.nickname, + player.profile.iconID, + profileDto.createdAt, + gctx.currentTime, + ), + ) + } + + // player.login が null の場合はログイン履歴を削除するのが適切な永続化の振る舞いだが、 + // ログイン履歴を削除するようなユースケースはない & プレイヤーには見れない情報であり多少の誤差は許容されるため、削除処理はスキップする (実装が面倒なのもある) + val login = player.login ?: return + val loginDto = playerLoginMapper.selectByPrimaryKey(player.id.toString()) + if (loginDto == null) { + playerLoginMapper.insert( + PlayerLoginDto( + player.id.toString(), + login.totalLoginDays.toLong(), + login.lastLoggedInAt, + gctx.currentTime, + gctx.currentTime, + ), + ) + } else { + playerLoginMapper.updateByPrimaryKey( + PlayerLoginDto( + player.id.toString(), + login.totalLoginDays.toLong(), + login.lastLoggedInAt, + loginDto.createdAt, + gctx.currentTime, + ), + ) + } + } +} diff --git a/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/AbstractController_IT.groovy b/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/AbstractController_IT.groovy index 561af70..d3c7a0c 100644 --- a/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/AbstractController_IT.groovy +++ b/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/AbstractController_IT.groovy @@ -1,8 +1,11 @@ package net.averak.gsync.adapter.handler.rest +import net.averak.gsync.core.daterange.Dateline import net.averak.gsync.core.exception.GsyncException +import net.averak.gsync.core.game_context.GameContext import net.averak.gsync.infrastructure.json.JsonUtils import net.averak.gsync.testkit.AbstractDatabaseSpec +import net.averak.gsync.testkit.Faker import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.HttpStatus import org.springframework.http.MediaType @@ -13,6 +16,9 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders import org.springframework.test.web.servlet.setup.MockMvcBuilders import org.springframework.util.MultiValueMap import org.springframework.web.context.WebApplicationContext +import spock.lang.Shared + +import java.time.LocalDateTime abstract class AbstractController_IT extends AbstractDatabaseSpec { @@ -21,6 +27,9 @@ abstract class AbstractController_IT extends AbstractDatabaseSpec { @Autowired private WebApplicationContext webApplicationContext + @Shared + protected GameContext gctx + /** * GET request * @@ -156,5 +165,11 @@ abstract class AbstractController_IT extends AbstractDatabaseSpec { chain.doFilter(request, response) })) .build() + + this.gctx = new GameContext( + Faker.uuidv4(), + Dateline.DEFAULT, + LocalDateTime.now(), + ) } } diff --git a/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/HealthCheckController_IT.groovy b/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/HealthCheckController_IT.groovy index b33e064..e11272a 100644 --- a/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/HealthCheckController_IT.groovy +++ b/app/adapter/src/test/groovy/net/averak/gsync/adapter/handler/rest/HealthCheckController_IT.groovy @@ -3,8 +3,6 @@ package net.averak.gsync.adapter.handler.rest import net.averak.gsync.testkit.Assert import org.springframework.http.HttpStatus -import java.time.LocalDateTime - class HealthCheckController_IT extends AbstractController_IT { // API PATH @@ -20,7 +18,7 @@ class HealthCheckController_IT extends AbstractController_IT { with(sql.rows("SELECT * FROM gsync_echo")) { it.size() == 1 it[0].message == "Health Check" - Assert.timestampIs(it[0].timestamp, LocalDateTime.now()) + Assert.timestampIs(it[0].timestamp, this.gctx.currentTime) } } } diff --git a/app/adapter/src/test/groovy/net/averak/gsync/adapter/repository/EchoRepository_UT.groovy b/app/adapter/src/test/groovy/net/averak/gsync/adapter/repository/EchoRepository_UT.groovy index 31fa8cf..83e2c09 100644 --- a/app/adapter/src/test/groovy/net/averak/gsync/adapter/repository/EchoRepository_UT.groovy +++ b/app/adapter/src/test/groovy/net/averak/gsync/adapter/repository/EchoRepository_UT.groovy @@ -1,6 +1,6 @@ package net.averak.gsync.adapter.repository -import net.averak.gsync.adapter.dao.entity.base.EchoEntity +import net.averak.gsync.adapter.dao.dto.base.EchoDto import net.averak.gsync.core.game_context.GameContext import net.averak.gsync.domain.model.Echo import net.averak.gsync.testkit.Assert @@ -36,9 +36,9 @@ class EchoRepository_UT extends AbstractRepository_UT { def "save: PKが存在する場合は更新される"() { given: - final entity = Fixture.setup(Faker.fake(EchoEntity)) + final dto = Fixture.setup(Faker.fake(EchoDto)) final echo = new Echo( - UUID.fromString(entity.echoId), + UUID.fromString(dto.echoId), Faker.alphanumeric(), LocalDateTime.now(), ) @@ -56,14 +56,14 @@ class EchoRepository_UT extends AbstractRepository_UT { def "findByID: idから検索できる"() { given: - final entity = new EchoEntity( + final dto = new EchoDto( Faker.uuidv5("e1").toString(), "hello", now, now, now, ) - Fixture.setup(entity) + Fixture.setup(dto) when: final result = this.sut.findByID(Faker.fake(GameContext), id) diff --git a/app/adapter/src/test/groovy/net/averak/gsync/adapter/repository/PlayerRepository_UT.groovy b/app/adapter/src/test/groovy/net/averak/gsync/adapter/repository/PlayerRepository_UT.groovy new file mode 100644 index 0000000..5fc63c8 --- /dev/null +++ b/app/adapter/src/test/groovy/net/averak/gsync/adapter/repository/PlayerRepository_UT.groovy @@ -0,0 +1,215 @@ +package net.averak.gsync.adapter.repository + +import net.averak.gsync.adapter.dao.dto.base.PlayerDto +import net.averak.gsync.adapter.dao.dto.base.PlayerLoginDto +import net.averak.gsync.adapter.dao.dto.base.PlayerProfileDto +import net.averak.gsync.core.game_context.GameContext +import net.averak.gsync.domain.model.Player +import net.averak.gsync.domain.model.PlayerLogin +import net.averak.gsync.domain.model.PlayerProfile +import net.averak.gsync.testkit.Assert +import net.averak.gsync.testkit.Faker +import net.averak.gsync.testkit.Fixture +import org.springframework.beans.factory.annotation.Autowired +import spock.lang.Shared + +import java.time.LocalDateTime + +class PlayerRepository_UT extends AbstractRepository_UT { + + @Autowired + PlayerRepository sut + + @Shared + LocalDateTime now = LocalDateTime.now() + + def "findByID: idから検索できる"() { + given: + Fixture.setup(Faker.fake(PlayerDto, [ + playerId: Faker.uuidv5("p1").toString(), + ])) + Fixture.setup(Faker.fake(PlayerProfileDto, [ + playerId: Faker.uuidv5("p1").toString(), + ])) + + testcase.given() + + when: + final result = this.sut.findByID(Faker.fake(GameContext), testcase.when.id) + + then: + testcase.then(result) + + where: + testcase << [ + [ + name : "ログイン情報が存在する場合、ログイン情報を取得できる", + given: () -> { + Fixture.setup(Faker.fake(PlayerLoginDto, [ + playerId: Faker.uuidv5("p1").toString(), + ])) + }, + when : [ + id: Faker.uuidv5("p1"), + ], + then : (Player p) -> { + assert p != null + assert p.id == Faker.uuidv5("p1") + assert p.profile != null + assert p.login != null + return true + }, + ], + [ + name : "ログイン情報が存在しない場合、ログイン情報は NULL になる", + given: () -> { }, + when : [ + id: Faker.uuidv5("p1"), + ], + then : (Player p) -> { + assert p != null + assert p.id == Faker.uuidv5("p1") + assert p.profile != null + assert p.login == null + return true + }, + ], + [ + name : "IDが存在しない場合、NULL が返る", + given: () -> { }, + when : [ + id: Faker.uuidv5("p2"), + ], + then : (Player p) -> { + assert p == null + return true + }, + ], + ] + } + + def "save: 保存できる"() { + given: + testcase.given() + + when: + final gctx = Faker.fake(GameContext, [currentTime: now]) + this.sut.save(gctx, testcase.when.player) + + then: + testcase.then() + + where: + testcase << [ + [ + name : "レコードが存在する場合、更新される", + given: () -> { + Fixture.setup(Faker.fake(PlayerDto, [ + playerId : Faker.uuidv5("p1").toString(), + isBanned : false, + createdAt: now.minusDays(1), + ])) + Fixture.setup(Faker.fake(PlayerProfileDto, [ + playerId : Faker.uuidv5("p1").toString(), + createdAt: now.minusDays(1), + ])) + Fixture.setup(Faker.fake(PlayerLoginDto, [ + playerId : Faker.uuidv5("p1").toString(), + createdAt: now.minusDays(1), + ])) + }, + when : [ + player: Faker.fake(Player, [ + id : Faker.uuidv5("p1"), + isBanned: true, + profile : Faker.fake(PlayerProfile, [ + nickname: "new nickname", + ]), + login : Faker.fake(PlayerLogin, [ + totalLoginDays: 100, + ]), + ]), + ], + then : () -> { + with(sql.rows("SELECT * FROM gsync_player")) { + assert it.size() == 1 + assert it[0].is_banned == true + Assert.timestampIs(it[0].created_at, now.minusDays(1)) + Assert.timestampIs(it[0].updated_at, now) + } + with(sql.rows("SELECT * FROM gsync_player_profile")) { + assert it.size() == 1 + assert it[0].nickname == "new nickname" + Assert.timestampIs(it[0].created_at, now.minusDays(1)) + Assert.timestampIs(it[0].updated_at, now) + } + with(sql.rows("SELECT * FROM gsync_player_login")) { + assert it.size() == 1 + assert it[0].total_login_days == 100 + Assert.timestampIs(it[0].created_at, now.minusDays(1)) + Assert.timestampIs(it[0].updated_at, now) + } + return true + }, + ], + [ + name : "レコードが存在しない場合、作成される", + given: () -> { }, + when : [ + player: Faker.fake(Player, [ + id: Faker.uuidv5("p1"), + ]), + ], + then : () -> { + with(sql.rows("SELECT * FROM gsync_player")) { + assert it.size() == 1 + assert it[0].player_id == Faker.uuidv5("p1").toString() + Assert.timestampIs(it[0].created_at, now) + Assert.timestampIs(it[0].updated_at, now) + } + with(sql.rows("SELECT * FROM gsync_player_profile")) { + assert it.size() == 1 + assert it[0].player_id == Faker.uuidv5("p1").toString() + Assert.timestampIs(it[0].created_at, now) + Assert.timestampIs(it[0].updated_at, now) + } + with(sql.rows("SELECT * FROM gsync_player_login")) { + assert it.size() == 1 + assert it[0].player_id == Faker.uuidv5("p1").toString() + Assert.timestampIs(it[0].created_at, now) + Assert.timestampIs(it[0].updated_at, now) + } + return true + }, + ], + [ + name : "ログイン履歴が NULL の場合はログイン履歴の作成をスキップする", + given: () -> { }, + when : [ + player: Faker.fake(Player, [ + id : Faker.uuidv5("p1"), + login: null, + ]), + ], + then : () -> { + with(sql.rows("SELECT * FROM gsync_player")) { + assert it.size() == 1 + assert it[0].player_id == Faker.uuidv5("p1").toString() + Assert.timestampIs(it[0].created_at, now) + Assert.timestampIs(it[0].updated_at, now) + } + with(sql.rows("SELECT * FROM gsync_player_profile")) { + assert it.size() == 1 + assert it[0].player_id == Faker.uuidv5("p1").toString() + Assert.timestampIs(it[0].created_at, now) + Assert.timestampIs(it[0].updated_at, now) + } + with(sql.rows("SELECT * FROM gsync_player_login")) { + assert it.size() == 0 + } + return true + }, + ], + ] + } +} diff --git a/app/core/src/test/groovy/net/averak/gsync/core/game_context/GameContext_UT.groovy b/app/core/src/test/groovy/net/averak/gsync/core/game_context/GameContext_UT.groovy index f2a62ad..b141b23 100644 --- a/app/core/src/test/groovy/net/averak/gsync/core/game_context/GameContext_UT.groovy +++ b/app/core/src/test/groovy/net/averak/gsync/core/game_context/GameContext_UT.groovy @@ -13,7 +13,6 @@ class GameContext_UT extends AbstractSpec { def "getToday: 今日の日付を取得する"() { given: final context = new GameContext( - Faker.alphanumeric(), Faker.uuidv4(), new Dateline(false, 0, 0, 0), LocalDateTime.of(2020, 1, 1, 0, 0, 0), diff --git a/app/domain/src/main/kotlin/net/averak/gsync/domain/model/Player.kt b/app/domain/src/main/kotlin/net/averak/gsync/domain/model/Player.kt new file mode 100644 index 0000000..b85a9ab --- /dev/null +++ b/app/domain/src/main/kotlin/net/averak/gsync/domain/model/Player.kt @@ -0,0 +1,22 @@ +package net.averak.gsync.domain.model + +import java.time.LocalDateTime +import java.util.* + +data class Player( + val id: UUID, + val friendID: UUID, + val isBanned: Boolean, + val profile: PlayerProfile, + var login: PlayerLogin?, +) + +data class PlayerProfile( + val nickname: String, + val iconID: String, +) + +data class PlayerLogin( + val totalLoginDays: Int, + val lastLoggedInAt: LocalDateTime, +) diff --git a/app/domain/src/main/kotlin/net/averak/gsync/domain/repository/IPlayerRepository.kt b/app/domain/src/main/kotlin/net/averak/gsync/domain/repository/IPlayerRepository.kt new file mode 100644 index 0000000..220f4be --- /dev/null +++ b/app/domain/src/main/kotlin/net/averak/gsync/domain/repository/IPlayerRepository.kt @@ -0,0 +1,12 @@ +package net.averak.gsync.domain.repository + +import net.averak.gsync.core.game_context.GameContext +import net.averak.gsync.domain.model.Player +import java.util.* + +interface IPlayerRepository { + + fun findByID(gctx: GameContext, id: UUID): Player? + + fun save(gctx: GameContext, player: Player) +} diff --git a/src/main/resources/dao/base/EchoBaseMapper.xml b/src/main/resources/dao/base/EchoBaseMapper.xml index dde3db9..736063d 100644 --- a/src/main/resources/dao/base/EchoBaseMapper.xml +++ b/src/main/resources/dao/base/EchoBaseMapper.xml @@ -1,7 +1,7 @@ - + `echo_id`, `message`, `timestamp`, `created_at`, `updated_at` - + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + `player_id`, `friend_id`, `is_banned`, `created_at`, `updated_at` + + + + + + delete from `gsync_player` + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + + delete from `gsync_player` + + + + + + + insert into `gsync_player` (`player_id`, `friend_id`, `is_banned`, + `created_at`, `updated_at`) + values (#{playerId,jdbcType=NVARCHAR}, #{friendId,jdbcType=NVARCHAR}, #{isBanned,jdbcType=BOOLEAN}, + #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}) + + + + insert into `gsync_player` + + + `player_id`, + + + `friend_id`, + + + `is_banned`, + + + `created_at`, + + + `updated_at`, + + + + + #{playerId,jdbcType=NVARCHAR}, + + + #{friendId,jdbcType=NVARCHAR}, + + + #{isBanned,jdbcType=BOOLEAN}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + + + + + update `gsync_player` + + + `player_id` = #{row.playerId,jdbcType=NVARCHAR}, + + + `friend_id` = #{row.friendId,jdbcType=NVARCHAR}, + + + `is_banned` = #{row.isBanned,jdbcType=BOOLEAN}, + + + `created_at` = #{row.createdAt,jdbcType=TIMESTAMP}, + + + `updated_at` = #{row.updatedAt,jdbcType=TIMESTAMP}, + + + + + + + + + update `gsync_player` + set `player_id` = #{row.playerId,jdbcType=NVARCHAR}, + `friend_id` = #{row.friendId,jdbcType=NVARCHAR}, + `is_banned` = #{row.isBanned,jdbcType=BOOLEAN}, + `created_at` = #{row.createdAt,jdbcType=TIMESTAMP}, + `updated_at` = #{row.updatedAt,jdbcType=TIMESTAMP} + + + + + + + update `gsync_player` + + + `friend_id` = #{friendId,jdbcType=NVARCHAR}, + + + `is_banned` = #{isBanned,jdbcType=BOOLEAN}, + + + `created_at` = #{createdAt,jdbcType=TIMESTAMP}, + + + `updated_at` = #{updatedAt,jdbcType=TIMESTAMP}, + + + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + + update `gsync_player` + set `friend_id` = #{friendId,jdbcType=NVARCHAR}, + `is_banned` = #{isBanned,jdbcType=BOOLEAN}, + `created_at` = #{createdAt,jdbcType=TIMESTAMP}, + `updated_at` = #{updatedAt,jdbcType=TIMESTAMP} + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + \ No newline at end of file diff --git a/src/main/resources/dao/base/PlayerLoginBaseMapper.xml b/src/main/resources/dao/base/PlayerLoginBaseMapper.xml new file mode 100644 index 0000000..7e2ad68 --- /dev/null +++ b/src/main/resources/dao/base/PlayerLoginBaseMapper.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + `player_id`, `total_login_days`, `last_logged_in_at`, `created_at`, `updated_at` + + + + + + delete from `gsync_player_login` + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + + delete from `gsync_player_login` + + + + + + + insert into `gsync_player_login` (`player_id`, `total_login_days`, `last_logged_in_at`, + `created_at`, `updated_at`) + values (#{playerId,jdbcType=NVARCHAR}, #{totalLoginDays,jdbcType=BIGINT}, #{lastLoggedInAt,jdbcType=TIMESTAMP}, + #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}) + + + + insert into `gsync_player_login` + + + `player_id`, + + + `total_login_days`, + + + `last_logged_in_at`, + + + `created_at`, + + + `updated_at`, + + + + + #{playerId,jdbcType=NVARCHAR}, + + + #{totalLoginDays,jdbcType=BIGINT}, + + + #{lastLoggedInAt,jdbcType=TIMESTAMP}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + + + + + update `gsync_player_login` + + + `player_id` = #{row.playerId,jdbcType=NVARCHAR}, + + + `total_login_days` = #{row.totalLoginDays,jdbcType=BIGINT}, + + + `last_logged_in_at` = #{row.lastLoggedInAt,jdbcType=TIMESTAMP}, + + + `created_at` = #{row.createdAt,jdbcType=TIMESTAMP}, + + + `updated_at` = #{row.updatedAt,jdbcType=TIMESTAMP}, + + + + + + + + + update `gsync_player_login` + set `player_id` = #{row.playerId,jdbcType=NVARCHAR}, + `total_login_days` = #{row.totalLoginDays,jdbcType=BIGINT}, + `last_logged_in_at` = #{row.lastLoggedInAt,jdbcType=TIMESTAMP}, + `created_at` = #{row.createdAt,jdbcType=TIMESTAMP}, + `updated_at` = #{row.updatedAt,jdbcType=TIMESTAMP} + + + + + + + update `gsync_player_login` + + + `total_login_days` = #{totalLoginDays,jdbcType=BIGINT}, + + + `last_logged_in_at` = #{lastLoggedInAt,jdbcType=TIMESTAMP}, + + + `created_at` = #{createdAt,jdbcType=TIMESTAMP}, + + + `updated_at` = #{updatedAt,jdbcType=TIMESTAMP}, + + + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + + update `gsync_player_login` + set `total_login_days` = #{totalLoginDays,jdbcType=BIGINT}, + `last_logged_in_at` = #{lastLoggedInAt,jdbcType=TIMESTAMP}, + `created_at` = #{createdAt,jdbcType=TIMESTAMP}, + `updated_at` = #{updatedAt,jdbcType=TIMESTAMP} + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + \ No newline at end of file diff --git a/src/main/resources/dao/base/PlayerProfileBaseMapper.xml b/src/main/resources/dao/base/PlayerProfileBaseMapper.xml new file mode 100644 index 0000000..d61c984 --- /dev/null +++ b/src/main/resources/dao/base/PlayerProfileBaseMapper.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + `player_id`, `nickname`, `icon_id`, `created_at`, `updated_at` + + + + + + delete from `gsync_player_profile` + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + + delete from `gsync_player_profile` + + + + + + + insert into `gsync_player_profile` (`player_id`, `nickname`, `icon_id`, + `created_at`, `updated_at`) + values (#{playerId,jdbcType=NVARCHAR}, #{nickname,jdbcType=NVARCHAR}, #{iconId,jdbcType=NVARCHAR}, + #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}) + + + + insert into `gsync_player_profile` + + + `player_id`, + + + `nickname`, + + + `icon_id`, + + + `created_at`, + + + `updated_at`, + + + + + #{playerId,jdbcType=NVARCHAR}, + + + #{nickname,jdbcType=NVARCHAR}, + + + #{iconId,jdbcType=NVARCHAR}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + + + + + update `gsync_player_profile` + + + `player_id` = #{row.playerId,jdbcType=NVARCHAR}, + + + `nickname` = #{row.nickname,jdbcType=NVARCHAR}, + + + `icon_id` = #{row.iconId,jdbcType=NVARCHAR}, + + + `created_at` = #{row.createdAt,jdbcType=TIMESTAMP}, + + + `updated_at` = #{row.updatedAt,jdbcType=TIMESTAMP}, + + + + + + + + + update `gsync_player_profile` + set `player_id` = #{row.playerId,jdbcType=NVARCHAR}, + `nickname` = #{row.nickname,jdbcType=NVARCHAR}, + `icon_id` = #{row.iconId,jdbcType=NVARCHAR}, + `created_at` = #{row.createdAt,jdbcType=TIMESTAMP}, + `updated_at` = #{row.updatedAt,jdbcType=TIMESTAMP} + + + + + + + update `gsync_player_profile` + + + `nickname` = #{nickname,jdbcType=NVARCHAR}, + + + `icon_id` = #{iconId,jdbcType=NVARCHAR}, + + + `created_at` = #{createdAt,jdbcType=TIMESTAMP}, + + + `updated_at` = #{updatedAt,jdbcType=TIMESTAMP}, + + + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + + update `gsync_player_profile` + set `nickname` = #{nickname,jdbcType=NVARCHAR}, + `icon_id` = #{iconId,jdbcType=NVARCHAR}, + `created_at` = #{createdAt,jdbcType=TIMESTAMP}, + `updated_at` = #{updatedAt,jdbcType=TIMESTAMP} + where `player_id` = #{playerId,jdbcType=NVARCHAR} + + + \ No newline at end of file diff --git a/src/main/resources/dao/extend/EchoMapper.xml b/src/main/resources/dao/extend/EchoMapper.xml deleted file mode 100644 index 1345e1d..0000000 --- a/src/main/resources/dao/extend/EchoMapper.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/main/resources/dao/extend/PlayerMapper.xml b/src/main/resources/dao/extend/PlayerMapper.xml new file mode 100644 index 0000000..99ac9ff --- /dev/null +++ b/src/main/resources/dao/extend/PlayerMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + diff --git a/src/main/resources/db/migration/V1_0_0_0__init_schema.sql b/src/main/resources/db/migration/V1_0_0_0__init_schema.sql index e3e7842..f5cf9a4 100644 --- a/src/main/resources/db/migration/V1_0_0_0__init_schema.sql +++ b/src/main/resources/db/migration/V1_0_0_0__init_schema.sql @@ -1,9 +1,44 @@ CREATE TABLE gsync_echo ( - echo_id STRING(36) NOT NULL, - message STRING(255) NOT NULL, - timestamp TIMESTAMP NOT NULL, + echo_id STRING(36) NOT NULL, + message STRING( MAX) NOT NULL, + timestamp TIMESTAMP NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, ) PRIMARY KEY (echo_id); -ALTER TABLE gsync_echo ADD ROW DELETION POLICY (OLDER_THAN(timestamp, INTERVAL 1 DAY)); +ALTER TABLE gsync_echo + ADD ROW DELETION POLICY (OLDER_THAN(timestamp, INTERVAL 1 DAY)); + +CREATE TABLE gsync_player +( + player_id STRING(36) NOT NULL, + friend_id STRING(36) NOT NULL, + is_banned BOOL NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, +) PRIMARY KEY (player_id); +CREATE UNIQUE INDEX gsync_player__friend_id ON gsync_player (friend_id); + +CREATE TABLE gsync_player_profile +( + player_id STRING(36) NOT NULL, + nickname STRING( MAX) NOT NULL, + icon_id STRING(36) NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, +) PRIMARY KEY (player_id), +INTERLEAVE IN PARENT gsync_player ON +DELETE +CASCADE; + +CREATE TABLE gsync_player_login +( + player_id STRING(36) NOT NULL, + total_login_days INT64 NOT NULL, + last_logged_in_at TIMESTAMP NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, +) PRIMARY KEY (player_id), +INTERLEAVE IN PARENT gsync_player ON +DELETE +CASCADE; diff --git a/src/main/resources/mybatis-generator-config.xml b/src/main/resources/mybatis-generator-config.xml index a7b6271..1316eaa 100644 --- a/src/main/resources/mybatis-generator-config.xml +++ b/src/main/resources/mybatis-generator-config.xml @@ -27,7 +27,7 @@ - diff --git a/testkit/src/main/groovy/net/averak/gsync/testkit/AbstractDatabaseSpec.groovy b/testkit/src/main/groovy/net/averak/gsync/testkit/AbstractDatabaseSpec.groovy index 28f520e..c5dfc6f 100644 --- a/testkit/src/main/groovy/net/averak/gsync/testkit/AbstractDatabaseSpec.groovy +++ b/testkit/src/main/groovy/net/averak/gsync/testkit/AbstractDatabaseSpec.groovy @@ -6,6 +6,7 @@ import net.averak.gsync.infrastructure.redis.RedisClient import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.transaction.annotation.Transactional +import spock.lang.Shared // @Transactional を付けるとテストケースがトランザクション内で実行され、テストケース実行後にロールバックされる // https://spring.pleiades.io/spring-framework/reference/testing/testcontext-framework/tx.html#testcontext-tx-enabling-transactions @@ -14,9 +15,11 @@ import org.springframework.transaction.annotation.Transactional abstract class AbstractDatabaseSpec extends AbstractSpec { @Autowired + @Shared Sql sql @Autowired + @Shared RedisClient redis @PostConstruct @@ -29,5 +32,6 @@ abstract class AbstractDatabaseSpec extends AbstractSpec { // なぜか @Transactional でロールバックされないので、仕方なく DELETE クエリを実行している sql.execute("DELETE FROM gsync_echo WHERE echo_id IS NOT NULL") + sql.execute("DELETE FROM gsync_player WHERE player_id IS NOT NULL") } } diff --git a/testkit/src/main/groovy/net/averak/gsync/testkit/Assert.groovy b/testkit/src/main/groovy/net/averak/gsync/testkit/Assert.groovy index 04fc8e8..72d9a8b 100644 --- a/testkit/src/main/groovy/net/averak/gsync/testkit/Assert.groovy +++ b/testkit/src/main/groovy/net/averak/gsync/testkit/Assert.groovy @@ -19,14 +19,8 @@ class Assert { assert expected.message == actual.message } - /** - * タイムスタンプが一致するか検証 - * - * @param approxDuration 許容する誤差 - */ - static void timestampIs(final Object actual, final LocalDateTime expected, final Duration approxDuration = Duration.ofSeconds(5)) { + static void timestampIs(final Object actual, final LocalDateTime expected, final Duration approxDuration = Duration.ofMillis(500)) { assert actual instanceof Timestamp assert ChronoUnit.MILLIS.between(actual.toLocalDateTime(), expected) <= approxDuration.toMillis() } - } diff --git a/testkit/src/main/groovy/net/averak/gsync/testkit/randomizer/EntityRandomizers.groovy b/testkit/src/main/groovy/net/averak/gsync/testkit/randomizer/EntityRandomizers.groovy index 5f34bff..eae268e 100644 --- a/testkit/src/main/groovy/net/averak/gsync/testkit/randomizer/EntityRandomizers.groovy +++ b/testkit/src/main/groovy/net/averak/gsync/testkit/randomizer/EntityRandomizers.groovy @@ -1,6 +1,9 @@ package net.averak.gsync.testkit.randomizer -import net.averak.gsync.adapter.dao.entity.base.EchoEntity +import net.averak.gsync.adapter.dao.dto.base.EchoDto +import net.averak.gsync.adapter.dao.dto.base.PlayerDto +import net.averak.gsync.adapter.dao.dto.base.PlayerLoginDto +import net.averak.gsync.adapter.dao.dto.base.PlayerProfileDto import net.averak.gsync.testkit.Faker import net.averak.gsync.testkit.IRandomizer import org.springframework.stereotype.Component @@ -8,13 +11,13 @@ import org.springframework.stereotype.Component import java.time.LocalDateTime @Component -class EchoEntityRandomizer implements IRandomizer { +class EchoDtoRandomizer implements IRandomizer { - final Class typeToGenerate = EchoEntity.class + final Class typeToGenerate = EchoDto.class @Override Object getRandomValue() { - return new EchoEntity( + return new EchoDto( Faker.uuidv4().toString(), Faker.alphanumeric(255), Faker.fake(LocalDateTime), @@ -23,3 +26,54 @@ class EchoEntityRandomizer implements IRandomizer { ) } } + +@Component +class PlayerDtoRandomizer implements IRandomizer { + + final Class typeToGenerate = PlayerDto.class + + @Override + Object getRandomValue() { + return new PlayerDto( + Faker.uuidv4().toString(), + Faker.uuidv4().toString(), + false, + Faker.fake(LocalDateTime), + Faker.fake(LocalDateTime), + ) + } +} + +@Component +class PlayerLoginDtoRandomizer implements IRandomizer { + + final Class typeToGenerate = PlayerLoginDto.class + + @Override + Object getRandomValue() { + return new PlayerLoginDto( + "", + Faker.integer(0, Integer.MAX_VALUE), + Faker.fake(LocalDateTime), + Faker.fake(LocalDateTime), + Faker.fake(LocalDateTime), + ) + } +} + +@Component +class PlayerProfileDtoRandomizer implements IRandomizer { + + final Class typeToGenerate = PlayerProfileDto.class + + @Override + Object getRandomValue() { + return new PlayerProfileDto( + "", + Faker.alphanumeric(10), + Faker.uuidv4().toString(), + Faker.fake(LocalDateTime), + Faker.fake(LocalDateTime),) + } +} + diff --git a/testkit/src/main/kotlin/net/averak/gsync/testkit/Fixture.kt b/testkit/src/main/kotlin/net/averak/gsync/testkit/Fixture.kt index 293644d..8a4380c 100644 --- a/testkit/src/main/kotlin/net/averak/gsync/testkit/Fixture.kt +++ b/testkit/src/main/kotlin/net/averak/gsync/testkit/Fixture.kt @@ -26,13 +26,13 @@ class Fixture { * テストフィクスチャをセットアップする */ @JvmStatic - fun setup(entity: T): T { - require(entity != null) { - "entity must not be null" + fun setup(dto: T): T { + require(dto != null) { + "dto must not be null" } - sql.dataSet(extractTableName(entity)).add(extractColumns(entity)) - return entity + sql.dataSet(extractTableName(dto)).add(extractColumns(dto)) + return dto } /** @@ -44,18 +44,18 @@ class Fixture { return entities.toList() } - private fun extractTableName(entity: Any): String { - val tableName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entity.javaClass.simpleName).replace("_entity", "") + private fun extractTableName(dto: Any): String { + val tableName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.javaClass.simpleName).replace("_dto", "") return "`gsync_$tableName`" } - private fun extractColumns(entity: Any): Map { + private fun extractColumns(dto: Any): Map { val result = LinkedHashMap() - entity.javaClass.declaredFields.forEach { + dto.javaClass.declaredFields.forEach { val columnName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, it.name) it.isAccessible = true - when (val value = it[entity]) { + when (val value = it[dto]) { is LocalDateTime -> { result["`$columnName`"] = Timestamp.valueOf(value) } diff --git a/testkit/src/main/kotlin/net/averak/gsync/testkit/TestConfig.kt b/testkit/src/main/kotlin/net/averak/gsync/testkit/TestConfig.kt index 7a11ff1..0bae3ef 100644 --- a/testkit/src/main/kotlin/net/averak/gsync/testkit/TestConfig.kt +++ b/testkit/src/main/kotlin/net/averak/gsync/testkit/TestConfig.kt @@ -3,7 +3,6 @@ package net.averak.gsync.testkit import groovy.sql.Sql import jakarta.annotation.PostConstruct import org.springframework.boot.autoconfigure.EnableAutoConfiguration -import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties import org.springframework.boot.jdbc.DataSourceBuilder import org.springframework.boot.test.context.TestConfiguration @@ -18,31 +17,12 @@ internal open class TestConfig( private val randomizers: List>, ) { - companion object { - - private var isAlreadyFlywayMigrated = false - } - @PostConstruct open fun init() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")) Faker.init(randomizers) } - @Bean - open fun flywayMigrationStrategy(): FlywayMigrationStrategy { - return FlywayMigrationStrategy { flyway -> - // テスト開始時に既存のデータベースをクリーンアップできれば十分なので、マイグレーションは一度だけ実行する - if (isAlreadyFlywayMigrated) { - return@FlywayMigrationStrategy - } - - flyway.clean() - flyway.migrate() - isAlreadyFlywayMigrated = true - } - } - @Bean open fun dataSource(properties: DataSourceProperties): DataSource { return TransactionAwareDataSourceProxy(