P02: Maven multi-module skeleton — domain, application, adapter-persistence, adapter-web, bootstrap
build / build (push) Failing after 18s
build / build (push) Failing after 18s
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent><groupId>dev.shopforge</groupId><artifactId>shopforge</artifactId><version>0.1.0-SNAPSHOT</version></parent>
|
||||
<artifactId>shopforge-adapter-persistence</artifactId>
|
||||
<name>ShopForge :: adapter-persistence</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency><groupId>dev.shopforge</groupId><artifactId>shopforge-domain</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package dev.shopforge.persistence;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
interface JpaShopRepository extends JpaRepository<ShopEntity, String> {
|
||||
Optional<ShopEntity> findBySubdomain(String subdomain);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.shopforge.persistence;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
/** DB ka naksha. Ye domain ka Shop NAHI hai — jaanbujhkar alag rakha gaya hai. */
|
||||
@Entity
|
||||
@Table(name = "shop")
|
||||
public class ShopEntity {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
private String naam;
|
||||
|
||||
@Column(unique = true)
|
||||
private String subdomain;
|
||||
private boolean active;
|
||||
|
||||
protected ShopEntity() { }
|
||||
|
||||
public ShopEntity(String id, String naam, String subdomain, boolean active) {
|
||||
this.id = id; this.naam = naam; this.subdomain = subdomain; this.active = active;
|
||||
}
|
||||
|
||||
public String getId() { return id; }
|
||||
public String getNaam() { return naam; }
|
||||
public String getSubdomain() { return subdomain; }
|
||||
public boolean isActive() { return active; }
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package dev.shopforge.persistence;
|
||||
|
||||
import dev.shopforge.domain.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.Optional;
|
||||
|
||||
/** ADAPTER — domain ka port yahan poora hota hai. Anuvaad yahin hota hai, kahin aur nahi. */
|
||||
@Repository
|
||||
public class ShopRepositoryAdapter implements ShopRepository {
|
||||
|
||||
private final JpaShopRepository jpa;
|
||||
|
||||
ShopRepositoryAdapter(JpaShopRepository jpa) { this.jpa = jpa; }
|
||||
|
||||
@Override
|
||||
public Optional<Shop> bySubdomain(String subdomain) {
|
||||
return jpa.findBySubdomain(subdomain).map(this::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shop save(Shop shop) {
|
||||
ShopEntity saved = jpa.save(new ShopEntity(
|
||||
shop.id().value(), shop.naam(), shop.subdomain(), shop.active()));
|
||||
return toDomain(saved);
|
||||
}
|
||||
|
||||
private Shop toDomain(ShopEntity e) {
|
||||
return new Shop(new TenantId(e.getId()), e.getNaam(), e.getSubdomain(), e.isActive());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user