-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
207 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
id 'checkstyle' | ||
id 'configure-jandex' | ||
} | ||
|
||
|
||
dependencies { | ||
api enforcedPlatform(libs.quarkus.platform.bom) | ||
|
||
api project(':my-ability') | ||
api project(':my-database-uni') | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
my-ability-uni/src/main/java/net/ximatai/muyun/ability/uni/ICURDUniAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package net.ximatai.muyun.ability.uni; | ||
|
||
public interface ICURDUniAbility extends ICreateAbilityUni { | ||
} |
19 changes: 19 additions & 0 deletions
19
my-ability-uni/src/main/java/net/ximatai/muyun/ability/uni/ICreateAbilityUni.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.ximatai.muyun.ability.uni; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import net.ximatai.muyun.ability.IDatabaseUniAbility; | ||
import net.ximatai.muyun.ability.IMetadataAbility; | ||
|
||
import java.util.Map; | ||
|
||
public interface ICreateAbilityUni extends IDatabaseUniAbility, IMetadataAbility { | ||
|
||
@POST | ||
@Path("/create") | ||
default Uni<String> create(Map body) { | ||
return getDatabase().insert(getInsertSql(body), body); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
id 'checkstyle' | ||
id 'configure-jandex' | ||
} | ||
|
||
|
||
dependencies { | ||
api enforcedPlatform(libs.quarkus.platform.bom) | ||
api project(':my-core') | ||
} |
2 changes: 1 addition & 1 deletion
2
...muyun/core/ability/curd/ICURDAbility.java → ...t/ximatai/muyun/ability/ICURDAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package net.ximatai.muyun.core.ability.curd; | ||
package net.ximatai.muyun.ability; | ||
|
||
public interface ICURDAbility extends ICreateAbility, IUpdateAbility, IDeleteAbility, ISelectAbility { | ||
} |
4 changes: 1 addition & 3 deletions
4
...yun/core/ability/curd/ICreateAbility.java → ...ximatai/muyun/ability/ICreateAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...yun/core/ability/curd/IDeleteAbility.java → ...ximatai/muyun/ability/IDeleteAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...yun/core/ability/curd/ISelectAbility.java → ...ximatai/muyun/ability/ISelectAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...yun/core/ability/curd/IUpdateAbility.java → ...ximatai/muyun/ability/IUpdateAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../muyun/core/ability/IDatabaseAbility.java → ...matai/muyun/ability/IDatabaseAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
my-core/src/main/java/net/ximatai/muyun/ability/IDatabaseUniAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.ximatai.muyun.ability; | ||
|
||
import net.ximatai.muyun.database.IDatabaseAccessUni; | ||
|
||
public interface IDatabaseUniAbility { | ||
|
||
IDatabaseAccessUni getDatabase(); | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../muyun/core/ability/IMetadataAbility.java → ...matai/muyun/ability/IMetadataAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
id 'checkstyle' | ||
id 'configure-jandex' | ||
} | ||
|
||
|
||
dependencies { | ||
api enforcedPlatform(libs.quarkus.platform.bom) | ||
implementation project(':my-database') | ||
// implementation project(':my-core-uni') | ||
|
||
api "io.quarkus:quarkus-hibernate-reactive-panache" | ||
api "io.quarkus:quarkus-reactive-pg-client" | ||
} |
70 changes: 70 additions & 0 deletions
70
my-database-uni/src/main/java/net/ximatai/muyun/database/uni/UniDataAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package net.ximatai.muyun.database.uni; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.persistence.NoResultException; | ||
import jakarta.persistence.Tuple; | ||
import net.ximatai.muyun.database.IDatabaseAccessUni; | ||
import net.ximatai.muyun.database.tool.TupleTool; | ||
import org.hibernate.reactive.mutiny.Mutiny; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@ApplicationScoped | ||
public class UniDataAccess implements IDatabaseAccessUni { | ||
|
||
@Inject | ||
Mutiny.SessionFactory sessionFactory; | ||
|
||
@Override | ||
public Uni<String> insert(String sql, Map<String, Object> params) { | ||
return this.row(sql, params).map(row -> row.get("id").toString()); | ||
} | ||
|
||
@Override | ||
public Uni<Map<String, Object>> row(String sql, Map<String, Object> params) { | ||
return sessionFactory.withSession(session -> { | ||
|
||
Mutiny.SelectionQuery<Tuple> query = session.createNativeQuery(sql, Tuple.class); | ||
|
||
if (params != null) { | ||
params.forEach(query::setParameter); | ||
} | ||
|
||
return query | ||
.getSingleResult() | ||
.map(TupleTool::toMap) | ||
.onFailure(NoResultException.class) | ||
.recoverWithItem(() -> null); | ||
}); | ||
} | ||
|
||
@Override | ||
public Uni<Map<String, Object>> row(String sql) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Uni<List<Map<String, Object>>> query(String sql, Map<String, Object> params) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Uni<List<Map<String, Object>>> query(String sql) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Uni<Integer> update(String sql, Map<String, Object> params) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Uni<Integer> delete(String sql, Map<String, Object> params) { | ||
return null; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
my-database/src/main/java/net/ximatai/muyun/database/IDatabaseAccessBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package net.ximatai.muyun.database; | ||
|
||
import java.util.Map; | ||
|
||
public interface IDatabaseAccessBase { | ||
|
||
Object insert(String sql, Map<String, Object> params); | ||
|
||
Object row(String sql, Map<String, Object> params); | ||
|
||
Object row(String sql); | ||
|
||
Object query(String sql, Map<String, Object> params); | ||
|
||
Object query(String sql); | ||
|
||
Object update(String sql, Map<String, Object> params); | ||
|
||
Object delete(String sql, Map<String, Object> params); | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
my-database/src/main/java/net/ximatai/muyun/database/IDatabaseAccessUni.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.ximatai.muyun.database; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface IDatabaseAccessUni { | ||
|
||
Uni<String> insert(String sql, Map<String, Object> params); | ||
|
||
Uni<Map<String, Object>> row(String sql, Map<String, Object> params); | ||
|
||
Uni<Map<String, Object>> row(String sql); | ||
|
||
Uni<List<Map<String, Object>>> query(String sql, Map<String, Object> params); | ||
|
||
Uni<List<Map<String, Object>>> query(String sql); | ||
|
||
Uni<Integer> update(String sql, Map<String, Object> params); | ||
|
||
Uni<Integer> delete(String sql, Map<String, Object> params); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters