-
Notifications
You must be signed in to change notification settings - Fork 25
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
10 changed files
with
215 additions
and
8 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
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
24 changes: 24 additions & 0 deletions
24
my-core/src/main/java/net/ximatai/muyun/ability/IRuntimeAbility.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.ability; | ||
|
||
import io.vertx.ext.web.RoutingContext; | ||
import net.ximatai.muyun.model.IRuntimeUser; | ||
|
||
public interface IRuntimeAbility { | ||
|
||
String SESSION_USER_KEY = "user"; | ||
|
||
RoutingContext getRoutingContext(); | ||
|
||
default IRuntimeUser getUser() { | ||
return getRoutingContext().session().get(SESSION_USER_KEY); | ||
} | ||
|
||
default void setUser(IRuntimeUser user) { | ||
getRoutingContext().session().put(SESSION_USER_KEY, user); | ||
} | ||
|
||
default void destroy() { | ||
getRoutingContext().session().destroy(); | ||
} | ||
|
||
} |
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
15 changes: 15 additions & 0 deletions
15
my-core/src/main/java/net/ximatai/muyun/model/IRuntimeUser.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,15 @@ | ||
package net.ximatai.muyun.model; | ||
|
||
public interface IRuntimeUser { | ||
|
||
String getId(); | ||
|
||
String getName(); | ||
|
||
String getUsername(); | ||
|
||
String getOrganizationId(); | ||
|
||
String getDepartmentId(); | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
my-core/src/main/java/net/ximatai/muyun/server/VertxRouterSetup.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,17 @@ | ||
package net.ximatai.muyun.server; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.handler.SessionHandler; | ||
import io.vertx.ext.web.sstore.LocalSessionStore; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
|
||
@ApplicationScoped | ||
public class VertxRouterSetup { | ||
|
||
public void init(@Observes StartupEvent ev, Vertx vertx, Router router) { | ||
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx))); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
my-platform/src/main/java/net/ximatai/muyun/platform/controller/RuntimeController.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,28 @@ | ||
package net.ximatai.muyun.platform.controller; | ||
|
||
import io.vertx.ext.web.RoutingContext; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import net.ximatai.muyun.ability.IRuntimeAbility; | ||
import net.ximatai.muyun.model.IRuntimeUser; | ||
|
||
import static net.ximatai.muyun.platform.PlatformConst.BASE_PATH; | ||
|
||
@Path(BASE_PATH + "/runtime") | ||
public class RuntimeController implements IRuntimeAbility { | ||
|
||
@Inject | ||
RoutingContext routingContext; | ||
|
||
@GET | ||
@Path("/whoami") | ||
public IRuntimeUser whoami() { | ||
return getUser(); | ||
} | ||
|
||
@Override | ||
public RoutingContext getRoutingContext() { | ||
return routingContext; | ||
} | ||
} |
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
67 changes: 67 additions & 0 deletions
67
my-platform/src/main/java/net/ximatai/muyun/platform/model/RuntimeUser.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,67 @@ | ||
package net.ximatai.muyun.platform.model; | ||
|
||
import net.ximatai.muyun.model.IRuntimeUser; | ||
|
||
public class RuntimeUser implements IRuntimeUser { | ||
|
||
private String id; | ||
private String name; | ||
private String username; | ||
private boolean isAdmin; | ||
private String organizationId; | ||
private String departmentId; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public RuntimeUser setId(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public RuntimeUser setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public RuntimeUser setUsername(String username) { | ||
this.username = username; | ||
return this; | ||
} | ||
|
||
public boolean isAdmin() { | ||
return isAdmin; | ||
} | ||
|
||
public RuntimeUser setAdmin(boolean admin) { | ||
isAdmin = admin; | ||
return this; | ||
} | ||
|
||
public String getOrganizationId() { | ||
return organizationId; | ||
} | ||
|
||
public RuntimeUser setOrganizationId(String organizationId) { | ||
this.organizationId = organizationId; | ||
return this; | ||
} | ||
|
||
public String getDepartmentId() { | ||
return departmentId; | ||
} | ||
|
||
public RuntimeUser setDepartmentId(String departmentId) { | ||
this.departmentId = departmentId; | ||
return this; | ||
} | ||
} |