Skip to content

Commit 1ffb397

Browse files
committed
lets actually finish the migration...
1 parent 14b9ab8 commit 1ffb397

20 files changed

Lines changed: 159 additions & 316 deletions

realty-common/src/main/java/io/github/md5sha256/realty/api/HistoryEventType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ public enum HistoryEventType {
99
RENT,
1010
UNRENT,
1111
RENEW,
12-
LEASE_EXPIRY
12+
LEASEHOLD_EXPIRY
1313
}

realty-common/src/main/java/io/github/md5sha256/realty/database/entity/ExpiredLeaseView.java renamed to realty-common/src/main/java/io/github/md5sha256/realty/database/entity/ExpiredLeaseholdView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import java.util.UUID;
66

7-
public record ExpiredLeaseView(
8-
int leaseContractId,
7+
public record ExpiredLeaseholdView(
8+
int leaseholdContractId,
99
@NotNull UUID landlordId,
1010
@NotNull UUID tenantId,
1111
@NotNull String worldGuardRegionId,

realty-common/src/main/java/io/github/md5sha256/realty/database/entity/HistoryEntry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.time.LocalDateTime;
77
import java.util.UUID;
88

9-
public sealed interface HistoryEntry permits HistoryEntry.Freehold, HistoryEntry.Lease, HistoryEntry.Agent {
9+
public sealed interface HistoryEntry permits HistoryEntry.Freehold, HistoryEntry.Leasehold, HistoryEntry.Agent {
1010

1111
@NotNull String eventType();
1212

@@ -20,7 +20,7 @@ record Freehold(
2020
double price
2121
) implements HistoryEntry {}
2222

23-
record Lease(
23+
record Leasehold(
2424
@NotNull String eventType,
2525
@NotNull LocalDateTime eventTime,
2626
@NotNull UUID tenantId,

realty-common/src/main/java/io/github/md5sha256/realty/database/entity/LeaseContractEntity.java renamed to realty-common/src/main/java/io/github/md5sha256/realty/database/entity/LeaseholdContractEntity.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
import java.util.UUID;
88

99
/**
10-
* Internal entity record mapping to the {@code LeaseContract} DDL table.
10+
* Internal entity record mapping to the {@code LeaseholdContract} DDL table.
1111
*
12-
* @param leaseContractId Auto-increment primary key
13-
* @param landlordId UUID of the landlord (authority over the lease)
12+
* @param leaseholdContractId Auto-increment primary key
13+
* @param landlordId UUID of the landlord (authority over the leasehold)
1414
* @param tenantId UUID of the tenant, or {@code null} if the region is for rent
1515
* @param price Rental price (must be > 0)
16-
* @param durationSeconds Lease duration in seconds (must be > 0)
17-
* @param startDate When the lease started
18-
* @param endDate When the current lease period ends, or {@code null} if no tenant
16+
* @param durationSeconds Leasehold duration in seconds (must be > 0)
17+
* @param startDate When the leasehold started
18+
* @param endDate When the current leasehold period ends, or {@code null} if unknown
1919
* @param currentMaxExtensions Current extension count (nullable; must be ≤ maxExtensions when present)
2020
* @param maxExtensions Maximum allowed extensions (nullable)
2121
* @see io.github.md5sha256.realty.api.LeaseContract
2222
*/
23-
public record LeaseContractEntity(
24-
int leaseContractId,
23+
public record LeaseholdContractEntity(
24+
int leaseholdContractId,
2525
@NotNull UUID landlordId,
2626
@Nullable UUID tenantId,
2727
double price,

realty-common/src/main/java/io/github/md5sha256/realty/database/entity/LeaseHistoryEntity.java renamed to realty-common/src/main/java/io/github/md5sha256/realty/database/entity/LeaseholdHistoryEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.time.LocalDateTime;
77
import java.util.UUID;
88

9-
public record LeaseHistoryEntity(
9+
public record LeaseholdHistoryEntity(
1010
int historyId,
1111
@NotNull String worldGuardRegionId,
1212
@NotNull UUID worldId,

realty-common/src/main/java/io/github/md5sha256/realty/database/mapper/LeaseContractMapper.java

Lines changed: 0 additions & 173 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package io.github.md5sha256.realty.database.mapper;
2+
3+
import io.github.md5sha256.realty.database.entity.ExpiredLeaseholdView;
4+
import io.github.md5sha256.realty.database.entity.LeaseholdContractEntity;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
7+
8+
import java.util.List;
9+
import java.util.UUID;
10+
11+
public interface LeaseholdContractMapper {
12+
13+
int insertLeasehold(int regionId,
14+
double price,
15+
long durationSeconds,
16+
int maxRenewals,
17+
@NotNull UUID landlordId,
18+
@Nullable UUID tenantId);
19+
20+
boolean existsByRegionAndTenant(@NotNull String worldGuardRegionId,
21+
@NotNull UUID worldId,
22+
@NotNull UUID playerId);
23+
24+
@Nullable LeaseholdContractEntity selectByRegion(@NotNull String worldGuardRegionId, @NotNull UUID worldId);
25+
26+
int rentRegion(@NotNull String worldGuardRegionId,
27+
@NotNull UUID worldId,
28+
@NotNull UUID tenantId);
29+
30+
int renewLeasehold(@NotNull String worldGuardRegionId,
31+
@NotNull UUID worldId,
32+
@NotNull UUID tenantId);
33+
34+
@NotNull List<ExpiredLeaseholdView> selectExpiredLeaseholds();
35+
36+
int clearTenant(int leaseholdContractId);
37+
38+
int updateDurationByRegion(@NotNull String worldGuardRegionId,
39+
@NotNull UUID worldId,
40+
long durationSeconds);
41+
42+
int updateLandlordByRegion(@NotNull String worldGuardRegionId,
43+
@NotNull UUID worldId,
44+
@NotNull UUID landlordId);
45+
46+
int updateTenantByRegion(@NotNull String worldGuardRegionId,
47+
@NotNull UUID worldId,
48+
@Nullable UUID tenantId);
49+
50+
int updateMaxRenewalsByRegion(@NotNull String worldGuardRegionId,
51+
@NotNull UUID worldId,
52+
int maxRenewals);
53+
}

realty-common/src/main/java/io/github/md5sha256/realty/database/mapper/LeaseHistoryMapper.java renamed to realty-common/src/main/java/io/github/md5sha256/realty/database/mapper/LeaseholdHistoryMapper.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package io.github.md5sha256.realty.database.mapper;
22

3-
import io.github.md5sha256.realty.database.entity.LeaseHistoryEntity;
3+
import io.github.md5sha256.realty.database.entity.LeaseholdHistoryEntity;
44
import org.jetbrains.annotations.NotNull;
55
import org.jetbrains.annotations.Nullable;
66

77
import java.time.LocalDateTime;
88
import java.util.List;
99
import java.util.UUID;
1010

11-
public interface LeaseHistoryMapper {
11+
public interface LeaseholdHistoryMapper {
1212

1313
int insert(@NotNull String worldGuardRegionId,
1414
@NotNull UUID worldId,
@@ -19,18 +19,17 @@ int insert(@NotNull String worldGuardRegionId,
1919
@Nullable Long durationSeconds,
2020
@Nullable Integer extensionsRemaining);
2121

22-
@NotNull List<LeaseHistoryEntity> searchHistory(@NotNull String worldGuardRegionId,
23-
@NotNull UUID worldId,
24-
@Nullable String eventType,
25-
@Nullable LocalDateTime since,
26-
@Nullable UUID playerId,
27-
int limit,
28-
int offset);
22+
@NotNull List<LeaseholdHistoryEntity> searchHistory(@NotNull String worldGuardRegionId,
23+
@NotNull UUID worldId,
24+
@Nullable String eventType,
25+
@Nullable LocalDateTime since,
26+
@Nullable UUID playerId,
27+
int limit,
28+
int offset);
2929

3030
int countHistory(@NotNull String worldGuardRegionId,
3131
@NotNull UUID worldId,
3232
@Nullable String eventType,
3333
@Nullable LocalDateTime since,
3434
@Nullable UUID playerId);
35-
3635
}

realty-common/src/main/java/io/github/md5sha256/realty/database/maria/MariaDatabase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import io.github.md5sha256.realty.database.Database;
55
import io.github.md5sha256.realty.database.SqlSessionWrapper;
66
import io.github.md5sha256.realty.database.maria.mapper.MariaContractMapper;
7-
import io.github.md5sha256.realty.database.maria.mapper.MariaLeaseContractMapper;
7+
import io.github.md5sha256.realty.database.maria.mapper.MariaLeaseholdContractMapper;
88
import io.github.md5sha256.realty.database.maria.mapper.MariaRealtyRegionMapper;
9-
import io.github.md5sha256.realty.database.maria.mapper.MariaLeaseHistoryMapper;
9+
import io.github.md5sha256.realty.database.maria.mapper.MariaLeaseholdHistoryMapper;
1010
import io.github.md5sha256.realty.database.maria.mapper.MariaFreeholdContractAuctionMapper;
1111
import io.github.md5sha256.realty.database.maria.mapper.MariaFreeholdHistoryMapper;
1212
import io.github.md5sha256.realty.database.maria.mapper.MariaFreeholdContractBidMapper;
@@ -60,10 +60,10 @@ private static SqlSessionFactory buildSessionFactory(@NotNull DataSource dataSou
6060
Configuration configuration = new Configuration(environment);
6161
configuration.getTypeHandlerRegistry().register(UUID.class, JdbcType.OTHER, UUIDAsBin16Handler.class);
6262
configuration.addMapper(MariaContractMapper.class);
63-
configuration.addMapper(MariaLeaseContractMapper.class);
63+
configuration.addMapper(MariaLeaseholdContractMapper.class);
6464
configuration.addMapper(MariaRealtyRegionMapper.class);
6565
configuration.addMapper(MariaFreeholdHistoryMapper.class);
66-
configuration.addMapper(MariaLeaseHistoryMapper.class);
66+
configuration.addMapper(MariaLeaseholdHistoryMapper.class);
6767
configuration.addMapper(MariaFreeholdContractAuctionMapper.class);
6868
configuration.addMapper(MariaFreeholdContractBidMapper.class);
6969
configuration.addMapper(MariaFreeholdContractMapper.class);

realty-common/src/main/java/io/github/md5sha256/realty/database/maria/mapper/LeaseHistorySqlProvider.java renamed to realty-common/src/main/java/io/github/md5sha256/realty/database/maria/mapper/LeaseholdHistorySqlProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import java.util.Map;
66

7-
public class LeaseHistorySqlProvider {
7+
public class LeaseholdHistorySqlProvider {
88

99
public String searchHistory(Map<String, Object> params) {
1010
return new SQL() {{
1111
SELECT("historyId, worldGuardRegionId, worldId, eventType, tenantId, landlordId, price, durationSeconds, extensionsRemaining, eventTime");
12-
FROM("LeaseHistory");
12+
FROM("LeaseholdHistory");
1313
WHERE("worldGuardRegionId = #{worldGuardRegionId}");
1414
WHERE("worldId = #{worldId}");
1515
if (params.get("eventType") != null) {
@@ -30,7 +30,7 @@ public String searchHistory(Map<String, Object> params) {
3030
public String countHistory(Map<String, Object> params) {
3131
return new SQL() {{
3232
SELECT("COUNT(*)");
33-
FROM("LeaseHistory");
33+
FROM("LeaseholdHistory");
3434
WHERE("worldGuardRegionId = #{worldGuardRegionId}");
3535
WHERE("worldId = #{worldId}");
3636
if (params.get("eventType") != null) {

0 commit comments

Comments
 (0)