mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-08-28 22:21:16 +08:00
chore: remove format and format-check targets from Makefile
This commit is contained in:
+58
-29
@@ -4,8 +4,10 @@ This file provides guidance to AI coding assistants when working with code in th
|
||||
|
||||
## Project Overview
|
||||
|
||||
IoT DC3 is a distributed IoT platform built on Spring Cloud for industrial device connectivity, data collection, and management. It uses a microservices architecture with gRPC +
|
||||
RabbitMQ for inter-service communication and supports multiple industrial protocols (Modbus TCP, OPC DA/UA, MQTT, Siemens S7, virtual listening).
|
||||
IoT DC3 is a distributed IoT platform built on Spring Cloud for industrial device connectivity, data collection, and
|
||||
management. It uses a microservices architecture with gRPC +
|
||||
RabbitMQ for inter-service communication and supports multiple industrial protocols (Modbus TCP, OPC DA/UA, MQTT,
|
||||
Siemens S7, virtual listening).
|
||||
|
||||
**Architecture Layers:**
|
||||
|
||||
@@ -18,7 +20,8 @@ RabbitMQ for inter-service communication and supports multiple industrial protoc
|
||||
|
||||
- Java 21, Spring Boot 4.0.6, Spring Framework 7.0.7 (project version `2026.5.5`, parent `dc3-parent:2026.5.5`)
|
||||
- PostgreSQL (primary DB), RabbitMQ (messaging), EMQX/MQTT (IoT protocol); in-process `LocalCacheService` replaces Redis
|
||||
- gRPC/Protobuf for inter-service APIs via `org.springframework.grpc:spring-grpc-spring-boot-starter` — server classes use `@Service` + extend generated `*ImplBase`; clients are
|
||||
- gRPC/Protobuf for inter-service APIs via `org.springframework.grpc:spring-grpc-spring-boot-starter` — server classes
|
||||
use `@Service` + extend generated `*ImplBase`; clients are
|
||||
registered as beans in a central `GrpcStubConfig` using `GrpcChannelFactory`
|
||||
- Docker / Podman Compose for deployment; a top-level `Makefile` wraps the common flows
|
||||
|
||||
@@ -26,7 +29,8 @@ RabbitMQ for inter-service communication and supports multiple industrial protoc
|
||||
|
||||
### Infrastructure Stacks (docker-compose files under `dc3/`)
|
||||
|
||||
The `dc3/` directory ships multiple compose files. Each has an `-aliyun` variant that pulls images from the Aliyun registry (for users in mainland China):
|
||||
The `dc3/` directory ships multiple compose files. Each has an `-aliyun` variant that pulls images from the Aliyun
|
||||
registry (for users in mainland China):
|
||||
|
||||
| Stack | File | Contents |
|
||||
|-----------------|----------------------------------------|---------------------------------------------------|
|
||||
@@ -37,7 +41,8 @@ The `dc3/` directory ships multiple compose files. Each has an `-aliyun` variant
|
||||
| `grafana` | `dc3/docker-compose-grafana.yml` | Grafana observability stack |
|
||||
| `elasticsearch` | `dc3/docker-compose-elasticsearch.yml` | Elasticsearch stack |
|
||||
|
||||
Note: The project no longer depends on Redis — caching is handled by the in-process `LocalCacheService` (see `dc3-common-public`).
|
||||
Note: The project no longer depends on Redis — caching is handled by the in-process `LocalCacheService` (see
|
||||
`dc3-common-public`).
|
||||
|
||||
### Starting Dependencies
|
||||
|
||||
@@ -76,7 +81,8 @@ podman compose -f dc3/docker-compose-optional.yml up -d
|
||||
|
||||
### Building
|
||||
|
||||
Maven settings are checked in at `.mvn/settings.xml` — always pass `-s .mvn/settings.xml` so local builds match CI / Dockerfile behavior:
|
||||
Maven settings are checked in at `.mvn/settings.xml` — always pass `-s .mvn/settings.xml` so local builds match CI /
|
||||
Dockerfile behavior:
|
||||
|
||||
```bash
|
||||
# Load local env vars used by application YAMLs
|
||||
@@ -93,7 +99,8 @@ mvn -s .mvn/settings.xml clean package
|
||||
mvn -s .mvn/settings.xml clean package -pl dc3-center/dc3-center-auth -am
|
||||
```
|
||||
|
||||
There are no Java test sources under `**/src/test/**/*.java` — rely on compile + targeted runtime smoke checks when refactoring.
|
||||
There are no Java test sources under `**/src/test/**/*.java` — rely on compile + targeted runtime smoke checks when
|
||||
refactoring.
|
||||
|
||||
### Running Services (manual, JAR mode)
|
||||
|
||||
@@ -106,10 +113,12 @@ Services must be started in this order:
|
||||
2. **Auth Center** — HTTP `8300`, gRPC `9300`
|
||||
3. **Data Center** — HTTP `8500`, gRPC `9500`
|
||||
4. **Manager Center** — HTTP `8400`, gRPC `9400`
|
||||
5. **Drivers** — e.g. `dc3-driver-virtual`, `dc3-driver-listening-virtual` (HTTP `6270`, gRPC `6271`), `dc3-driver-modbus-tcp`, `dc3-driver-mqtt`, `dc3-driver-opc-da`,
|
||||
5. **Drivers** — e.g. `dc3-driver-virtual`, `dc3-driver-listening-virtual` (HTTP `6270`, gRPC `6271`),
|
||||
`dc3-driver-modbus-tcp`, `dc3-driver-mqtt`, `dc3-driver-opc-da`,
|
||||
`dc3-driver-opc-ua`, `dc3-driver-plcs7`
|
||||
|
||||
`dc3/env/dev.env.sh` defines host/port/credentials for local infra and `CENTER_AUTH_HOST` / `CENTER_DATA_HOST` / `CENTER_MANAGER_HOST` gRPC targets. `source dc3/env/dev.env.sh`
|
||||
`dc3/env/dev.env.sh` defines host/port/credentials for local infra and `CENTER_AUTH_HOST` / `CENTER_DATA_HOST` /
|
||||
`CENTER_MANAGER_HOST` gRPC targets. `source dc3/env/dev.env.sh`
|
||||
before running services from the shell or IDE.
|
||||
|
||||
## Module Structure
|
||||
@@ -174,52 +183,64 @@ Proto files live under `dc3-api/*/src/main/protobuf/api/<layer>/<service>/`:
|
||||
|
||||
- **dc3-api-auth** (`api/center/auth/`): `tenant.proto`, `token.proto`, `user.proto`, `user_login.proto`
|
||||
- **dc3-api-data** (`api/center/data/`): `point_value.proto`
|
||||
- **dc3-api-driver** (`api/common/driver/`): `driver_device.proto`, `driver_driver.proto`, `driver_entity.proto`, `driver_point.proto`, `driver_query.proto`,
|
||||
- **dc3-api-driver** (`api/common/driver/`): `driver_device.proto`, `driver_driver.proto`, `driver_entity.proto`,
|
||||
`driver_point.proto`, `driver_query.proto`,
|
||||
`driver_query_page.proto`
|
||||
- **dc3-api-manager** (`api/center/manager/`): `manager_device.proto`, `manager_driver.proto`, `manager_point.proto`, `manager_query.proto`, `manager_query_page.proto`
|
||||
- **dc3-api-manager** (`api/center/manager/`): `manager_device.proto`, `manager_driver.proto`, `manager_point.proto`,
|
||||
`manager_query.proto`, `manager_query_page.proto`
|
||||
|
||||
When modifying service APIs:
|
||||
|
||||
1. Edit the `.proto` file in the appropriate `dc3-api-*` module
|
||||
2. Regenerate Java classes: `mvn -s .mvn/settings.xml clean package` (protobuf-maven-plugin runs at compile phase)
|
||||
3. Implement the service interface in the corresponding `dc3-center-*` or driver module — the class extends the generated `*ImplBase` and is annotated with `@Service`. Spring gRPC
|
||||
3. Implement the service interface in the corresponding `dc3-center-*` or driver module — the class extends the
|
||||
generated `*ImplBase` and is annotated with `@Service`. Spring gRPC
|
||||
auto-registers all `BindableService` beans on the server.
|
||||
4. Inter-service calls use gRPC stubs produced by a central `GrpcStubConfig` (`@Bean` methods calling `GrpcChannelFactory.createChannel(<service-name>)`) and injected via
|
||||
4. Inter-service calls use gRPC stubs produced by a central `GrpcStubConfig` (`@Bean` methods calling
|
||||
`GrpcChannelFactory.createChannel(<service-name>)`) and injected via
|
||||
`@Resource` — **not REST**
|
||||
|
||||
## Service Boundaries & Runtime Data Flow
|
||||
|
||||
- HTTP enters via `dc3-gateway` (port 8000). Routes defined in `dc3-gateway/src/main/resources/application-pre.yml` strip the `/api/v3` prefix (`StripPrefix=2`) and optionally
|
||||
- HTTP enters via `dc3-gateway` (port 8000). Routes defined in `dc3-gateway/src/main/resources/application-pre.yml`
|
||||
strip the `/api/v3` prefix (`StripPrefix=2`) and optionally
|
||||
apply the `Authentic` filter.
|
||||
- Manager / Data / Auth each expose both **REST** (for the gateway) and **gRPC** (for inter-service + drivers).
|
||||
- Drivers register and fetch device/point config via Manager gRPC:
|
||||
- Server: `@Service`-annotated `*ImplBase` subclasses under `dc3-common-manager/.../grpc/server/driver/` (e.g. `DriverDriverServer`); Spring gRPC registers them automatically
|
||||
- Client stubs: drivers and Data service obtain stubs from `GrpcStubConfig` (channel named `ManagerConstant.SERVICE_NAME`) and inject them with `@Resource`
|
||||
- Server: `@Service`-annotated `*ImplBase` subclasses under `dc3-common-manager/.../grpc/server/driver/` (e.g.
|
||||
`DriverDriverServer`); Spring gRPC registers them automatically
|
||||
- Client stubs: drivers and Data service obtain stubs from `GrpcStubConfig` (channel named
|
||||
`ManagerConstant.SERVICE_NAME`) and inject them with `@Resource`
|
||||
- Commands and metadata changes flow asynchronously over **RabbitMQ topic exchanges**:
|
||||
- Exchange/routing key constants: `dc3-common-constant/.../RabbitConstant.java`
|
||||
- Exchange declarations: `dc3-common-rabbitmq/.../ExchangeConfig.java`
|
||||
- Example command path — Data service resolves the driver by gRPC, then publishes to `dc3.e.command` keyed by driver service name (
|
||||
- Example command path — Data service resolves the driver by gRPC, then publishes to `dc3.e.command` keyed by driver
|
||||
service name (
|
||||
`dc3-common-data/.../PointValueCommandServiceImpl.java`).
|
||||
|
||||
## Code Architecture Patterns
|
||||
|
||||
**Reactive Web Layer (center services, gateway):**
|
||||
|
||||
- Controllers return `Mono<R<T>>` and typically `extends BaseController` to pull tenant/user headers from the reactive context.
|
||||
- Controllers return `Mono<R<T>>` and typically `extends BaseController` to pull tenant/user headers from the reactive
|
||||
context.
|
||||
- Response envelope is always `R<T>` (`dc3-common-public/.../R.java`) for REST, `GrpcR` for gRPC.
|
||||
- Validation uses grouped marker interfaces (`Add`, `Update`, etc.) with `@Validated(...)` on controller methods.
|
||||
- URL prefixes/constants go in `*Constant` classes (e.g. `ManagerConstant.DRIVER_URL_PREFIX`), never hardcoded in controllers.
|
||||
- URL prefixes/constants go in `*Constant` classes (e.g. `ManagerConstant.DRIVER_URL_PREFIX`), never hardcoded in
|
||||
controllers.
|
||||
|
||||
**Models & Mapping:**
|
||||
|
||||
- Explicit BO / VO / DTO separation — **never expose entities directly**.
|
||||
- Conversions go through `*Builder` classes (e.g. `DriverBuilder`, `GrpcDriverBuilder`) rather than reflection-based mappers.
|
||||
- Conversions go through `*Builder` classes (e.g. `DriverBuilder`, `GrpcDriverBuilder`) rather than reflection-based
|
||||
mappers.
|
||||
|
||||
**Configuration:**
|
||||
|
||||
- All YAML uses `${ENV:default}` placeholders — **never hardcode `localhost` in code paths**.
|
||||
- Profile selection via `${NODE_ENV:dev}`; Maven profiles: `dev` (default), `test`, `pre`, `pro`.
|
||||
- `pre` / `pro` profiles resolve service discovery/config through Nacos (`spring.cloud.nacos.*` in gateway + center YAMLs).
|
||||
- `pre` / `pro` profiles resolve service discovery/config through Nacos (`spring.cloud.nacos.*` in gateway + center
|
||||
YAMLs).
|
||||
- gRPC targets overridable via env (`CENTER_AUTH_HOST`, `CENTER_DATA_HOST`, `CENTER_MANAGER_HOST`).
|
||||
|
||||
**Driver Services:**
|
||||
@@ -228,12 +249,14 @@ When modifying service APIs:
|
||||
- Extend base classes from `dc3-common-driver`.
|
||||
- Implement gRPC service interfaces from `dc3-api-driver`.
|
||||
- Register with Manager Center on startup via `DriverApi.DriverRegister()`.
|
||||
- **Driver service names are routing-critical** — they become suffixes in RabbitMQ routing keys and gRPC target names. Preserve existing naming constants when refactoring.
|
||||
- **Driver service names are routing-critical** — they become suffixes in RabbitMQ routing keys and gRPC target names.
|
||||
Preserve existing naming constants when refactoring.
|
||||
|
||||
**Center Services:**
|
||||
|
||||
- Implement gRPC service interfaces from the matching `dc3-api-*` module.
|
||||
- Use `dc3-common-dal` for data access, `LocalCacheService` from `dc3-common-public` for caching, `dc3-common-rabbitmq` for messaging.
|
||||
- Use `dc3-common-dal` for data access, `LocalCacheService` from `dc3-common-public` for caching, `dc3-common-rabbitmq`
|
||||
for messaging.
|
||||
|
||||
**Multi-tenancy:**
|
||||
|
||||
@@ -251,13 +274,15 @@ When modifying service APIs:
|
||||
2. Add it to `dc3-driver/pom.xml` `<modules>`.
|
||||
3. Depend on `dc3-common-driver`; implement the required protocol adapter.
|
||||
4. Keep the driver service name consistent across `application.yml`, RabbitMQ routing, and gRPC registration.
|
||||
5. Handle the standard driver responsibilities: connect to devices, acquire data, execute commands, register with Manager, report status/events.
|
||||
5. Handle the standard driver responsibilities: connect to devices, acquire data, execute commands, register with
|
||||
Manager, report status/events.
|
||||
|
||||
## Git Commit Identity (for Claude's commits)
|
||||
|
||||
**Project-only rule — only applies to commits Claude makes in this repository.**
|
||||
|
||||
When committing, Claude must use the `claude[bot]` GitHub App identity so commits show Claude's real avatar on GitHub, consistent with how Copilot's commits already appear in this
|
||||
When committing, Claude must use the `claude[bot]` GitHub App identity so commits show Claude's real avatar on GitHub,
|
||||
consistent with how Copilot's commits already appear in this
|
||||
repo's history. Run every commit as:
|
||||
|
||||
```bash
|
||||
@@ -271,8 +296,10 @@ EOF
|
||||
)"
|
||||
```
|
||||
|
||||
- `209825114` is the GitHub user ID of the official `claude[bot]` account; the `<id>+<login>@users.noreply.github.com` form is what GitHub uses to link a commit to a bot avatar.
|
||||
- Do **NOT** run `git config --local user.name` / `user.email` — the repo's default git identity must stay as-is so the human author's own commits keep their own identity.
|
||||
- `209825114` is the GitHub user ID of the official `claude[bot]` account; the `<id>+<login>@users.noreply.github.com`
|
||||
form is what GitHub uses to link a commit to a bot avatar.
|
||||
- Do **NOT** run `git config --local user.name` / `user.email` — the repo's default git identity must stay as-is so the
|
||||
human author's own commits keep their own identity.
|
||||
- The `Co-Authored-By` trailer may remain; it is harmless alongside the bot-identity author.
|
||||
|
||||
## Branching and Contribution
|
||||
@@ -285,7 +312,9 @@ EOF
|
||||
|
||||
## Notes on Existing State
|
||||
|
||||
- No Java unit tests (`**/src/test/**/*.java` is empty). Validate changes by compile + targeted runtime smoke (spin up a compose stack, hit gateway, check driver registration /
|
||||
- No Java unit tests (`**/src/test/**/*.java` is empty). Validate changes by compile + targeted runtime smoke (spin up a
|
||||
compose stack, hit gateway, check driver registration /
|
||||
gRPC calls).
|
||||
- READMEs with additional context: root `README.md` (and `.ja.md`, `.vi.md`, `.zh.md`), plus per-API READMEs (`dc3-api/dc3-api-auth/README.md`, `.../dc3-api-data/README.md`,
|
||||
- READMEs with additional context: root `README.md` (and `.ja.md`, `.vi.md`, `.zh.md`), plus per-API READMEs (
|
||||
`dc3-api/dc3-api-auth/README.md`, `.../dc3-api-data/README.md`,
|
||||
`.../dc3-api-driver/README.md`).
|
||||
|
||||
@@ -43,4 +43,7 @@
|
||||
|
||||
</mirrors>
|
||||
|
||||
<pluginGroups>
|
||||
<pluginGroup>io.spring.javaformat</pluginGroup>
|
||||
</pluginGroups>
|
||||
</settings>
|
||||
@@ -18,7 +18,7 @@
|
||||
# tip:
|
||||
# make -f ./Makefile help
|
||||
|
||||
.PHONY: help clean package format format-check app app-all dev dev-all dev-db dev-optional build deploy tag \
|
||||
.PHONY: help clean package app app-all dev dev-all dev-db dev-optional build deploy tag \
|
||||
check-compose compose-file compose-up compose-down compose-ps compose-config compose-build \
|
||||
compose-logs compose-pull compose-restart
|
||||
|
||||
@@ -58,11 +58,9 @@ endif
|
||||
|
||||
help:
|
||||
echo 'You can use make to execute the following commands:' \
|
||||
&& echo 'Usage: make [help | clean | package | format | format-check | app | app-all | dev-db | dev-optional | dev | dev-all | build | deploy | tag]' \
|
||||
&& echo 'Usage: make [help | clean | package | app | app-all | dev-db | dev-optional | dev | dev-all | build | deploy | tag]' \
|
||||
&& echo ' - make clean: clean Maven build artifacts' \
|
||||
&& echo ' - make package: package all modules with Maven' \
|
||||
&& echo ' - make format: apply Spring Java Format to all Java sources' \
|
||||
&& echo ' - make format-check: validate code style without modifying files' \
|
||||
&& echo ' - make tag: git tag' \
|
||||
&& echo ' - make app: run the packaged application stack (docker-compose.yml)' \
|
||||
&& echo ' - make app-all: run db + optional + packaged application stacks' \
|
||||
@@ -97,12 +95,6 @@ clean:
|
||||
package:
|
||||
$(MVN) clean package
|
||||
|
||||
format:
|
||||
$(MVN) io.spring.javaformat:spring-javaformat-maven-plugin:apply
|
||||
|
||||
format-check:
|
||||
$(MVN) io.spring.javaformat:spring-javaformat-maven-plugin:validate
|
||||
|
||||
tag:
|
||||
dc3/bin/tag.sh
|
||||
|
||||
|
||||
+6
-3
@@ -70,7 +70,8 @@ make dev
|
||||
make dev-all
|
||||
```
|
||||
|
||||
中国本土向けのイメージレジストリを使う場合は `REGISTRY=domestic` を指定してください。互換エイリアスの `REGISTRY=aliyun` と `REGISTRY=cn` も利用できます:
|
||||
中国本土向けのイメージレジストリを使う場合は `REGISTRY=domestic` を指定してください。互換エイリアスの `REGISTRY=aliyun` と
|
||||
`REGISTRY=cn` も利用できます:
|
||||
|
||||
```bash
|
||||
make dev-db REGISTRY=domestic
|
||||
@@ -88,7 +89,8 @@ make compose-logs STACK=dev REGISTRY=global
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
リポジトリ直下の `.env` は `dc3/` 配下の Compose ファイル用の変数展開に使用されます。アプリケーション実行時の環境変数は引き続き `dc3/env/dev.env` または `dc3/env/dev.env.sh`
|
||||
リポジトリ直下の `.env` は `dc3/` 配下の Compose ファイル用の変数展開に使用されます。アプリケーション実行時の環境変数は引き続き
|
||||
`dc3/env/dev.env` または `dc3/env/dev.env.sh`
|
||||
で管理されます。
|
||||
|
||||
## 3.2 準備
|
||||
@@ -102,7 +104,8 @@ mvn -s .mvn/settings.xml clean package
|
||||
|
||||
> **ローカル開発ガイド**: ワンストップのローカルセットアップ手順は [`docs/QUICKSTART.md`](docs/QUICKSTART.md) を参照してください。
|
||||
|
||||
> **トラブルシューティング**: よくあるビルド/ランタイムの問題と解決策は [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) を参照してください。
|
||||
> **トラブルシューティング**: よくあるビルド/ランタイムの問題と解決策は [
|
||||
`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) を参照してください。
|
||||
|
||||
## 3.3 サービスの起動
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ All components and code are open-source, ensuring transparency, flexibility, and
|
||||
|
||||
# 1 Architecture
|
||||
|
||||
The architecture is designed for end-to-end IoT capabilities across device connectivity, data services, operational management, and extensible application integration.
|
||||
The architecture is designed for end-to-end IoT capabilities across device connectivity, data services, operational
|
||||
management, and extensible application integration.
|
||||
|
||||
- **Driver Layer**: Provides SDKs for rapid driver development and seamless connectivity to physical devices through
|
||||
standard or proprietary protocols. This layer handles southbound data acquisition and command execution;
|
||||
@@ -55,7 +56,8 @@ The architecture is designed for end-to-end IoT capabilities across device conne
|
||||
|
||||
> Choose one
|
||||
>
|
||||
> This base stack starts PostgreSQL and RabbitMQ. If you need a database SQL script, connect directly to the started database in the container for export.
|
||||
> This base stack starts PostgreSQL and RabbitMQ. If you need a database SQL script, connect directly to the started
|
||||
> database in the container for export.
|
||||
|
||||
```bash
|
||||
# Global access with standard container registry service
|
||||
@@ -74,7 +76,8 @@ make dev
|
||||
make dev-all
|
||||
```
|
||||
|
||||
Use `REGISTRY=domestic` when you want the mainland China image registry variants. Backward-compatible aliases `REGISTRY=aliyun` and `REGISTRY=cn` still work:
|
||||
Use `REGISTRY=domestic` when you want the mainland China image registry variants. Backward-compatible aliases
|
||||
`REGISTRY=aliyun` and `REGISTRY=cn` still work:
|
||||
|
||||
```bash
|
||||
make dev-db REGISTRY=domestic
|
||||
@@ -126,11 +129,13 @@ source dc3/env/dev.env.sh
|
||||
mvn -s .mvn/settings.xml clean package
|
||||
```
|
||||
|
||||
> **Module Overview**: See [`docs/MODULES.md`](docs/MODULES.md) for the full module dependency map and runtime flow diagram.
|
||||
> **Module Overview**: See [`docs/MODULES.md`](docs/MODULES.md) for the full module dependency map and runtime flow
|
||||
> diagram.
|
||||
|
||||
> **Local Dev Guide**: See [`docs/QUICKSTART.md`](docs/QUICKSTART.md) for a one-stop local setup workflow.
|
||||
|
||||
> **Troubleshooting**: See [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) for common build/runtime issues and resolutions.
|
||||
> **Troubleshooting**: See [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) for common build/runtime issues and
|
||||
> resolutions.
|
||||
|
||||
## 3.3 Start Services
|
||||
|
||||
|
||||
+20
-10
@@ -26,20 +26,27 @@ Toàn bộ thành phần và mã nguồn đều mở, đảm bảo tính minh b
|
||||
|
||||
# 1 Kiến trúc
|
||||
|
||||
Kiến trúc được thiết kế để cung cấp năng lực IoT đầu-cuối, bao gồm kết nối thiết bị, dịch vụ dữ liệu, quản lý vận hành và tích hợp ứng dụng mở rộng.
|
||||
Kiến trúc được thiết kế để cung cấp năng lực IoT đầu-cuối, bao gồm kết nối thiết bị, dịch vụ dữ liệu, quản lý vận hành
|
||||
và tích hợp ứng dụng mở rộng.
|
||||
|
||||
- **Tầng Driver**: Cung cấp SDK để kết nối thiết bị vật lý qua giao thức tiêu chuẩn hoặc độc quyền, đảm nhiệm thu thập dữ liệu hướng nam và thực thi lệnh điều khiển;
|
||||
- **Tầng Dữ liệu**: Cung cấp thu thập, lưu trữ và truy vấn dữ liệu thiết bị một cách tin cậy, phục vụ cả dữ liệu thời gian thực và lịch sử;
|
||||
- **Tầng Quản lý**: Đóng vai trò trung tâm hợp tác microservice phân tán, bao gồm đăng ký dịch vụ, quản lý driver/thiết bị, điều phối lệnh và quản trị cấu hình tập trung;
|
||||
- **Tầng Ứng dụng**: Hỗ trợ mở dữ liệu, lập lịch tác vụ, cảnh báo/thông báo, quản lý log, tích hợp bên thứ ba và các kịch bản tự động hóa tăng cường bởi AI.
|
||||
- **Tầng Driver**: Cung cấp SDK để kết nối thiết bị vật lý qua giao thức tiêu chuẩn hoặc độc quyền, đảm nhiệm thu thập
|
||||
dữ liệu hướng nam và thực thi lệnh điều khiển;
|
||||
- **Tầng Dữ liệu**: Cung cấp thu thập, lưu trữ và truy vấn dữ liệu thiết bị một cách tin cậy, phục vụ cả dữ liệu thời
|
||||
gian thực và lịch sử;
|
||||
- **Tầng Quản lý**: Đóng vai trò trung tâm hợp tác microservice phân tán, bao gồm đăng ký dịch vụ, quản lý driver/thiết
|
||||
bị, điều phối lệnh và quản trị cấu hình tập trung;
|
||||
- **Tầng Ứng dụng**: Hỗ trợ mở dữ liệu, lập lịch tác vụ, cảnh báo/thông báo, quản lý log, tích hợp bên thứ ba và các
|
||||
kịch bản tự động hóa tăng cường bởi AI.
|
||||
|
||||
# 2 Mục tiêu
|
||||
|
||||
- **Khả năng mở rộng**: Hỗ trợ mở rộng ngang bằng Spring Cloud cho khối lượng công việc IoT phân tán, thông lượng cao;
|
||||
- **Tính bền vững**: Giảm rủi ro điểm lỗi đơn lẻ nhờ thiết kế chịu lỗi và các node dịch vụ có thể thay thế;
|
||||
- **Hiệu năng**: Đáp ứng nhu cầu kết nối thiết bị quy mô lớn và xử lý telemetry;
|
||||
- **Khả năng mở rộng phát triển**: Tăng tốc tích hợp giao thức mới và driver tùy biến thông qua SDK và cơ chế đăng ký dịch vụ;
|
||||
- **Linh hoạt triển khai**: Vận hành trên private cloud, public cloud và edge, đồng thời giữ tương thích hệ sinh thái Java;
|
||||
- **Khả năng mở rộng phát triển**: Tăng tốc tích hợp giao thức mới và driver tùy biến thông qua SDK và cơ chế đăng ký
|
||||
dịch vụ;
|
||||
- **Linh hoạt triển khai**: Vận hành trên private cloud, public cloud và edge, đồng thời giữ tương thích hệ sinh thái
|
||||
Java;
|
||||
- **Hiệu quả vận hành**: Đơn giản hóa quy trình onboarding, đăng ký và xác thực quyền;
|
||||
- **Bảo mật và đa tenant**: Hỗ trợ mã hóa truyền dữ liệu, tách biệt namespace và cơ chế phân tách theo tenant;
|
||||
- **Phân phối cloud-native**: Tối ưu cho Kubernetes và container hóa bằng Docker để triển khai nhất quán;
|
||||
@@ -71,7 +78,8 @@ make dev
|
||||
make dev-all
|
||||
```
|
||||
|
||||
Nếu bạn muốn dùng registry tối ưu cho người dùng ở Trung Quốc đại lục, hãy đặt `REGISTRY=domestic`. Các bí danh tương thích `REGISTRY=aliyun` và `REGISTRY=cn` vẫn dùng được:
|
||||
Nếu bạn muốn dùng registry tối ưu cho người dùng ở Trung Quốc đại lục, hãy đặt `REGISTRY=domestic`. Các bí danh tương
|
||||
thích `REGISTRY=aliyun` và `REGISTRY=cn` vẫn dùng được:
|
||||
|
||||
```bash
|
||||
make dev-db REGISTRY=domestic
|
||||
@@ -89,7 +97,8 @@ Trước khi thay đổi cổng publish, tag image hoặc tham số observabilit
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Tệp `.env` ở thư mục gốc được dùng cho nội suy biến trong các file Compose dưới `dc3/`; các biến runtime của ứng dụng vẫn nằm trong `dc3/env/dev.env` hoặc `dc3/env/dev.env.sh`.
|
||||
Tệp `.env` ở thư mục gốc được dùng cho nội suy biến trong các file Compose dưới `dc3/`; các biến runtime của ứng dụng
|
||||
vẫn nằm trong `dc3/env/dev.env` hoặc `dc3/env/dev.env.sh`.
|
||||
|
||||
## 3.2 Chuẩn bị
|
||||
|
||||
@@ -102,7 +111,8 @@ mvn -s .mvn/settings.xml clean package
|
||||
|
||||
> **Hướng dẫn dev cục bộ**: Xem [`docs/QUICKSTART.md`](docs/QUICKSTART.md) để biết quy trình thiết lập môi trường local.
|
||||
|
||||
> **Khắc phục sự cố**: Xem [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) để biết các vấn đề thường gặp khi build/runtime và cách giải quyết.
|
||||
> **Khắc phục sự cố**: Xem [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) để biết các vấn đề thường gặp khi
|
||||
> build/runtime và cách giải quyết.
|
||||
|
||||
## 3.3 Khởi động dịch vụ
|
||||
|
||||
|
||||
+2
-1
@@ -88,7 +88,8 @@ make compose-logs STACK=dev REGISTRY=global
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
根目录 `.env` 用于 `dc3/` 下 Compose 文件的变量插值;应用运行时环境变量仍然位于 `dc3/env/dev.env` 或 `dc3/env/dev.env.sh`。
|
||||
根目录 `.env` 用于 `dc3/` 下 Compose 文件的变量插值;应用运行时环境变量仍然位于 `dc3/env/dev.env` 或
|
||||
`dc3/env/dev.env.sh`。
|
||||
|
||||
## 3.2 准备工作
|
||||
|
||||
|
||||
+14
-7
@@ -1,7 +1,9 @@
|
||||
# Security Policy
|
||||
|
||||
> :lock: **Note:** iot-dc3 is a distributed Internet of Things (IoT) platform that involves device access, data collection, and command dispatch. Security issues not only affect
|
||||
> system operation but may also cause data or control risks. Please pay close attention to security configuration and version updates.
|
||||
> :lock: **Note:** iot-dc3 is a distributed Internet of Things (IoT) platform that involves device access, data
|
||||
> collection, and command dispatch. Security issues not only affect
|
||||
> system operation but may also cause data or control risks. Please pay close attention to security configuration and
|
||||
> version updates.
|
||||
|
||||
## Supported Versions
|
||||
|
||||
@@ -18,23 +20,28 @@ The following table lists the iot-dc3 versions that are currently supported with
|
||||
## Reporting a Vulnerability
|
||||
|
||||
> We take security issues very seriously.
|
||||
> If a vulnerability is verified, we will fix it as soon as possible and disclose the fix information in the release notes.
|
||||
> If a vulnerability is verified, we will fix it as soon as possible and disclose the fix information in the release
|
||||
> notes.
|
||||
|
||||
If you find a potential security vulnerability while using **iot-dc3**, **do not disclose it publicly in issues or discussion areas**, but report it through the following private
|
||||
If you find a potential security vulnerability while using **iot-dc3**, **do not disclose it publicly in issues or
|
||||
discussion areas**, but report it through the following private
|
||||
channels:
|
||||
|
||||
1. **Email report**:
|
||||
Send an email to the project maintenance team, and please include the keyword `Security Vulnerability` in the subject line.
|
||||
Send an email to the project maintenance team, and please include the keyword `Security Vulnerability` in the subject
|
||||
line.
|
||||
|
||||
2. **Direct message report**:
|
||||
You can directly contact the project maintainers through the private message function on Gitee or GitHub.
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
To ensure the security and stability of the iot-dc3 platform in production environments, it is recommended to follow these practices:
|
||||
To ensure the security and stability of the iot-dc3 platform in production environments, it is recommended to follow
|
||||
these practices:
|
||||
|
||||
- :white_check_mark: Always use supported versions;
|
||||
- :no_entry_sign: Do not expose core communication ports (such as MQTT, TCP, Modbus gateways) directly to the public network;
|
||||
- :no_entry_sign: Do not expose core communication ports (such as MQTT, TCP, Modbus gateways) directly to the public
|
||||
network;
|
||||
- :lock: Use secure authentication mechanisms and enable HTTPS / SSL encryption;
|
||||
- :arrows_counterclockwise: Regularly update system dependencies and Docker images;
|
||||
- :jigsaw: Only authorize trusted devices and users to access the system;
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
<module name="com.puppycrawl.tools.checkstyle.Checker">
|
||||
|
||||
<!-- Exclude third-party and generated code -->
|
||||
<module name="BeforeExecutionExclusionFileFilter">
|
||||
<property name="fileNamePattern" value="[/\\](com[/\\]serotonin|org[/\\]openscada|io[/\\]github[/\\]pnoker[/\\]driver[/\\]api[/\\]impl[/\\]nodave)[/\\]" />
|
||||
</module>
|
||||
|
||||
<module name="NewlineAtEndOfFileCheck" />
|
||||
|
||||
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
|
||||
|
||||
<!-- Block Checks -->
|
||||
<module name="EmptyBlockCheck">
|
||||
<property name="option" value="text" />
|
||||
</module>
|
||||
<module name="LeftCurlyCheck" />
|
||||
<module name="RightCurlyCheck">
|
||||
<property name="option" value="alone" />
|
||||
</module>
|
||||
<!-- NeedBracesCheck excluded — too many existing single-line if/for without braces, fix incrementally -->
|
||||
|
||||
<!-- Coding -->
|
||||
<module name="CovariantEqualsCheck" />
|
||||
<module name="EmptyStatementCheck" />
|
||||
<module name="EqualsHashCodeCheck" />
|
||||
<module name="InnerAssignmentCheck" />
|
||||
<module name="SimplifyBooleanExpressionCheck" />
|
||||
<module name="SimplifyBooleanReturnCheck" />
|
||||
<module name="StringLiteralEqualityCheck" />
|
||||
<module name="MultipleVariableDeclarationsCheck" />
|
||||
<module name="OneStatementPerLineCheck" />
|
||||
|
||||
<!-- Imports (AvoidStarImportCheck excluded — too many existing star imports, fix incrementally) -->
|
||||
<module name="RedundantImportCheck" />
|
||||
<module name="UnusedImportsCheck">
|
||||
<property name="processJavadoc" value="true" />
|
||||
</module>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<module name="UpperEllCheck" />
|
||||
<module name="ArrayTypeStyleCheck" />
|
||||
<module name="OuterTypeFilenameCheck" />
|
||||
|
||||
<!-- Modifiers -->
|
||||
<module name="RedundantModifierCheck" />
|
||||
<module name="ModifierOrderCheck" />
|
||||
|
||||
<!-- Regexp -->
|
||||
<module name="RegexpCheck">
|
||||
<property name="format" value="[ \t]+$" />
|
||||
<property name="illegalPattern" value="true" />
|
||||
<property name="message" value="Trailing whitespace" />
|
||||
</module>
|
||||
|
||||
<!-- Whitespace -->
|
||||
<module name="GenericWhitespaceCheck" />
|
||||
<module name="WhitespaceAfterCheck" />
|
||||
<module name="WhitespaceAroundCheck" />
|
||||
|
||||
</module>
|
||||
</module>
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-api-auth` provides gRPC service definitions for authentication and authorization in the IoT DC3 platform. It defines the interfaces for tenant management, user authentication,
|
||||
`dc3-api-auth` provides gRPC service definitions for authentication and authorization in the IoT DC3 platform. It
|
||||
defines the interfaces for tenant management, user authentication,
|
||||
token validation, and user login operations.
|
||||
|
||||
## Module Information
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-api-data` provides gRPC service definitions for device data collection and management in the IoT DC3 platform. It defines interfaces for querying real-time device point values
|
||||
`dc3-api-data` provides gRPC service definitions for device data collection and management in the IoT DC3 platform. It
|
||||
defines interfaces for querying real-time device point values
|
||||
and historical data retrieval.
|
||||
|
||||
## Module Information
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-api-driver` provides gRPC service definitions for driver services in the IoT DC3 platform. It defines the communication interface between device drivers and the platform's
|
||||
`dc3-api-driver` provides gRPC service definitions for driver services in the IoT DC3 platform. It defines the
|
||||
communication interface between device drivers and the platform's
|
||||
manager service, enabling device registration, metadata synchronization, and point value collection.
|
||||
|
||||
## Module Information
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-api-manager` provides gRPC service definitions for the Manager Center in the IoT DC3 platform. It defines the interfaces used by the Data service and other consumers to query
|
||||
`dc3-api-manager` provides gRPC service definitions for the Manager Center in the IoT DC3 platform. It defines the
|
||||
interfaces used by the Data service and other consumers to query
|
||||
driver, device, and point metadata from the Manager Center.
|
||||
|
||||
## Module Information
|
||||
|
||||
@@ -117,53 +117,6 @@
|
||||
<groupId>org.xolstice.maven.plugins</groupId>
|
||||
<artifactId>protobuf-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- Spring Java Format -->
|
||||
<plugin>
|
||||
<groupId>io.spring.javaformat</groupId>
|
||||
<artifactId>spring-javaformat-maven-plugin</artifactId>
|
||||
<version>0.0.47</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>validate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Checkstyle (Spring Java Format rules) -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.spring.javaformat</groupId>
|
||||
<artifactId>spring-javaformat-checkstyle</artifactId>
|
||||
<version>0.0.47</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle-validation</id>
|
||||
<phase>validate</phase>
|
||||
<inherited>true</inherited>
|
||||
<configuration>
|
||||
<configLocation>${maven.multiModuleProjectDirectory}/checkstyle.xml</configLocation>
|
||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
+3
-3
@@ -28,8 +28,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class AgenticApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AgenticApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AgenticApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-center-auth` is the Authorization Center of the IoT DC3 platform. It provides authentication and authorization management for the entire platform including tenant management,
|
||||
`dc3-center-auth` is the Authorization Center of the IoT DC3 platform. It provides authentication and authorization
|
||||
management for the entire platform including tenant management,
|
||||
user login, token validation, and permission control.
|
||||
|
||||
## Module Information
|
||||
@@ -25,7 +26,8 @@ user login, token validation, and permission control.
|
||||
- **Tenant Management**: Multi-tenant registration, lookup by tenant code
|
||||
- **User Authentication**: User login validation with salt-based encrypted password
|
||||
- **Dictionary Services**: Provide lookup dictionaries for auth-scoped data
|
||||
- **gRPC Server**: Exposes `TenantApi`, `UserApi`, `UserLoginApi`, `TokenApi` for inter-service consumption (e.g., Gateway)
|
||||
- **gRPC Server**: Exposes `TenantApi`, `UserApi`, `UserLoginApi`, `TokenApi` for inter-service consumption (e.g.,
|
||||
Gateway)
|
||||
|
||||
## REST Endpoints (via Gateway)
|
||||
|
||||
|
||||
+8
-7
@@ -34,12 +34,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class AuthApplication {
|
||||
|
||||
/**
|
||||
* Main entry point for the Authentication Center Service.
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class, args);
|
||||
}
|
||||
/**
|
||||
* Main entry point for the Authentication Center Service.
|
||||
*
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-center-data` is the Data Center of the IoT DC3 platform. It integrates common messaging middleware including AMQP, WebSocket, and MQTT for collecting device point values from
|
||||
`dc3-center-data` is the Data Center of the IoT DC3 platform. It integrates common messaging middleware including AMQP,
|
||||
WebSocket, and MQTT for collecting device point values from
|
||||
drivers, storing them in the time-series repository, and exposing data query APIs.
|
||||
|
||||
## Module Information
|
||||
@@ -21,9 +22,11 @@ drivers, storing them in the time-series repository, and exposing data query API
|
||||
|
||||
## Key Responsibilities
|
||||
|
||||
- **Point Value Ingestion**: Receives point values from drivers via RabbitMQ (`dc3.e.value` exchange, `dc3.q.value.point` queue) and persists them to the time-series storage
|
||||
- **Point Value Ingestion**: Receives point values from drivers via RabbitMQ (`dc3.e.value` exchange,
|
||||
`dc3.q.value.point` queue) and persists them to the time-series storage
|
||||
- **Point Value Query**: Exposes REST and gRPC APIs to query the latest and historical point values
|
||||
- **Device Command Dispatch**: Receives read/write commands, resolves the target driver via Manager gRPC (`ManagerConstant.SERVICE_NAME`), and publishes to `dc3.e.command`
|
||||
- **Device Command Dispatch**: Receives read/write commands, resolves the target driver via Manager gRPC (
|
||||
`ManagerConstant.SERVICE_NAME`), and publishes to `dc3.e.command`
|
||||
- **Driver Status**: Tracks driver online/offline status events
|
||||
- **Data Query**: Supports pagination query, real-time telemetry, and historical data retrieval
|
||||
|
||||
|
||||
+8
-7
@@ -34,12 +34,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class DataApplication {
|
||||
|
||||
/**
|
||||
* Main entry point for the Data Center Service.
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataApplication.class, args);
|
||||
}
|
||||
/**
|
||||
* Main entry point for the Data Center Service.
|
||||
*
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-center-manager` is the Device Management Center of the IoT DC3 platform. It provides comprehensive management for all device collections including device/driver registration,
|
||||
`dc3-center-manager` is the Device Management Center of the IoT DC3 platform. It provides comprehensive management for
|
||||
all device collections including device/driver registration,
|
||||
profile management, point configuration, permission management, and command interfaces.
|
||||
|
||||
## Module Information
|
||||
|
||||
+8
-7
@@ -34,12 +34,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class ManagerApplication {
|
||||
|
||||
/**
|
||||
* Main entry point for the Manager Center Service.
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ManagerApplication.class, args);
|
||||
}
|
||||
/**
|
||||
* Main entry point for the Manager Center Service.
|
||||
*
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ManagerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-center-single` is the Integrated All-in-One Center of the IoT DC3 platform. It combines authorization, data, and management services into a single deployable module for
|
||||
`dc3-center-single` is the Integrated All-in-One Center of the IoT DC3 platform. It combines authorization, data, and
|
||||
management services into a single deployable module for
|
||||
simplified single-node or lightweight deployment scenarios.
|
||||
|
||||
## Module Information
|
||||
|
||||
+10
-9
@@ -37,16 +37,17 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
* Configures MyBatis mapper scanning for multiple packages. Enables automatic discovery
|
||||
* of mapper interfaces for database access.
|
||||
*/
|
||||
@MapperScan(basePackages = { "io.github.pnoker.common.dal.mapper", "io.github.pnoker.common.auth.mapper",
|
||||
"io.github.pnoker.common.data.mapper", "io.github.pnoker.common.manager.mapper" })
|
||||
@MapperScan(basePackages = {"io.github.pnoker.common.dal.mapper", "io.github.pnoker.common.auth.mapper",
|
||||
"io.github.pnoker.common.data.mapper", "io.github.pnoker.common.manager.mapper"})
|
||||
public class SingleApplication {
|
||||
|
||||
/**
|
||||
* Main entry point for the Single Center Service.
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SingleApplication.class, args);
|
||||
}
|
||||
/**
|
||||
* Main entry point for the Single Center Service.
|
||||
*
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SingleApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-12
@@ -31,19 +31,19 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties(prefix = "dc3.agentic")
|
||||
public class AgenticProperties {
|
||||
|
||||
/**
|
||||
* Whether to enable the agentic module.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
/**
|
||||
* Whether to enable the agentic module.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* Maximum number of messages retained per conversation for chat memory.
|
||||
*/
|
||||
private int memoryMaxMessages = 50;
|
||||
/**
|
||||
* Maximum number of messages retained per conversation for chat memory.
|
||||
*/
|
||||
private int memoryMaxMessages = 50;
|
||||
|
||||
/**
|
||||
* Session time-to-live in hours. Sessions older than this are marked expired.
|
||||
*/
|
||||
private int sessionTtlHours = 72;
|
||||
/**
|
||||
* Session time-to-live in hours. Sessions older than this are marked expired.
|
||||
*/
|
||||
private int sessionTtlHours = 72;
|
||||
|
||||
}
|
||||
|
||||
+33
-33
@@ -37,40 +37,40 @@ import org.springframework.context.annotation.Configuration;
|
||||
@EnableConfigurationProperties(AgenticProperties.class)
|
||||
public class ChatClientConfig {
|
||||
|
||||
private static final String SYSTEM_PROMPT = """
|
||||
You are an intelligent assistant for the IoT DC3 platform.
|
||||
private static final String SYSTEM_PROMPT = """
|
||||
You are an intelligent assistant for the IoT DC3 platform.
|
||||
|
||||
You can help users manage IoT devices, query real-time and historical data,
|
||||
and perform device operations. You have access to the following capabilities:
|
||||
|
||||
- **Auth tools**: Look up tenants, users, and login records.
|
||||
- **Manager tools**: Query devices, drivers, and data points (metrics).
|
||||
- **Data tools**: Read real-time point values, query historical data, and send read/write commands to devices.
|
||||
|
||||
Guidelines:
|
||||
- Always confirm before sending write commands to physical devices.
|
||||
- Present data in a clear, structured format.
|
||||
- If a query fails, explain the error and suggest alternatives.
|
||||
- Use the tools to fetch real data rather than making up values.
|
||||
""";
|
||||
|
||||
You can help users manage IoT devices, query real-time and historical data,
|
||||
and perform device operations. You have access to the following capabilities:
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ChatMemory agenticChatMemory(ChatMemoryRepository chatMemoryRepository, AgenticProperties properties) {
|
||||
return MessageWindowChatMemory.builder()
|
||||
.chatMemoryRepository(chatMemoryRepository)
|
||||
.maxMessages(properties.getMemoryMaxMessages())
|
||||
.build();
|
||||
}
|
||||
|
||||
- **Auth tools**: Look up tenants, users, and login records.
|
||||
- **Manager tools**: Query devices, drivers, and data points (metrics).
|
||||
- **Data tools**: Read real-time point values, query historical data, and send read/write commands to devices.
|
||||
|
||||
Guidelines:
|
||||
- Always confirm before sending write commands to physical devices.
|
||||
- Present data in a clear, structured format.
|
||||
- If a query fails, explain the error and suggest alternatives.
|
||||
- Use the tools to fetch real data rather than making up values.
|
||||
""";
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ChatMemory agenticChatMemory(ChatMemoryRepository chatMemoryRepository, AgenticProperties properties) {
|
||||
return MessageWindowChatMemory.builder()
|
||||
.chatMemoryRepository(chatMemoryRepository)
|
||||
.maxMessages(properties.getMemoryMaxMessages())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ChatClient agenticChatClient(ChatClient.Builder builder, AuthToolSet authToolSet,
|
||||
ManagerToolSet managerToolSet, DataToolSet dataToolSet, ChatMemory agenticChatMemory,
|
||||
SkillRegistry skillRegistry) {
|
||||
return builder.defaultSystem(SYSTEM_PROMPT)
|
||||
.defaultTools(authToolSet, managerToolSet, dataToolSet)
|
||||
.defaultAdvisors(MessageChatMemoryAdvisor.builder(agenticChatMemory).build())
|
||||
.build();
|
||||
}
|
||||
@Bean
|
||||
public ChatClient agenticChatClient(ChatClient.Builder builder, AuthToolSet authToolSet,
|
||||
ManagerToolSet managerToolSet, DataToolSet dataToolSet, ChatMemory agenticChatMemory,
|
||||
SkillRegistry skillRegistry) {
|
||||
return builder.defaultSystem(SYSTEM_PROMPT)
|
||||
.defaultTools(authToolSet, managerToolSet, dataToolSet)
|
||||
.defaultAdvisors(MessageChatMemoryAdvisor.builder(agenticChatMemory).build())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-12
@@ -21,20 +21,20 @@ package io.github.pnoker.common.agentic.constant;
|
||||
*/
|
||||
public class AgenticConstant {
|
||||
|
||||
public static final String SERVICE_NAME = "dc3-center-agentic";
|
||||
public static final String SERVICE_NAME = "dc3-center-agentic";
|
||||
|
||||
/**
|
||||
* URL prefix for the chat REST API. Gateway: /api/v3/agentic/chat/** →
|
||||
* agentic:8600/agentic/chat/**
|
||||
*/
|
||||
public static final String CHAT_URL_PREFIX = "/chat";
|
||||
/**
|
||||
* URL prefix for the chat REST API. Gateway: /api/v3/agentic/chat/** →
|
||||
* agentic:8600/agentic/chat/**
|
||||
*/
|
||||
public static final String CHAT_URL_PREFIX = "/chat";
|
||||
|
||||
/**
|
||||
* URL prefix for the session REST API.
|
||||
*/
|
||||
public static final String SESSION_URL_PREFIX = "/session";
|
||||
/**
|
||||
* URL prefix for the session REST API.
|
||||
*/
|
||||
public static final String SESSION_URL_PREFIX = "/session";
|
||||
|
||||
private AgenticConstant() {
|
||||
}
|
||||
private AgenticConstant() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+145
-147
@@ -51,175 +51,173 @@ import java.util.UUID;
|
||||
@RequestMapping(AgenticConstant.CHAT_URL_PREFIX)
|
||||
public class ChatController implements BaseController {
|
||||
|
||||
private final ChatClient chatClient;
|
||||
private final ChatClient chatClient;
|
||||
|
||||
private final SkillRegistry skillRegistry;
|
||||
private final SkillRegistry skillRegistry;
|
||||
|
||||
private final SessionService sessionService;
|
||||
private final SessionService sessionService;
|
||||
|
||||
public ChatController(ChatClient chatClient, SkillRegistry skillRegistry, SessionService sessionService) {
|
||||
this.chatClient = chatClient;
|
||||
this.skillRegistry = skillRegistry;
|
||||
this.sessionService = sessionService;
|
||||
}
|
||||
public ChatController(ChatClient chatClient, SkillRegistry skillRegistry, SessionService sessionService) {
|
||||
this.chatClient = chatClient;
|
||||
this.skillRegistry = skillRegistry;
|
||||
this.sessionService = sessionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Streaming chat completion — returns SSE events in OpenAI chunk format. Activated
|
||||
* when {@code request.stream == true}.
|
||||
*/
|
||||
@PostMapping(value = "/completions", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public Flux<ServerSentEvent<String>> streamChatCompletion(@RequestBody ChatCompletionRequest request) {
|
||||
log.debug("Stream chat request: model={}, messages={}, conversationId={}, skill={}", request.getModel(),
|
||||
request.getMessages().size(), request.getConversationId(), request.getSkill());
|
||||
/**
|
||||
* Streaming chat completion — returns SSE events in OpenAI chunk format. Activated
|
||||
* when {@code request.stream == true}.
|
||||
*/
|
||||
@PostMapping(value = "/completions", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public Flux<ServerSentEvent<String>> streamChatCompletion(@RequestBody ChatCompletionRequest request) {
|
||||
log.debug("Stream chat request: model={}, messages={}, conversationId={}, skill={}", request.getModel(),
|
||||
request.getMessages().size(), request.getConversationId(), request.getSkill());
|
||||
|
||||
String userMessage = extractLastUserMessage(request);
|
||||
String conversationId = resolveConversationId(request);
|
||||
String systemAddition = resolveSkillSystemPrompt(request);
|
||||
String userMessage = extractLastUserMessage(request);
|
||||
String conversationId = resolveConversationId(request);
|
||||
String systemAddition = resolveSkillSystemPrompt(request);
|
||||
|
||||
touchSession(conversationId, request);
|
||||
touchSession(conversationId, request);
|
||||
|
||||
var promptSpec = chatClient.prompt()
|
||||
.user(userMessage)
|
||||
.advisors(advisor -> advisor.param(ChatMemory.CONVERSATION_ID, conversationId));
|
||||
if (systemAddition != null) {
|
||||
promptSpec = promptSpec.system(systemAddition);
|
||||
}
|
||||
var promptSpec = chatClient.prompt()
|
||||
.user(userMessage)
|
||||
.advisors(advisor -> advisor.param(ChatMemory.CONVERSATION_ID, conversationId));
|
||||
if (systemAddition != null) {
|
||||
promptSpec = promptSpec.system(systemAddition);
|
||||
}
|
||||
|
||||
Flux<String> contentFlux = promptSpec.stream().content();
|
||||
Flux<String> contentFlux = promptSpec.stream().content();
|
||||
|
||||
String chatId = "chatcmpl-" + UUID.randomUUID().toString().replace("-", "").substring(0, 24);
|
||||
long created = Instant.now().getEpochSecond();
|
||||
String model = request.getModel() != null ? request.getModel() : "dc3-agentic";
|
||||
String chatId = "chatcmpl-" + UUID.randomUUID().toString().replace("-", "").substring(0, 24);
|
||||
long created = Instant.now().getEpochSecond();
|
||||
String model = request.getModel() != null ? request.getModel() : "dc3-agentic";
|
||||
|
||||
return contentFlux
|
||||
.map(chunk -> ServerSentEvent.<String>builder().data(formatChunk(chatId, created, model, chunk)).build())
|
||||
.concatWith(
|
||||
Mono.just(ServerSentEvent.<String>builder().data(formatFinalChunk(chatId, created, model)).build()))
|
||||
.concatWith(Mono.just(ServerSentEvent.<String>builder().data("[DONE]").build()));
|
||||
}
|
||||
return contentFlux
|
||||
.map(chunk -> ServerSentEvent.<String>builder().data(formatChunk(chatId, created, model, chunk)).build())
|
||||
.concatWith(
|
||||
Mono.just(ServerSentEvent.<String>builder().data(formatFinalChunk(chatId, created, model)).build()))
|
||||
.concatWith(Mono.just(ServerSentEvent.<String>builder().data("[DONE]").build()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-streaming chat completion — returns a single JSON response. Activated when
|
||||
* {@code request.stream == false} or omitted.
|
||||
*/
|
||||
@PostMapping(value = "/completions", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Mono<ChatCompletionResponse> chatCompletion(@RequestBody ChatCompletionRequest request) {
|
||||
log.debug("Chat request: model={}, messages={}, conversationId={}, skill={}", request.getModel(),
|
||||
request.getMessages().size(), request.getConversationId(), request.getSkill());
|
||||
/**
|
||||
* Non-streaming chat completion — returns a single JSON response. Activated when
|
||||
* {@code request.stream == false} or omitted.
|
||||
*/
|
||||
@PostMapping(value = "/completions", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Mono<ChatCompletionResponse> chatCompletion(@RequestBody ChatCompletionRequest request) {
|
||||
log.debug("Chat request: model={}, messages={}, conversationId={}, skill={}", request.getModel(),
|
||||
request.getMessages().size(), request.getConversationId(), request.getSkill());
|
||||
|
||||
String userMessage = extractLastUserMessage(request);
|
||||
String conversationId = resolveConversationId(request);
|
||||
String systemAddition = resolveSkillSystemPrompt(request);
|
||||
String userMessage = extractLastUserMessage(request);
|
||||
String conversationId = resolveConversationId(request);
|
||||
String systemAddition = resolveSkillSystemPrompt(request);
|
||||
|
||||
touchSession(conversationId, request);
|
||||
touchSession(conversationId, request);
|
||||
|
||||
return Mono.fromCallable(() -> {
|
||||
var promptSpec = chatClient.prompt()
|
||||
.user(userMessage)
|
||||
.advisors(advisor -> advisor.param(ChatMemory.CONVERSATION_ID, conversationId));
|
||||
if (systemAddition != null) {
|
||||
promptSpec = promptSpec.system(systemAddition);
|
||||
}
|
||||
return Mono.fromCallable(() -> {
|
||||
var promptSpec = chatClient.prompt()
|
||||
.user(userMessage)
|
||||
.advisors(advisor -> advisor.param(ChatMemory.CONVERSATION_ID, conversationId));
|
||||
if (systemAddition != null) {
|
||||
promptSpec = promptSpec.system(systemAddition);
|
||||
}
|
||||
|
||||
String content = promptSpec.call().content();
|
||||
String content = promptSpec.call().content();
|
||||
|
||||
String chatId = "chatcmpl-" + UUID.randomUUID().toString().replace("-", "").substring(0, 24);
|
||||
return ChatCompletionResponse.builder()
|
||||
.id(chatId)
|
||||
.object("chat.completion")
|
||||
.created(Instant.now().getEpochSecond())
|
||||
.model(request.getModel() != null ? request.getModel() : "dc3-agentic")
|
||||
.choices(List.of(ChatCompletionResponse.Choice.builder()
|
||||
.index(0)
|
||||
.message(new ChatCompletionResponse.Message("assistant", content))
|
||||
.finishReason("stop")
|
||||
.build()))
|
||||
.usage(new ChatCompletionResponse.Usage(0, 0, 0))
|
||||
.build();
|
||||
});
|
||||
}
|
||||
String chatId = "chatcmpl-" + UUID.randomUUID().toString().replace("-", "").substring(0, 24);
|
||||
return ChatCompletionResponse.builder()
|
||||
.id(chatId)
|
||||
.object("chat.completion")
|
||||
.created(Instant.now().getEpochSecond())
|
||||
.model(request.getModel() != null ? request.getModel() : "dc3-agentic")
|
||||
.choices(List.of(ChatCompletionResponse.Choice.builder()
|
||||
.index(0)
|
||||
.message(new ChatCompletionResponse.Message("assistant", content))
|
||||
.finishReason("stop")
|
||||
.build()))
|
||||
.usage(new ChatCompletionResponse.Usage(0, 0, 0))
|
||||
.build();
|
||||
});
|
||||
}
|
||||
|
||||
private String extractLastUserMessage(ChatCompletionRequest request) {
|
||||
if (request.getMessages() == null || request.getMessages().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return request.getMessages()
|
||||
.stream()
|
||||
.filter(m -> "user".equals(m.getRole()))
|
||||
.reduce((first, second) -> second)
|
||||
.map(m -> m.getContent())
|
||||
.orElse("");
|
||||
}
|
||||
private String extractLastUserMessage(ChatCompletionRequest request) {
|
||||
if (request.getMessages() == null || request.getMessages().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return request.getMessages()
|
||||
.stream()
|
||||
.filter(m -> "user".equals(m.getRole()))
|
||||
.reduce((first, second) -> second)
|
||||
.map(m -> m.getContent())
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
private String resolveConversationId(ChatCompletionRequest request) {
|
||||
return request.getConversationId() != null ? request.getConversationId() : UUID.randomUUID().toString();
|
||||
}
|
||||
private String resolveConversationId(ChatCompletionRequest request) {
|
||||
return request.getConversationId() != null ? request.getConversationId() : UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the skill-specific system prompt addition for the given request. Returns
|
||||
* {@code null} when no skill is specified or the skill has no addition.
|
||||
*/
|
||||
private String resolveSkillSystemPrompt(ChatCompletionRequest request) {
|
||||
String skillName = request.getSkill();
|
||||
if (skillName == null) {
|
||||
return null;
|
||||
}
|
||||
SkillDefinition skill = skillRegistry.get(skillName);
|
||||
if (skill == null) {
|
||||
log.warn("Requested skill '{}' not found in registry", skillName);
|
||||
return null;
|
||||
}
|
||||
log.info("Activating skill: {} — {}", skill.getName(), skill.getDescription());
|
||||
return skill.getSystemPromptAddition();
|
||||
}
|
||||
/**
|
||||
* Resolve the skill-specific system prompt addition for the given request. Returns
|
||||
* {@code null} when no skill is specified or the skill has no addition.
|
||||
*/
|
||||
private String resolveSkillSystemPrompt(ChatCompletionRequest request) {
|
||||
String skillName = request.getSkill();
|
||||
if (skillName == null) {
|
||||
return null;
|
||||
}
|
||||
SkillDefinition skill = skillRegistry.get(skillName);
|
||||
if (skill == null) {
|
||||
log.warn("Requested skill '{}' not found in registry", skillName);
|
||||
return null;
|
||||
}
|
||||
log.info("Activating skill: {} — {}", skill.getName(), skill.getDescription());
|
||||
return skill.getSystemPromptAddition();
|
||||
}
|
||||
|
||||
private String formatChunk(String id, long created, String model, String content) {
|
||||
ChatCompletionChunkResponse chunk = ChatCompletionChunkResponse.builder()
|
||||
.id(id)
|
||||
.object("chat.completion.chunk")
|
||||
.created(created)
|
||||
.model(model)
|
||||
.choices(List.of(ChatCompletionChunkResponse.ChunkChoice.builder()
|
||||
.index(0)
|
||||
.delta(new ChatCompletionChunkResponse.Delta(null, content))
|
||||
.finishReason(null)
|
||||
.build()))
|
||||
.build();
|
||||
return toJson(chunk);
|
||||
}
|
||||
private String formatChunk(String id, long created, String model, String content) {
|
||||
ChatCompletionChunkResponse chunk = ChatCompletionChunkResponse.builder()
|
||||
.id(id)
|
||||
.object("chat.completion.chunk")
|
||||
.created(created)
|
||||
.model(model)
|
||||
.choices(List.of(ChatCompletionChunkResponse.ChunkChoice.builder()
|
||||
.index(0)
|
||||
.delta(new ChatCompletionChunkResponse.Delta(null, content))
|
||||
.finishReason(null)
|
||||
.build()))
|
||||
.build();
|
||||
return toJson(chunk);
|
||||
}
|
||||
|
||||
private String formatFinalChunk(String id, long created, String model) {
|
||||
ChatCompletionChunkResponse chunk = ChatCompletionChunkResponse.builder()
|
||||
.id(id)
|
||||
.object("chat.completion.chunk")
|
||||
.created(created)
|
||||
.model(model)
|
||||
.choices(List.of(ChatCompletionChunkResponse.ChunkChoice.builder()
|
||||
.index(0)
|
||||
.delta(new ChatCompletionChunkResponse.Delta(null, null))
|
||||
.finishReason("stop")
|
||||
.build()))
|
||||
.build();
|
||||
return toJson(chunk);
|
||||
}
|
||||
private String formatFinalChunk(String id, long created, String model) {
|
||||
ChatCompletionChunkResponse chunk = ChatCompletionChunkResponse.builder()
|
||||
.id(id)
|
||||
.object("chat.completion.chunk")
|
||||
.created(created)
|
||||
.model(model)
|
||||
.choices(List.of(ChatCompletionChunkResponse.ChunkChoice.builder()
|
||||
.index(0)
|
||||
.delta(new ChatCompletionChunkResponse.Delta(null, null))
|
||||
.finishReason("stop")
|
||||
.build()))
|
||||
.build();
|
||||
return toJson(chunk);
|
||||
}
|
||||
|
||||
private String toJson(Object obj) {
|
||||
try {
|
||||
return com.fasterxml.jackson.databind.json.JsonMapper.builder().build().writeValueAsString(obj);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to serialize response", e);
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
private String toJson(Object obj) {
|
||||
try {
|
||||
return com.fasterxml.jackson.databind.json.JsonMapper.builder().build().writeValueAsString(obj);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to serialize response", e);
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
|
||||
private void touchSession(String conversationId, ChatCompletionRequest request) {
|
||||
try {
|
||||
sessionService.touch(conversationId, request.getSkill());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.warn("Failed to touch session for {}: {}", conversationId, e.getMessage());
|
||||
}
|
||||
}
|
||||
private void touchSession(String conversationId, ChatCompletionRequest request) {
|
||||
try {
|
||||
sessionService.touch(conversationId, request.getSkill());
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to touch session for {}: {}", conversationId, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+39
-42
@@ -34,52 +34,49 @@ import reactor.core.publisher.Mono;
|
||||
@RequestMapping(AgenticConstant.SESSION_URL_PREFIX)
|
||||
public class SessionController implements BaseController {
|
||||
|
||||
private final SessionService sessionService;
|
||||
private final SessionService sessionService;
|
||||
|
||||
private final SessionBuilder sessionBuilder;
|
||||
private final SessionBuilder sessionBuilder;
|
||||
|
||||
public SessionController(SessionService sessionService, SessionBuilder sessionBuilder) {
|
||||
this.sessionService = sessionService;
|
||||
this.sessionBuilder = sessionBuilder;
|
||||
}
|
||||
public SessionController(SessionService sessionService, SessionBuilder sessionBuilder) {
|
||||
this.sessionService = sessionService;
|
||||
this.sessionBuilder = sessionBuilder;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Mono<R<Page<SessionVO>>> list(SessionQuery query) {
|
||||
try {
|
||||
Page<SessionBO> page = sessionService.selectByPage(query);
|
||||
return Mono.just(R.ok(sessionBuilder.buildVOPageByBOPage(page)));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping
|
||||
public Mono<R<Page<SessionVO>>> list(SessionQuery query) {
|
||||
try {
|
||||
Page<SessionBO> page = sessionService.selectByPage(query);
|
||||
return Mono.just(R.ok(sessionBuilder.buildVOPageByBOPage(page)));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/{conversationId}")
|
||||
public Mono<R<SessionVO>> get(@PathVariable String conversationId) {
|
||||
try {
|
||||
SessionBO session = sessionService.getByConversationId(conversationId);
|
||||
if (session == null) {
|
||||
return Mono.just(R.fail("Session not found"));
|
||||
}
|
||||
return Mono.just(R.ok(sessionBuilder.buildVOByBO(session)));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/{conversationId}")
|
||||
public Mono<R<SessionVO>> get(@PathVariable String conversationId) {
|
||||
try {
|
||||
SessionBO session = sessionService.getByConversationId(conversationId);
|
||||
if (session == null) {
|
||||
return Mono.just(R.fail("Session not found"));
|
||||
}
|
||||
return Mono.just(R.ok(sessionBuilder.buildVOByBO(session)));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{conversationId}")
|
||||
public Mono<R<Boolean>> delete(@PathVariable String conversationId) {
|
||||
try {
|
||||
sessionService.removeByConversationId(conversationId);
|
||||
return Mono.just(R.ok());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@DeleteMapping("/{conversationId}")
|
||||
public Mono<R<Boolean>> delete(@PathVariable String conversationId) {
|
||||
try {
|
||||
sessionService.removeByConversationId(conversationId);
|
||||
return Mono.just(R.ok());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -28,20 +28,20 @@ import java.time.LocalDateTime;
|
||||
@ToString(callSuper = true)
|
||||
public class SessionBO extends BaseBO {
|
||||
|
||||
private String conversationId;
|
||||
private String conversationId;
|
||||
|
||||
private String title;
|
||||
private String title;
|
||||
|
||||
private String skill;
|
||||
private String skill;
|
||||
|
||||
private Byte status;
|
||||
private Byte status;
|
||||
|
||||
private LocalDateTime expireTime;
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
private Long tenantId;
|
||||
private Long tenantId;
|
||||
|
||||
private Long userId;
|
||||
private Long userId;
|
||||
|
||||
private Byte enableFlag;
|
||||
private Byte enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+24
-24
@@ -26,40 +26,40 @@ import org.mapstruct.Mapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface SessionBuilder {
|
||||
|
||||
SessionBO buildBOByVO(SessionVO entityVO);
|
||||
SessionBO buildBOByVO(SessionVO entityVO);
|
||||
|
||||
List<SessionBO> buildBOListByVOList(List<SessionVO> entityVOList);
|
||||
List<SessionBO> buildBOListByVOList(List<SessionVO> entityVOList);
|
||||
|
||||
SessionVO buildVOByBO(SessionBO entityBO);
|
||||
SessionVO buildVOByBO(SessionBO entityBO);
|
||||
|
||||
List<SessionVO> buildVOListByBOList(List<SessionBO> entityBOList);
|
||||
List<SessionVO> buildVOListByBOList(List<SessionBO> entityBOList);
|
||||
|
||||
SessionBO buildBOByDO(SessionDO entityDO);
|
||||
SessionBO buildBOByDO(SessionDO entityDO);
|
||||
|
||||
List<SessionBO> buildBOListByDOList(List<SessionDO> entityDOList);
|
||||
List<SessionBO> buildBOListByDOList(List<SessionDO> entityDOList);
|
||||
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
SessionDO buildDOByBO(SessionBO entityBO);
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
SessionDO buildDOByBO(SessionBO entityBO);
|
||||
|
||||
List<SessionDO> buildDOListByBOList(List<SessionBO> entityBOList);
|
||||
List<SessionDO> buildDOListByBOList(List<SessionBO> entityBOList);
|
||||
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<SessionVO> buildVOPageByBOPage(Page<SessionBO> entityPageBO);
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<SessionVO> buildVOPageByBOPage(Page<SessionBO> entityPageBO);
|
||||
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<SessionBO> buildBOPageByDOPage(Page<SessionDO> entityPageDO);
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<SessionBO> buildBOPageByDOPage(Page<SessionDO> entityPageDO);
|
||||
|
||||
}
|
||||
|
||||
+37
-37
@@ -31,59 +31,59 @@ import java.time.LocalDateTime;
|
||||
@TableName("dc3_session")
|
||||
public class SessionDO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@TableField("conversation_id")
|
||||
private String conversationId;
|
||||
@TableField("conversation_id")
|
||||
private String conversationId;
|
||||
|
||||
@TableField("title")
|
||||
private String title;
|
||||
@TableField("title")
|
||||
private String title;
|
||||
|
||||
@TableField("skill")
|
||||
private String skill;
|
||||
@TableField("skill")
|
||||
private String skill;
|
||||
|
||||
@TableField("status")
|
||||
private Byte status;
|
||||
@TableField("status")
|
||||
private Byte status;
|
||||
|
||||
@TableField("expire_time")
|
||||
private LocalDateTime expireTime;
|
||||
@TableField("expire_time")
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
@TableField("tenant_id")
|
||||
private Long tenantId;
|
||||
@TableField("tenant_id")
|
||||
private Long tenantId;
|
||||
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
@TableField("enable_flag")
|
||||
private Byte enableFlag;
|
||||
@TableField("enable_flag")
|
||||
private Byte enableFlag;
|
||||
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
@TableField("creator_id")
|
||||
private Long creatorId;
|
||||
@TableField("creator_id")
|
||||
private Long creatorId;
|
||||
|
||||
@TableField("creator_name")
|
||||
private String creatorName;
|
||||
@TableField("creator_name")
|
||||
private String creatorName;
|
||||
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("operator_id")
|
||||
private Long operatorId;
|
||||
@TableField("operator_id")
|
||||
private Long operatorId;
|
||||
|
||||
@TableField("operator_name")
|
||||
private String operatorName;
|
||||
@TableField("operator_name")
|
||||
private String operatorName;
|
||||
|
||||
@TableField("operate_time")
|
||||
private LocalDateTime operateTime;
|
||||
@TableField("operate_time")
|
||||
private LocalDateTime operateTime;
|
||||
|
||||
@TableLogic
|
||||
@TableField("deleted")
|
||||
private Byte deleted;
|
||||
@TableLogic
|
||||
@TableField("deleted")
|
||||
private Byte deleted;
|
||||
|
||||
}
|
||||
|
||||
+7
-7
@@ -30,17 +30,17 @@ import java.io.Serializable;
|
||||
@AllArgsConstructor
|
||||
public class SessionQuery implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Pages page;
|
||||
private Pages page;
|
||||
|
||||
private Long tenantId;
|
||||
private Long tenantId;
|
||||
|
||||
private Long userId;
|
||||
private Long userId;
|
||||
|
||||
private Byte status;
|
||||
private Byte status;
|
||||
|
||||
private String conversationId;
|
||||
private String conversationId;
|
||||
|
||||
}
|
||||
|
||||
+32
-32
@@ -35,44 +35,44 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class ChatCompletionRequest {
|
||||
|
||||
/**
|
||||
* Model identifier (advisory — the actual model is configured server-side).
|
||||
*/
|
||||
private String model;
|
||||
/**
|
||||
* Model identifier (advisory — the actual model is configured server-side).
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* Conversation messages in chronological order.
|
||||
*/
|
||||
private List<ChatMessageDTO> messages;
|
||||
/**
|
||||
* Conversation messages in chronological order.
|
||||
*/
|
||||
private List<ChatMessageDTO> messages;
|
||||
|
||||
/**
|
||||
* Sampling temperature override (0.0–2.0). Null uses the server default.
|
||||
*/
|
||||
private Double temperature;
|
||||
/**
|
||||
* Sampling temperature override (0.0–2.0). Null uses the server default.
|
||||
*/
|
||||
private Double temperature;
|
||||
|
||||
/**
|
||||
* Maximum tokens to generate. Null uses the server default.
|
||||
*/
|
||||
private Integer maxTokens;
|
||||
/**
|
||||
* Maximum tokens to generate. Null uses the server default.
|
||||
*/
|
||||
private Integer maxTokens;
|
||||
|
||||
/**
|
||||
* Whether to stream the response as SSE events.
|
||||
*/
|
||||
private Boolean stream;
|
||||
/**
|
||||
* Whether to stream the response as SSE events.
|
||||
*/
|
||||
private Boolean stream;
|
||||
|
||||
/**
|
||||
* Conversation ID for chat memory correlation. If omitted, a new conversation is
|
||||
* started each request.
|
||||
*/
|
||||
private String conversationId;
|
||||
/**
|
||||
* Conversation ID for chat memory correlation. If omitted, a new conversation is
|
||||
* started each request.
|
||||
*/
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* Skill name to activate for this request. Null = all tools available.
|
||||
*/
|
||||
private String skill;
|
||||
/**
|
||||
* Skill name to activate for this request. Null = all tools available.
|
||||
*/
|
||||
private String skill;
|
||||
|
||||
public boolean isStream() {
|
||||
return Boolean.TRUE.equals(stream);
|
||||
}
|
||||
public boolean isStream() {
|
||||
return Boolean.TRUE.equals(stream);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -30,14 +30,14 @@ import lombok.Setter;
|
||||
@AllArgsConstructor
|
||||
public class ChatMessageDTO {
|
||||
|
||||
/**
|
||||
* Message role: "system", "user", "assistant", or "tool".
|
||||
*/
|
||||
private String role;
|
||||
/**
|
||||
* Message role: "system", "user", "assistant", or "tool".
|
||||
*/
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* Message content text.
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* Message content text.
|
||||
*/
|
||||
private String content;
|
||||
|
||||
}
|
||||
|
||||
+25
-25
@@ -36,43 +36,43 @@ import java.util.List;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ChatCompletionChunkResponse {
|
||||
|
||||
private String id;
|
||||
private String id;
|
||||
|
||||
private String object;
|
||||
private String object;
|
||||
|
||||
private long created;
|
||||
private long created;
|
||||
|
||||
private String model;
|
||||
private String model;
|
||||
|
||||
private List<ChunkChoice> choices;
|
||||
private List<ChunkChoice> choices;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class ChunkChoice {
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class ChunkChoice {
|
||||
|
||||
private int index;
|
||||
private int index;
|
||||
|
||||
private Delta delta;
|
||||
private Delta delta;
|
||||
|
||||
@JsonProperty("finish_reason")
|
||||
private String finishReason;
|
||||
@JsonProperty("finish_reason")
|
||||
private String finishReason;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class Delta {
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class Delta {
|
||||
|
||||
private String role;
|
||||
private String role;
|
||||
|
||||
private String content;
|
||||
private String content;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+33
-33
@@ -35,57 +35,57 @@ import java.util.List;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ChatCompletionResponse {
|
||||
|
||||
private String id;
|
||||
private String id;
|
||||
|
||||
private String object;
|
||||
private String object;
|
||||
|
||||
private long created;
|
||||
private long created;
|
||||
|
||||
private String model;
|
||||
private String model;
|
||||
|
||||
private List<Choice> choices;
|
||||
private List<Choice> choices;
|
||||
|
||||
private Usage usage;
|
||||
private Usage usage;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class Choice {
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class Choice {
|
||||
|
||||
private int index;
|
||||
private int index;
|
||||
|
||||
private Message message;
|
||||
private Message message;
|
||||
|
||||
private String finishReason;
|
||||
private String finishReason;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Message {
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Message {
|
||||
|
||||
private String role;
|
||||
private String role;
|
||||
|
||||
private String content;
|
||||
private String content;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Usage {
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Usage {
|
||||
|
||||
private int promptTokens;
|
||||
private int promptTokens;
|
||||
|
||||
private int completionTokens;
|
||||
private int completionTokens;
|
||||
|
||||
private int totalTokens;
|
||||
private int totalTokens;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -30,20 +30,20 @@ import java.time.LocalDateTime;
|
||||
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
|
||||
public class SessionVO extends BaseVO {
|
||||
|
||||
private String conversationId;
|
||||
private String conversationId;
|
||||
|
||||
private String title;
|
||||
private String title;
|
||||
|
||||
private String skill;
|
||||
private String skill;
|
||||
|
||||
private Byte status;
|
||||
private Byte status;
|
||||
|
||||
private LocalDateTime expireTime;
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
private Long tenantId;
|
||||
private Long tenantId;
|
||||
|
||||
private Long userId;
|
||||
private Long userId;
|
||||
|
||||
private Byte enableFlag;
|
||||
private Byte enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+30
-26
@@ -22,34 +22,38 @@ import io.github.pnoker.common.agentic.entity.query.SessionQuery;
|
||||
|
||||
public interface SessionService {
|
||||
|
||||
/**
|
||||
* Create a new session if one does not exist for the given conversation ID. If a
|
||||
* session already exists, update its operate_time.
|
||||
* @param conversationId conversation ID
|
||||
* @param skill active skill name (may be null)
|
||||
* @return the session BO
|
||||
*/
|
||||
SessionBO touch(String conversationId, String skill);
|
||||
/**
|
||||
* Create a new session if one does not exist for the given conversation ID. If a
|
||||
* session already exists, update its operate_time.
|
||||
*
|
||||
* @param conversationId conversation ID
|
||||
* @param skill active skill name (may be null)
|
||||
* @return the session BO
|
||||
*/
|
||||
SessionBO touch(String conversationId, String skill);
|
||||
|
||||
/**
|
||||
* Get session by conversation ID.
|
||||
* @param conversationId conversation ID
|
||||
* @return session BO or null
|
||||
*/
|
||||
SessionBO getByConversationId(String conversationId);
|
||||
/**
|
||||
* Get session by conversation ID.
|
||||
*
|
||||
* @param conversationId conversation ID
|
||||
* @return session BO or null
|
||||
*/
|
||||
SessionBO getByConversationId(String conversationId);
|
||||
|
||||
/**
|
||||
* Delete session by conversation ID (logical delete) and clear associated chat
|
||||
* memory.
|
||||
* @param conversationId conversation ID
|
||||
*/
|
||||
void removeByConversationId(String conversationId);
|
||||
/**
|
||||
* Delete session by conversation ID (logical delete) and clear associated chat
|
||||
* memory.
|
||||
*
|
||||
* @param conversationId conversation ID
|
||||
*/
|
||||
void removeByConversationId(String conversationId);
|
||||
|
||||
/**
|
||||
* Query sessions with pagination.
|
||||
* @param query query parameters
|
||||
* @return paginated results
|
||||
*/
|
||||
Page<SessionBO> selectByPage(SessionQuery query);
|
||||
/**
|
||||
* Query sessions with pagination.
|
||||
*
|
||||
* @param query query parameters
|
||||
* @return paginated results
|
||||
*/
|
||||
Page<SessionBO> selectByPage(SessionQuery query);
|
||||
|
||||
}
|
||||
|
||||
+62
-62
@@ -38,76 +38,76 @@ import java.util.Objects;
|
||||
@Service
|
||||
public class SessionServiceImpl implements SessionService {
|
||||
|
||||
@Resource
|
||||
private SessionBuilder sessionBuilder;
|
||||
@Resource
|
||||
private SessionBuilder sessionBuilder;
|
||||
|
||||
@Resource
|
||||
private SessionManager sessionManager;
|
||||
@Resource
|
||||
private SessionManager sessionManager;
|
||||
|
||||
@Resource
|
||||
private ChatMemory agenticChatMemory;
|
||||
@Resource
|
||||
private ChatMemory agenticChatMemory;
|
||||
|
||||
@Override
|
||||
public SessionBO touch(String conversationId, String skill) {
|
||||
SessionDO existing = findByConversationId(conversationId);
|
||||
if (existing != null) {
|
||||
if (StringUtils.isNotEmpty(skill)) {
|
||||
existing.setSkill(skill);
|
||||
}
|
||||
sessionManager.updateById(existing);
|
||||
return sessionBuilder.buildBOByDO(existing);
|
||||
}
|
||||
@Override
|
||||
public SessionBO touch(String conversationId, String skill) {
|
||||
SessionDO existing = findByConversationId(conversationId);
|
||||
if (existing != null) {
|
||||
if (StringUtils.isNotEmpty(skill)) {
|
||||
existing.setSkill(skill);
|
||||
}
|
||||
sessionManager.updateById(existing);
|
||||
return sessionBuilder.buildBOByDO(existing);
|
||||
}
|
||||
|
||||
SessionDO entityDO = new SessionDO();
|
||||
entityDO.setConversationId(conversationId);
|
||||
entityDO.setTitle("New Conversation");
|
||||
entityDO.setSkill(StringUtils.defaultString(skill, ""));
|
||||
entityDO.setStatus((byte) 0);
|
||||
entityDO.setEnableFlag((byte) 0);
|
||||
sessionManager.save(entityDO);
|
||||
return sessionBuilder.buildBOByDO(entityDO);
|
||||
}
|
||||
SessionDO entityDO = new SessionDO();
|
||||
entityDO.setConversationId(conversationId);
|
||||
entityDO.setTitle("New Conversation");
|
||||
entityDO.setSkill(StringUtils.defaultString(skill, ""));
|
||||
entityDO.setStatus((byte) 0);
|
||||
entityDO.setEnableFlag((byte) 0);
|
||||
sessionManager.save(entityDO);
|
||||
return sessionBuilder.buildBOByDO(entityDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionBO getByConversationId(String conversationId) {
|
||||
SessionDO entityDO = findByConversationId(conversationId);
|
||||
return entityDO != null ? sessionBuilder.buildBOByDO(entityDO) : null;
|
||||
}
|
||||
@Override
|
||||
public SessionBO getByConversationId(String conversationId) {
|
||||
SessionDO entityDO = findByConversationId(conversationId);
|
||||
return entityDO != null ? sessionBuilder.buildBOByDO(entityDO) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByConversationId(String conversationId) {
|
||||
SessionDO entityDO = findByConversationId(conversationId);
|
||||
if (entityDO != null) {
|
||||
sessionManager.removeById(entityDO.getId());
|
||||
agenticChatMemory.clear(conversationId);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void removeByConversationId(String conversationId) {
|
||||
SessionDO entityDO = findByConversationId(conversationId);
|
||||
if (entityDO != null) {
|
||||
sessionManager.removeById(entityDO.getId());
|
||||
agenticChatMemory.clear(conversationId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SessionBO> selectByPage(SessionQuery query) {
|
||||
if (Objects.isNull(query.getPage())) {
|
||||
query.setPage(new io.github.pnoker.common.entity.common.Pages());
|
||||
}
|
||||
Page<SessionDO> entityPageDO = sessionManager.page(PageUtil.page(query.getPage()), fuzzyQuery(query));
|
||||
return sessionBuilder.buildBOPageByDOPage(entityPageDO);
|
||||
}
|
||||
@Override
|
||||
public Page<SessionBO> selectByPage(SessionQuery query) {
|
||||
if (Objects.isNull(query.getPage())) {
|
||||
query.setPage(new io.github.pnoker.common.entity.common.Pages());
|
||||
}
|
||||
Page<SessionDO> entityPageDO = sessionManager.page(PageUtil.page(query.getPage()), fuzzyQuery(query));
|
||||
return sessionBuilder.buildBOPageByDOPage(entityPageDO);
|
||||
}
|
||||
|
||||
private SessionDO findByConversationId(String conversationId) {
|
||||
LambdaQueryWrapper<SessionDO> wrapper = Wrappers.<SessionDO>query()
|
||||
.lambda()
|
||||
.eq(SessionDO::getConversationId, conversationId)
|
||||
.last("LIMIT 1");
|
||||
return sessionManager.getOne(wrapper);
|
||||
}
|
||||
private SessionDO findByConversationId(String conversationId) {
|
||||
LambdaQueryWrapper<SessionDO> wrapper = Wrappers.<SessionDO>query()
|
||||
.lambda()
|
||||
.eq(SessionDO::getConversationId, conversationId)
|
||||
.last("LIMIT 1");
|
||||
return sessionManager.getOne(wrapper);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SessionDO> fuzzyQuery(SessionQuery query) {
|
||||
LambdaQueryWrapper<SessionDO> wrapper = Wrappers.<SessionDO>query().lambda();
|
||||
wrapper.eq(Objects.nonNull(query.getTenantId()), SessionDO::getTenantId, query.getTenantId());
|
||||
wrapper.eq(Objects.nonNull(query.getUserId()), SessionDO::getUserId, query.getUserId());
|
||||
wrapper.eq(Objects.nonNull(query.getStatus()), SessionDO::getStatus, query.getStatus());
|
||||
wrapper.like(StringUtils.isNotEmpty(query.getConversationId()), SessionDO::getConversationId,
|
||||
query.getConversationId());
|
||||
return wrapper;
|
||||
}
|
||||
private LambdaQueryWrapper<SessionDO> fuzzyQuery(SessionQuery query) {
|
||||
LambdaQueryWrapper<SessionDO> wrapper = Wrappers.<SessionDO>query().lambda();
|
||||
wrapper.eq(Objects.nonNull(query.getTenantId()), SessionDO::getTenantId, query.getTenantId());
|
||||
wrapper.eq(Objects.nonNull(query.getUserId()), SessionDO::getUserId, query.getUserId());
|
||||
wrapper.eq(Objects.nonNull(query.getStatus()), SessionDO::getStatus, query.getStatus());
|
||||
wrapper.like(StringUtils.isNotEmpty(query.getConversationId()), SessionDO::getConversationId,
|
||||
query.getConversationId());
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+41
-41
@@ -36,55 +36,55 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class SkillDefinition {
|
||||
|
||||
/**
|
||||
* Unique skill identifier (matches the YAML filename stem by convention).
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* Unique skill identifier (matches the YAML filename stem by convention).
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Human-readable description of what this skill enables.
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* Human-readable description of what this skill enables.
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Whether the skill is active and should be loaded at startup.
|
||||
*/
|
||||
private boolean enabled;
|
||||
/**
|
||||
* Whether the skill is active and should be loaded at startup.
|
||||
*/
|
||||
private boolean enabled;
|
||||
|
||||
/**
|
||||
* Additional system prompt text injected when this skill is activated.
|
||||
*/
|
||||
private String systemPromptAddition;
|
||||
/**
|
||||
* Additional system prompt text injected when this skill is activated.
|
||||
*/
|
||||
private String systemPromptAddition;
|
||||
|
||||
/**
|
||||
* Names of the Spring AI tools this skill is allowed to use.
|
||||
*/
|
||||
private List<String> tools;
|
||||
/**
|
||||
* Names of the Spring AI tools this skill is allowed to use.
|
||||
*/
|
||||
private List<String> tools;
|
||||
|
||||
/**
|
||||
* Few-shot examples illustrating expected user-assistant interactions.
|
||||
*/
|
||||
private List<SkillExample> examples;
|
||||
/**
|
||||
* Few-shot examples illustrating expected user-assistant interactions.
|
||||
*/
|
||||
private List<SkillExample> examples;
|
||||
|
||||
/**
|
||||
* A single user-assistant exchange used as a few-shot example.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SkillExample {
|
||||
/**
|
||||
* A single user-assistant exchange used as a few-shot example.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SkillExample {
|
||||
|
||||
/**
|
||||
* Example user message.
|
||||
*/
|
||||
private String user;
|
||||
/**
|
||||
* Example user message.
|
||||
*/
|
||||
private String user;
|
||||
|
||||
/**
|
||||
* Example assistant response.
|
||||
*/
|
||||
private String assistant;
|
||||
/**
|
||||
* Example assistant response.
|
||||
*/
|
||||
private String assistant;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+44
-46
@@ -39,59 +39,57 @@ import java.util.Map;
|
||||
@Component
|
||||
public class SkillLoader implements ApplicationRunner {
|
||||
|
||||
private final SkillRegistry registry;
|
||||
private final SkillRegistry registry;
|
||||
|
||||
public SkillLoader(SkillRegistry registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
public SkillLoader(SkillRegistry registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource[] resources = resolver.getResources("classpath*:skills/*.yml");
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource[] resources = resolver.getResources("classpath*:skills/*.yml");
|
||||
|
||||
List<String> loaded = new ArrayList<>();
|
||||
List<String> loaded = new ArrayList<>();
|
||||
|
||||
Yaml yaml = new Yaml();
|
||||
for (Resource resource : resources) {
|
||||
try (InputStreamReader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) {
|
||||
Map<String, Object> map = yaml.load(reader);
|
||||
SkillDefinition skill = mapToSkill(map);
|
||||
if (skill.isEnabled()) {
|
||||
registry.register(skill);
|
||||
loaded.add(skill.getName());
|
||||
}
|
||||
else {
|
||||
log.debug("Skipping disabled skill: {}", skill.getName());
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to load skill from {}: {}", resource.getDescription(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
Yaml yaml = new Yaml();
|
||||
for (Resource resource : resources) {
|
||||
try (InputStreamReader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) {
|
||||
Map<String, Object> map = yaml.load(reader);
|
||||
SkillDefinition skill = mapToSkill(map);
|
||||
if (skill.isEnabled()) {
|
||||
registry.register(skill);
|
||||
loaded.add(skill.getName());
|
||||
} else {
|
||||
log.debug("Skipping disabled skill: {}", skill.getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to load skill from {}: {}", resource.getDescription(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Loaded {} skills: {}", loaded.size(), loaded);
|
||||
}
|
||||
log.info("Loaded {} skills: {}", loaded.size(), loaded);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private SkillDefinition mapToSkill(Map<String, Object> map) {
|
||||
SkillDefinition skill = new SkillDefinition();
|
||||
skill.setName((String) map.get("name"));
|
||||
skill.setDescription((String) map.get("description"));
|
||||
skill.setEnabled(Boolean.TRUE.equals(map.get("enabled")));
|
||||
skill.setSystemPromptAddition((String) map.get("system-prompt-addition"));
|
||||
skill.setTools((List<String>) map.get("tools"));
|
||||
@SuppressWarnings("unchecked")
|
||||
private SkillDefinition mapToSkill(Map<String, Object> map) {
|
||||
SkillDefinition skill = new SkillDefinition();
|
||||
skill.setName((String) map.get("name"));
|
||||
skill.setDescription((String) map.get("description"));
|
||||
skill.setEnabled(Boolean.TRUE.equals(map.get("enabled")));
|
||||
skill.setSystemPromptAddition((String) map.get("system-prompt-addition"));
|
||||
skill.setTools((List<String>) map.get("tools"));
|
||||
|
||||
List<Map<String, String>> exampleMaps = (List<Map<String, String>>) map.get("examples");
|
||||
if (exampleMaps != null) {
|
||||
List<SkillDefinition.SkillExample> examples = new ArrayList<>();
|
||||
for (Map<String, String> ex : exampleMaps) {
|
||||
examples.add(new SkillDefinition.SkillExample(ex.get("user"), ex.get("assistant")));
|
||||
}
|
||||
skill.setExamples(examples);
|
||||
}
|
||||
List<Map<String, String>> exampleMaps = (List<Map<String, String>>) map.get("examples");
|
||||
if (exampleMaps != null) {
|
||||
List<SkillDefinition.SkillExample> examples = new ArrayList<>();
|
||||
for (Map<String, String> ex : exampleMaps) {
|
||||
examples.add(new SkillDefinition.SkillExample(ex.get("user"), ex.get("assistant")));
|
||||
}
|
||||
skill.setExamples(examples);
|
||||
}
|
||||
|
||||
return skill;
|
||||
}
|
||||
return skill;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+43
-39
@@ -27,48 +27,52 @@ import java.util.*;
|
||||
@Component
|
||||
public class SkillRegistry {
|
||||
|
||||
private final Map<String, SkillDefinition> skills = new LinkedHashMap<>();
|
||||
private final Map<String, SkillDefinition> skills = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Register a skill definition. Overwrites any existing skill with the same name.
|
||||
* @param skill the skill to register
|
||||
*/
|
||||
public void register(SkillDefinition skill) {
|
||||
skills.put(skill.getName(), skill);
|
||||
}
|
||||
/**
|
||||
* Register a skill definition. Overwrites any existing skill with the same name.
|
||||
*
|
||||
* @param skill the skill to register
|
||||
*/
|
||||
public void register(SkillDefinition skill) {
|
||||
skills.put(skill.getName(), skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a skill by name.
|
||||
* @param name the skill name
|
||||
* @return the matching skill, or {@code null} if not found
|
||||
*/
|
||||
public SkillDefinition get(String name) {
|
||||
return skills.get(name);
|
||||
}
|
||||
/**
|
||||
* Look up a skill by name.
|
||||
*
|
||||
* @param name the skill name
|
||||
* @return the matching skill, or {@code null} if not found
|
||||
*/
|
||||
public SkillDefinition get(String name) {
|
||||
return skills.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all registered skills in insertion order.
|
||||
* @return unmodifiable collection of all skills
|
||||
*/
|
||||
public Collection<SkillDefinition> all() {
|
||||
return Collections.unmodifiableCollection(skills.values());
|
||||
}
|
||||
/**
|
||||
* Return all registered skills in insertion order.
|
||||
*
|
||||
* @return unmodifiable collection of all skills
|
||||
*/
|
||||
public Collection<SkillDefinition> all() {
|
||||
return Collections.unmodifiableCollection(skills.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tool names associated with the given skill.
|
||||
* <p>
|
||||
* Returns {@code null} (meaning "all tools available") when the skill is not found or
|
||||
* the skill's tool list is empty.
|
||||
* @param skillName the skill to look up
|
||||
* @return list of allowed tool names, or {@code null} for unrestricted
|
||||
*/
|
||||
public List<String> getEnabledToolNames(String skillName) {
|
||||
SkillDefinition skill = skills.get(skillName);
|
||||
if (skill == null) {
|
||||
return null;
|
||||
}
|
||||
List<String> tools = skill.getTools();
|
||||
return (tools == null || tools.isEmpty()) ? null : tools;
|
||||
}
|
||||
/**
|
||||
* Return the tool names associated with the given skill.
|
||||
* <p>
|
||||
* Returns {@code null} (meaning "all tools available") when the skill is not found or
|
||||
* the skill's tool list is empty.
|
||||
*
|
||||
* @param skillName the skill to look up
|
||||
* @return list of allowed tool names, or {@code null} for unrestricted
|
||||
*/
|
||||
public List<String> getEnabledToolNames(String skillName) {
|
||||
SkillDefinition skill = skills.get(skillName);
|
||||
if (skill == null) {
|
||||
return null;
|
||||
}
|
||||
List<String> tools = skill.getTools();
|
||||
return (tools == null || tools.isEmpty()) ? null : tools;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+40
-40
@@ -39,51 +39,51 @@ import java.util.Objects;
|
||||
@Component
|
||||
public class AuthToolSet {
|
||||
|
||||
private final TenantFacade tenantFacade;
|
||||
private final TenantFacade tenantFacade;
|
||||
|
||||
private final UserFacade userFacade;
|
||||
private final UserFacade userFacade;
|
||||
|
||||
private final UserLoginFacade userLoginFacade;
|
||||
private final UserLoginFacade userLoginFacade;
|
||||
|
||||
public AuthToolSet(TenantFacade tenantFacade, UserFacade userFacade, UserLoginFacade userLoginFacade) {
|
||||
this.tenantFacade = tenantFacade;
|
||||
this.userFacade = userFacade;
|
||||
this.userLoginFacade = userLoginFacade;
|
||||
}
|
||||
public AuthToolSet(TenantFacade tenantFacade, UserFacade userFacade, UserLoginFacade userLoginFacade) {
|
||||
this.tenantFacade = tenantFacade;
|
||||
this.userFacade = userFacade;
|
||||
this.userLoginFacade = userLoginFacade;
|
||||
}
|
||||
|
||||
@Tool(description = "Look up a tenant by its unique code. Returns tenant name, code, and enable status.")
|
||||
public String lookupTenantByCode(
|
||||
@ToolParam(description = "The unique tenant code, e.g. 'default'") String tenantCode) {
|
||||
log.debug("Tool: lookupTenantByCode({})", tenantCode);
|
||||
FacadeTenantBO bo = tenantFacade.selectByCode(tenantCode);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Tenant not found for code: " + tenantCode;
|
||||
}
|
||||
return String.format("Tenant: name=%s, code=%s, enabled=%s", bo.getTenantName(), bo.getTenantCode(),
|
||||
bo.getEnableFlag());
|
||||
}
|
||||
@Tool(description = "Look up a tenant by its unique code. Returns tenant name, code, and enable status.")
|
||||
public String lookupTenantByCode(
|
||||
@ToolParam(description = "The unique tenant code, e.g. 'default'") String tenantCode) {
|
||||
log.debug("Tool: lookupTenantByCode({})", tenantCode);
|
||||
FacadeTenantBO bo = tenantFacade.selectByCode(tenantCode);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Tenant not found for code: " + tenantCode;
|
||||
}
|
||||
return String.format("Tenant: name=%s, code=%s, enabled=%s", bo.getTenantName(), bo.getTenantCode(),
|
||||
bo.getEnableFlag());
|
||||
}
|
||||
|
||||
@Tool(description = "Look up a user by their numeric ID. Returns nickname, username, email, and phone.")
|
||||
public String lookupUserById(@ToolParam(description = "The numeric user ID") Long userId) {
|
||||
log.debug("Tool: lookupUserById({})", userId);
|
||||
FacadeUserBO bo = userFacade.selectById(userId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "User not found for ID: " + userId;
|
||||
}
|
||||
return String.format("User: nickname=%s, username=%s, phone=%s, email=%s", bo.getNickName(), bo.getUserName(),
|
||||
bo.getPhone(), bo.getEmail());
|
||||
}
|
||||
@Tool(description = "Look up a user by their numeric ID. Returns nickname, username, email, and phone.")
|
||||
public String lookupUserById(@ToolParam(description = "The numeric user ID") Long userId) {
|
||||
log.debug("Tool: lookupUserById({})", userId);
|
||||
FacadeUserBO bo = userFacade.selectById(userId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "User not found for ID: " + userId;
|
||||
}
|
||||
return String.format("User: nickname=%s, username=%s, phone=%s, email=%s", bo.getNickName(), bo.getUserName(),
|
||||
bo.getPhone(), bo.getEmail());
|
||||
}
|
||||
|
||||
@Tool(description = "Look up a user login record by login name. Returns the login name, associated user ID, and enable status.")
|
||||
public String lookupUserLoginByName(
|
||||
@ToolParam(description = "The login name (username used for authentication)") String loginName) {
|
||||
log.debug("Tool: lookupUserLoginByName({})", loginName);
|
||||
FacadeUserLoginBO bo = userLoginFacade.selectByName(loginName);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "User login not found for name: " + loginName;
|
||||
}
|
||||
return String.format("UserLogin: loginName=%s, userId=%d, enabled=%s", bo.getLoginName(), bo.getUserId(),
|
||||
bo.getEnableFlag());
|
||||
}
|
||||
@Tool(description = "Look up a user login record by login name. Returns the login name, associated user ID, and enable status.")
|
||||
public String lookupUserLoginByName(
|
||||
@ToolParam(description = "The login name (username used for authentication)") String loginName) {
|
||||
log.debug("Tool: lookupUserLoginByName({})", loginName);
|
||||
FacadeUserLoginBO bo = userLoginFacade.selectByName(loginName);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "User login not found for name: " + loginName;
|
||||
}
|
||||
return String.format("UserLogin: loginName=%s, userId=%d, enabled=%s", bo.getLoginName(), bo.getUserId(),
|
||||
bo.getEnableFlag());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+69
-73
@@ -37,84 +37,80 @@ import java.util.List;
|
||||
@Component
|
||||
public class DataToolSet {
|
||||
|
||||
private final PointValueFacade pointValueFacade;
|
||||
private final PointValueFacade pointValueFacade;
|
||||
|
||||
private final PointValueCommandFacade pointValueCommandFacade;
|
||||
private final PointValueCommandFacade pointValueCommandFacade;
|
||||
|
||||
public DataToolSet(PointValueFacade pointValueFacade, PointValueCommandFacade pointValueCommandFacade) {
|
||||
this.pointValueFacade = pointValueFacade;
|
||||
this.pointValueCommandFacade = pointValueCommandFacade;
|
||||
}
|
||||
public DataToolSet(PointValueFacade pointValueFacade, PointValueCommandFacade pointValueCommandFacade) {
|
||||
this.pointValueFacade = pointValueFacade;
|
||||
this.pointValueCommandFacade = pointValueCommandFacade;
|
||||
}
|
||||
|
||||
@Tool(description = "Get the latest point value for a specific device and point. Returns the current value.")
|
||||
public String getLatestPointValue(@ToolParam(description = "The tenant ID") Long tenantId,
|
||||
@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID") Long pointId) {
|
||||
log.debug("Tool: getLatestPointValue(tenantId={}, deviceId={}, pointId={})", tenantId, deviceId, pointId);
|
||||
try {
|
||||
FacadePointValueBO value = pointValueFacade.lastValue(tenantId, deviceId, pointId);
|
||||
if (value == null) {
|
||||
return "No latest value found for device " + deviceId + " point " + pointId;
|
||||
}
|
||||
return String.format("Device %d / Point %d: value=%s, rawValue=%s, time=%d", value.getDeviceId(),
|
||||
value.getPointId(), value.getValue(), value.getRawValue(), value.getCreateTime());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to get latest point value: {}", e.getMessage());
|
||||
return "Error retrieving latest value: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
@Tool(description = "Get the latest point value for a specific device and point. Returns the current value.")
|
||||
public String getLatestPointValue(@ToolParam(description = "The tenant ID") Long tenantId,
|
||||
@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID") Long pointId) {
|
||||
log.debug("Tool: getLatestPointValue(tenantId={}, deviceId={}, pointId={})", tenantId, deviceId, pointId);
|
||||
try {
|
||||
FacadePointValueBO value = pointValueFacade.lastValue(tenantId, deviceId, pointId);
|
||||
if (value == null) {
|
||||
return "No latest value found for device " + deviceId + " point " + pointId;
|
||||
}
|
||||
return String.format("Device %d / Point %d: value=%s, rawValue=%s, time=%d", value.getDeviceId(),
|
||||
value.getPointId(), value.getValue(), value.getRawValue(), value.getCreateTime());
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to get latest point value: {}", e.getMessage());
|
||||
return "Error retrieving latest value: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@Tool(description = "Get historical point values for a specific device and point. Returns a list of value strings.")
|
||||
public String getPointValueHistory(@ToolParam(description = "The tenant ID") Long tenantId,
|
||||
@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID") Long pointId,
|
||||
@ToolParam(description = "Number of historical records to retrieve") int count) {
|
||||
log.debug("Tool: getPointValueHistory(tenantId={}, deviceId={}, pointId={}, count={})", tenantId, deviceId,
|
||||
pointId, count);
|
||||
try {
|
||||
List<String> history = pointValueFacade.history(tenantId, deviceId, pointId, count);
|
||||
if (history == null || history.isEmpty()) {
|
||||
return "No history data found for device " + deviceId + " point " + pointId;
|
||||
}
|
||||
return "History values (" + history.size() + " records): " + String.join(", ", history);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to get point value history: {}", e.getMessage());
|
||||
return "Error retrieving history: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
@Tool(description = "Get historical point values for a specific device and point. Returns a list of value strings.")
|
||||
public String getPointValueHistory(@ToolParam(description = "The tenant ID") Long tenantId,
|
||||
@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID") Long pointId,
|
||||
@ToolParam(description = "Number of historical records to retrieve") int count) {
|
||||
log.debug("Tool: getPointValueHistory(tenantId={}, deviceId={}, pointId={}, count={})", tenantId, deviceId,
|
||||
pointId, count);
|
||||
try {
|
||||
List<String> history = pointValueFacade.history(tenantId, deviceId, pointId, count);
|
||||
if (history == null || history.isEmpty()) {
|
||||
return "No history data found for device " + deviceId + " point " + pointId;
|
||||
}
|
||||
return "History values (" + history.size() + " records): " + String.join(", ", history);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to get point value history: {}", e.getMessage());
|
||||
return "Error retrieving history: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@Tool(description = "Send a read command to a device for a specific point. The driver will read the current value from the physical device.")
|
||||
public String readPointValue(@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID to read") Long pointId) {
|
||||
log.debug("Tool: readPointValue(deviceId={}, pointId={})", deviceId, pointId);
|
||||
try {
|
||||
boolean success = pointValueCommandFacade.read(deviceId, pointId);
|
||||
return success ? "Read command sent successfully for device " + deviceId + " point " + pointId
|
||||
: "Read command failed for device " + deviceId + " point " + pointId;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to send read command: {}", e.getMessage());
|
||||
return "Error sending read command: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
@Tool(description = "Send a read command to a device for a specific point. The driver will read the current value from the physical device.")
|
||||
public String readPointValue(@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID to read") Long pointId) {
|
||||
log.debug("Tool: readPointValue(deviceId={}, pointId={})", deviceId, pointId);
|
||||
try {
|
||||
boolean success = pointValueCommandFacade.read(deviceId, pointId);
|
||||
return success ? "Read command sent successfully for device " + deviceId + " point " + pointId
|
||||
: "Read command failed for device " + deviceId + " point " + pointId;
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to send read command: {}", e.getMessage());
|
||||
return "Error sending read command: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@Tool(description = "Send a write command to a device for a specific point. Sets the point to the specified value on the physical device.")
|
||||
public String writePointValue(@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID to write") Long pointId,
|
||||
@ToolParam(description = "The value to write (as a string)") String value) {
|
||||
log.debug("Tool: writePointValue(deviceId={}, pointId={}, value={})", deviceId, pointId, value);
|
||||
try {
|
||||
boolean success = pointValueCommandFacade.write(deviceId, pointId, value);
|
||||
return success
|
||||
? "Write command sent successfully for device " + deviceId + " point " + pointId + " value=" + value
|
||||
: "Write command failed for device " + deviceId + " point " + pointId;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to send write command: {}", e.getMessage());
|
||||
return "Error sending write command: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
@Tool(description = "Send a write command to a device for a specific point. Sets the point to the specified value on the physical device.")
|
||||
public String writePointValue(@ToolParam(description = "The device ID") Long deviceId,
|
||||
@ToolParam(description = "The point (metric) ID to write") Long pointId,
|
||||
@ToolParam(description = "The value to write (as a string)") String value) {
|
||||
log.debug("Tool: writePointValue(deviceId={}, pointId={}, value={})", deviceId, pointId, value);
|
||||
try {
|
||||
boolean success = pointValueCommandFacade.write(deviceId, pointId, value);
|
||||
return success
|
||||
? "Write command sent successfully for device " + deviceId + " point " + pointId + " value=" + value
|
||||
: "Write command failed for device " + deviceId + " point " + pointId;
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to send write command: {}", e.getMessage());
|
||||
return "Error sending write command: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+156
-156
@@ -46,189 +46,189 @@ import java.util.stream.Collectors;
|
||||
@Component
|
||||
public class ManagerToolSet {
|
||||
|
||||
private final DeviceFacade deviceFacade;
|
||||
private final DeviceFacade deviceFacade;
|
||||
|
||||
private final DriverFacade driverFacade;
|
||||
private final DriverFacade driverFacade;
|
||||
|
||||
private final PointFacade pointFacade;
|
||||
private final PointFacade pointFacade;
|
||||
|
||||
public ManagerToolSet(DeviceFacade deviceFacade, DriverFacade driverFacade, PointFacade pointFacade) {
|
||||
this.deviceFacade = deviceFacade;
|
||||
this.driverFacade = driverFacade;
|
||||
this.pointFacade = pointFacade;
|
||||
}
|
||||
public ManagerToolSet(DeviceFacade deviceFacade, DriverFacade driverFacade, PointFacade pointFacade) {
|
||||
this.deviceFacade = deviceFacade;
|
||||
this.driverFacade = driverFacade;
|
||||
this.pointFacade = pointFacade;
|
||||
}
|
||||
|
||||
// ==================== Device Tools ====================
|
||||
// ==================== Device Tools ====================
|
||||
|
||||
@Tool(description = "Look up a device by its numeric ID. Returns device name, code, driver ID, enable status, and profile IDs.")
|
||||
public String lookupDeviceById(@ToolParam(description = "The numeric device ID") Long deviceId) {
|
||||
log.debug("Tool: lookupDeviceById({})", deviceId);
|
||||
FacadeDeviceBO bo = deviceFacade.selectById(deviceId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Device not found for ID: " + deviceId;
|
||||
}
|
||||
return formatDevice(bo);
|
||||
}
|
||||
@Tool(description = "Look up a device by its numeric ID. Returns device name, code, driver ID, enable status, and profile IDs.")
|
||||
public String lookupDeviceById(@ToolParam(description = "The numeric device ID") Long deviceId) {
|
||||
log.debug("Tool: lookupDeviceById({})", deviceId);
|
||||
FacadeDeviceBO bo = deviceFacade.selectById(deviceId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Device not found for ID: " + deviceId;
|
||||
}
|
||||
return formatDevice(bo);
|
||||
}
|
||||
|
||||
@Tool(description = "Search for devices with optional filters. Supports filtering by device name, code, or driver ID. Returns a paginated list of devices.")
|
||||
public String searchDevices(
|
||||
@ToolParam(description = "Device name filter (partial match), or null to skip") String deviceName,
|
||||
@ToolParam(description = "Device code filter, or null to skip") String deviceCode,
|
||||
@ToolParam(description = "Driver ID filter, or null to skip") Long driverId,
|
||||
@ToolParam(description = "Page number (1-based)") int page,
|
||||
@ToolParam(description = "Page size") int size) {
|
||||
log.debug("Tool: searchDevices(name={}, code={}, driverId={}, page={}, size={})", deviceName, deviceCode,
|
||||
driverId, page, size);
|
||||
@Tool(description = "Search for devices with optional filters. Supports filtering by device name, code, or driver ID. Returns a paginated list of devices.")
|
||||
public String searchDevices(
|
||||
@ToolParam(description = "Device name filter (partial match), or null to skip") String deviceName,
|
||||
@ToolParam(description = "Device code filter, or null to skip") String deviceCode,
|
||||
@ToolParam(description = "Driver ID filter, or null to skip") Long driverId,
|
||||
@ToolParam(description = "Page number (1-based)") int page,
|
||||
@ToolParam(description = "Page size") int size) {
|
||||
log.debug("Tool: searchDevices(name={}, code={}, driverId={}, page={}, size={})", deviceName, deviceCode,
|
||||
driverId, page, size);
|
||||
|
||||
FacadeDeviceQuery query = new FacadeDeviceQuery();
|
||||
query.setDeviceName(deviceName);
|
||||
query.setDeviceCode(deviceCode);
|
||||
query.setDriverId(driverId);
|
||||
Pages p = new Pages();
|
||||
p.setCurrent(page);
|
||||
p.setSize(size);
|
||||
query.setPage(p);
|
||||
FacadeDeviceQuery query = new FacadeDeviceQuery();
|
||||
query.setDeviceName(deviceName);
|
||||
query.setDeviceCode(deviceCode);
|
||||
query.setDriverId(driverId);
|
||||
Pages p = new Pages();
|
||||
p.setCurrent(page);
|
||||
p.setSize(size);
|
||||
query.setPage(p);
|
||||
|
||||
FacadePage<FacadeDeviceBO> result = deviceFacade.selectByPage(query);
|
||||
return formatDevicePage(result);
|
||||
}
|
||||
FacadePage<FacadeDeviceBO> result = deviceFacade.selectByPage(query);
|
||||
return formatDevicePage(result);
|
||||
}
|
||||
|
||||
@Tool(description = "List all devices attached to a given driver ID.")
|
||||
public String listDevicesByDriverId(@ToolParam(description = "The driver ID") Long driverId) {
|
||||
log.debug("Tool: listDevicesByDriverId({})", driverId);
|
||||
List<FacadeDeviceBO> devices = deviceFacade.selectByDriverId(driverId);
|
||||
if (devices.isEmpty()) {
|
||||
return "No devices found for driver ID: " + driverId;
|
||||
}
|
||||
return "Devices for driver " + driverId + ":\n"
|
||||
+ devices.stream().map(this::formatDevice).collect(Collectors.joining("\n"));
|
||||
}
|
||||
@Tool(description = "List all devices attached to a given driver ID.")
|
||||
public String listDevicesByDriverId(@ToolParam(description = "The driver ID") Long driverId) {
|
||||
log.debug("Tool: listDevicesByDriverId({})", driverId);
|
||||
List<FacadeDeviceBO> devices = deviceFacade.selectByDriverId(driverId);
|
||||
if (devices.isEmpty()) {
|
||||
return "No devices found for driver ID: " + driverId;
|
||||
}
|
||||
return "Devices for driver " + driverId + ":\n"
|
||||
+ devices.stream().map(this::formatDevice).collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
@Tool(description = "List all devices that use a given profile (device template) ID.")
|
||||
public String listDevicesByProfileId(@ToolParam(description = "The profile ID") Long profileId) {
|
||||
log.debug("Tool: listDevicesByProfileId({})", profileId);
|
||||
List<FacadeDeviceBO> devices = deviceFacade.selectByProfileId(profileId);
|
||||
if (devices.isEmpty()) {
|
||||
return "No devices found for profile ID: " + profileId;
|
||||
}
|
||||
return "Devices for profile " + profileId + ":\n"
|
||||
+ devices.stream().map(this::formatDevice).collect(Collectors.joining("\n"));
|
||||
}
|
||||
@Tool(description = "List all devices that use a given profile (device template) ID.")
|
||||
public String listDevicesByProfileId(@ToolParam(description = "The profile ID") Long profileId) {
|
||||
log.debug("Tool: listDevicesByProfileId({})", profileId);
|
||||
List<FacadeDeviceBO> devices = deviceFacade.selectByProfileId(profileId);
|
||||
if (devices.isEmpty()) {
|
||||
return "No devices found for profile ID: " + profileId;
|
||||
}
|
||||
return "Devices for profile " + profileId + ":\n"
|
||||
+ devices.stream().map(this::formatDevice).collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
// ==================== Driver Tools ====================
|
||||
// ==================== Driver Tools ====================
|
||||
|
||||
@Tool(description = "Look up a driver by its numeric ID. Returns driver name, code, service name, host, type, and enable status.")
|
||||
public String lookupDriverById(@ToolParam(description = "The numeric driver ID") Long driverId) {
|
||||
log.debug("Tool: lookupDriverById({})", driverId);
|
||||
FacadeDriverBO bo = driverFacade.selectById(driverId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Driver not found for ID: " + driverId;
|
||||
}
|
||||
return formatDriver(bo);
|
||||
}
|
||||
@Tool(description = "Look up a driver by its numeric ID. Returns driver name, code, service name, host, type, and enable status.")
|
||||
public String lookupDriverById(@ToolParam(description = "The numeric driver ID") Long driverId) {
|
||||
log.debug("Tool: lookupDriverById({})", driverId);
|
||||
FacadeDriverBO bo = driverFacade.selectById(driverId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Driver not found for ID: " + driverId;
|
||||
}
|
||||
return formatDriver(bo);
|
||||
}
|
||||
|
||||
@Tool(description = "Resolve the driver that owns a given device. Returns the driver details.")
|
||||
public String lookupDriverByDeviceId(@ToolParam(description = "The device ID") Long deviceId) {
|
||||
log.debug("Tool: lookupDriverByDeviceId({})", deviceId);
|
||||
FacadeDriverBO bo = driverFacade.selectByDeviceId(deviceId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "No driver found for device ID: " + deviceId;
|
||||
}
|
||||
return formatDriver(bo);
|
||||
}
|
||||
@Tool(description = "Resolve the driver that owns a given device. Returns the driver details.")
|
||||
public String lookupDriverByDeviceId(@ToolParam(description = "The device ID") Long deviceId) {
|
||||
log.debug("Tool: lookupDriverByDeviceId({})", deviceId);
|
||||
FacadeDriverBO bo = driverFacade.selectByDeviceId(deviceId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "No driver found for device ID: " + deviceId;
|
||||
}
|
||||
return formatDriver(bo);
|
||||
}
|
||||
|
||||
@Tool(description = "Search for drivers with optional name filter. Returns a paginated list.")
|
||||
public String searchDrivers(
|
||||
@ToolParam(description = "Driver name filter (partial match), or null to skip") String driverName,
|
||||
@ToolParam(description = "Page number (1-based)") int page,
|
||||
@ToolParam(description = "Page size") int size) {
|
||||
log.debug("Tool: searchDrivers(name={}, page={}, size={})", driverName, page, size);
|
||||
@Tool(description = "Search for drivers with optional name filter. Returns a paginated list.")
|
||||
public String searchDrivers(
|
||||
@ToolParam(description = "Driver name filter (partial match), or null to skip") String driverName,
|
||||
@ToolParam(description = "Page number (1-based)") int page,
|
||||
@ToolParam(description = "Page size") int size) {
|
||||
log.debug("Tool: searchDrivers(name={}, page={}, size={})", driverName, page, size);
|
||||
|
||||
FacadeDriverQuery query = new FacadeDriverQuery();
|
||||
query.setDriverName(driverName);
|
||||
Pages p = new Pages();
|
||||
p.setCurrent(page);
|
||||
p.setSize(size);
|
||||
query.setPage(p);
|
||||
FacadeDriverQuery query = new FacadeDriverQuery();
|
||||
query.setDriverName(driverName);
|
||||
Pages p = new Pages();
|
||||
p.setCurrent(page);
|
||||
p.setSize(size);
|
||||
query.setPage(p);
|
||||
|
||||
FacadePage<FacadeDriverBO> result = driverFacade.selectByPage(query);
|
||||
return formatDriverPage(result);
|
||||
}
|
||||
FacadePage<FacadeDriverBO> result = driverFacade.selectByPage(query);
|
||||
return formatDriverPage(result);
|
||||
}
|
||||
|
||||
// ==================== Point Tools ====================
|
||||
// ==================== Point Tools ====================
|
||||
|
||||
@Tool(description = "Look up a point (data point / metric) by its numeric ID. Returns point name, code, type, read/write flag, unit, base value, and multiplier.")
|
||||
public String lookupPointById(@ToolParam(description = "The numeric point ID") Long pointId) {
|
||||
log.debug("Tool: lookupPointById({})", pointId);
|
||||
FacadePointBO bo = pointFacade.selectById(pointId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Point not found for ID: " + pointId;
|
||||
}
|
||||
return formatPoint(bo);
|
||||
}
|
||||
@Tool(description = "Look up a point (data point / metric) by its numeric ID. Returns point name, code, type, read/write flag, unit, base value, and multiplier.")
|
||||
public String lookupPointById(@ToolParam(description = "The numeric point ID") Long pointId) {
|
||||
log.debug("Tool: lookupPointById({})", pointId);
|
||||
FacadePointBO bo = pointFacade.selectById(pointId);
|
||||
if (Objects.isNull(bo)) {
|
||||
return "Point not found for ID: " + pointId;
|
||||
}
|
||||
return formatPoint(bo);
|
||||
}
|
||||
|
||||
@Tool(description = "Search for points with optional filters. Returns a paginated list.")
|
||||
public String searchPoints(
|
||||
@ToolParam(description = "Point name filter (partial match), or null to skip") String pointName,
|
||||
@ToolParam(description = "Profile ID filter, or null to skip") Long profileId,
|
||||
@ToolParam(description = "Page number (1-based)") int page,
|
||||
@ToolParam(description = "Page size") int size) {
|
||||
log.debug("Tool: searchPoints(name={}, profileId={}, page={}, size={})", pointName, profileId, page, size);
|
||||
@Tool(description = "Search for points with optional filters. Returns a paginated list.")
|
||||
public String searchPoints(
|
||||
@ToolParam(description = "Point name filter (partial match), or null to skip") String pointName,
|
||||
@ToolParam(description = "Profile ID filter, or null to skip") Long profileId,
|
||||
@ToolParam(description = "Page number (1-based)") int page,
|
||||
@ToolParam(description = "Page size") int size) {
|
||||
log.debug("Tool: searchPoints(name={}, profileId={}, page={}, size={})", pointName, profileId, page, size);
|
||||
|
||||
FacadePointQuery query = new FacadePointQuery();
|
||||
query.setPointName(pointName);
|
||||
query.setProfileId(profileId);
|
||||
Pages p = new Pages();
|
||||
p.setCurrent(page);
|
||||
p.setSize(size);
|
||||
query.setPage(p);
|
||||
FacadePointQuery query = new FacadePointQuery();
|
||||
query.setPointName(pointName);
|
||||
query.setProfileId(profileId);
|
||||
Pages p = new Pages();
|
||||
p.setCurrent(page);
|
||||
p.setSize(size);
|
||||
query.setPage(p);
|
||||
|
||||
FacadePage<FacadePointBO> result = pointFacade.selectByPage(query);
|
||||
return formatPointPage(result);
|
||||
}
|
||||
FacadePage<FacadePointBO> result = pointFacade.selectByPage(query);
|
||||
return formatPointPage(result);
|
||||
}
|
||||
|
||||
// ==================== Formatting Helpers ====================
|
||||
// ==================== Formatting Helpers ====================
|
||||
|
||||
private String formatDevice(FacadeDeviceBO d) {
|
||||
return String.format("Device[id=%d, name=%s, code=%s, driverId=%d, enabled=%s, profileIds=%s]", d.getId(),
|
||||
d.getDeviceName(), d.getDeviceCode(), d.getDriverId(), d.getEnableFlag(), d.getProfileIds());
|
||||
}
|
||||
private String formatDevice(FacadeDeviceBO d) {
|
||||
return String.format("Device[id=%d, name=%s, code=%s, driverId=%d, enabled=%s, profileIds=%s]", d.getId(),
|
||||
d.getDeviceName(), d.getDeviceCode(), d.getDriverId(), d.getEnableFlag(), d.getProfileIds());
|
||||
}
|
||||
|
||||
private String formatDevicePage(FacadePage<FacadeDeviceBO> page) {
|
||||
if (Objects.isNull(page) || page.getRecords().isEmpty()) {
|
||||
return "No devices found.";
|
||||
}
|
||||
String items = page.getRecords().stream().map(this::formatDevice).collect(Collectors.joining("\n"));
|
||||
return String.format("Page %d/%d (total %d):\n%s", page.getCurrent(), page.getPages(), page.getTotal(), items);
|
||||
}
|
||||
private String formatDevicePage(FacadePage<FacadeDeviceBO> page) {
|
||||
if (Objects.isNull(page) || page.getRecords().isEmpty()) {
|
||||
return "No devices found.";
|
||||
}
|
||||
String items = page.getRecords().stream().map(this::formatDevice).collect(Collectors.joining("\n"));
|
||||
return String.format("Page %d/%d (total %d):\n%s", page.getCurrent(), page.getPages(), page.getTotal(), items);
|
||||
}
|
||||
|
||||
private String formatDriver(FacadeDriverBO d) {
|
||||
return String.format("Driver[id=%d, name=%s, code=%s, serviceName=%s, host=%s, type=%s, enabled=%s]", d.getId(),
|
||||
d.getDriverName(), d.getDriverCode(), d.getServiceName(), d.getServiceHost(), d.getDriverTypeFlag(),
|
||||
d.getEnableFlag());
|
||||
}
|
||||
private String formatDriver(FacadeDriverBO d) {
|
||||
return String.format("Driver[id=%d, name=%s, code=%s, serviceName=%s, host=%s, type=%s, enabled=%s]", d.getId(),
|
||||
d.getDriverName(), d.getDriverCode(), d.getServiceName(), d.getServiceHost(), d.getDriverTypeFlag(),
|
||||
d.getEnableFlag());
|
||||
}
|
||||
|
||||
private String formatDriverPage(FacadePage<FacadeDriverBO> page) {
|
||||
if (Objects.isNull(page) || page.getRecords().isEmpty()) {
|
||||
return "No drivers found.";
|
||||
}
|
||||
String items = page.getRecords().stream().map(this::formatDriver).collect(Collectors.joining("\n"));
|
||||
return String.format("Page %d/%d (total %d):\n%s", page.getCurrent(), page.getPages(), page.getTotal(), items);
|
||||
}
|
||||
private String formatDriverPage(FacadePage<FacadeDriverBO> page) {
|
||||
if (Objects.isNull(page) || page.getRecords().isEmpty()) {
|
||||
return "No drivers found.";
|
||||
}
|
||||
String items = page.getRecords().stream().map(this::formatDriver).collect(Collectors.joining("\n"));
|
||||
return String.format("Page %d/%d (total %d):\n%s", page.getCurrent(), page.getPages(), page.getTotal(), items);
|
||||
}
|
||||
|
||||
private String formatPoint(FacadePointBO p) {
|
||||
return String.format(
|
||||
"Point[id=%d, name=%s, code=%s, type=%s, rw=%s, unit=%s, base=%s, multiple=%s, profileId=%d]",
|
||||
p.getId(), p.getPointName(), p.getPointCode(), p.getPointTypeFlag(), p.getRwFlag(), p.getUnit(),
|
||||
p.getBaseValue(), p.getMultiple(), p.getProfileId());
|
||||
}
|
||||
private String formatPoint(FacadePointBO p) {
|
||||
return String.format(
|
||||
"Point[id=%d, name=%s, code=%s, type=%s, rw=%s, unit=%s, base=%s, multiple=%s, profileId=%d]",
|
||||
p.getId(), p.getPointName(), p.getPointCode(), p.getPointTypeFlag(), p.getRwFlag(), p.getUnit(),
|
||||
p.getBaseValue(), p.getMultiple(), p.getProfileId());
|
||||
}
|
||||
|
||||
private String formatPointPage(FacadePage<FacadePointBO> page) {
|
||||
if (Objects.isNull(page) || page.getRecords().isEmpty()) {
|
||||
return "No points found.";
|
||||
}
|
||||
String items = page.getRecords().stream().map(this::formatPoint).collect(Collectors.joining("\n"));
|
||||
return String.format("Page %d/%d (total %d):\n%s", page.getCurrent(), page.getPages(), page.getTotal(), items);
|
||||
}
|
||||
private String formatPointPage(FacadePage<FacadePointBO> page) {
|
||||
if (Objects.isNull(page) || page.getRecords().isEmpty()) {
|
||||
return "No points found.";
|
||||
}
|
||||
String items = page.getRecords().stream().map(this::formatPoint).collect(Collectors.joining("\n"));
|
||||
return String.format("Page %d/%d (total %d):\n%s", page.getCurrent(), page.getPages(), page.getTotal(), items);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-common-api` provides shared gRPC utility classes used across all services in the IoT DC3 platform. It contains builder utilities for constructing gRPC request/response objects
|
||||
`dc3-common-api` provides shared gRPC utility classes used across all services in the IoT DC3 platform. It contains
|
||||
builder utilities for constructing gRPC request/response objects
|
||||
from domain model entities.
|
||||
|
||||
## Module Information
|
||||
@@ -13,11 +14,13 @@ from domain model entities.
|
||||
|
||||
## Key Components
|
||||
|
||||
- **`GrpcBuilderUtil`** — Utility class for building common gRPC DTOs from BO/DO entities (e.g., setting pagination, building result wrappers)
|
||||
- **`GrpcBuilderUtil`** — Utility class for building common gRPC DTOs from BO/DO entities (e.g., setting pagination,
|
||||
building result wrappers)
|
||||
|
||||
## Dependencies
|
||||
|
||||
This module is included in any service that imports a `dc3-api-*` module. It bridges domain model objects with generated protobuf classes.
|
||||
This module is included in any service that imports a `dc3-api-*` module. It bridges domain model objects with generated
|
||||
protobuf classes.
|
||||
|
||||
## Build Instructions
|
||||
|
||||
|
||||
+122
-117
@@ -39,132 +39,137 @@ import java.util.Optional;
|
||||
*/
|
||||
public class GrpcBuilderUtil {
|
||||
|
||||
private GrpcBuilderUtil() {
|
||||
throw new IllegalStateException(ExceptionConstant.UTILITY_CLASS);
|
||||
}
|
||||
private GrpcBuilderUtil() {
|
||||
throw new IllegalStateException(ExceptionConstant.UTILITY_CLASS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grpc Page to Pages
|
||||
* @param page GrpcPage
|
||||
* @return Pages
|
||||
*/
|
||||
public static Pages buildPagesByGrpcPage(GrpcPage page) {
|
||||
if (Objects.isNull(page)) {
|
||||
GrpcPage.Builder builder = GrpcPage.newBuilder();
|
||||
builder.setCurrent(1);
|
||||
builder.setPages(DefaultConstant.PAGE_SIZE);
|
||||
page = builder.build();
|
||||
}
|
||||
/**
|
||||
* Grpc Page to Pages
|
||||
*
|
||||
* @param page GrpcPage
|
||||
* @return Pages
|
||||
*/
|
||||
public static Pages buildPagesByGrpcPage(GrpcPage page) {
|
||||
if (Objects.isNull(page)) {
|
||||
GrpcPage.Builder builder = GrpcPage.newBuilder();
|
||||
builder.setCurrent(1);
|
||||
builder.setPages(DefaultConstant.PAGE_SIZE);
|
||||
page = builder.build();
|
||||
}
|
||||
|
||||
Pages pages = new Pages();
|
||||
long current = page.getCurrent() < 1 ? 1 : page.getCurrent();
|
||||
long pageSize = page.getSize() < 1 ? DefaultConstant.PAGE_SIZE : page.getSize();
|
||||
pageSize = pageSize > DefaultConstant.MAX_PAGE_SIZE ? DefaultConstant.MAX_PAGE_SIZE : pageSize;
|
||||
pages.setCurrent(current);
|
||||
pages.setSize(pageSize);
|
||||
return pages;
|
||||
}
|
||||
Pages pages = new Pages();
|
||||
long current = page.getCurrent() < 1 ? 1 : page.getCurrent();
|
||||
long pageSize = page.getSize() < 1 ? DefaultConstant.PAGE_SIZE : page.getSize();
|
||||
pageSize = pageSize > DefaultConstant.MAX_PAGE_SIZE ? DefaultConstant.MAX_PAGE_SIZE : pageSize;
|
||||
pages.setCurrent(current);
|
||||
pages.setSize(pageSize);
|
||||
return pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity Base BO to Grpc Base BO
|
||||
* @param entityBO EntityBO
|
||||
* @param <T> EntityBO extends BaseBO
|
||||
* @return GrpcBase
|
||||
*/
|
||||
public static <T extends BaseBO> GrpcBase buildGrpcBaseByBO(T entityBO) {
|
||||
if (Objects.isNull(entityBO)) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Entity Base BO to Grpc Base BO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @param <T> EntityBO extends BaseBO
|
||||
* @return GrpcBase
|
||||
*/
|
||||
public static <T extends BaseBO> GrpcBase buildGrpcBaseByBO(T entityBO) {
|
||||
if (Objects.isNull(entityBO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GrpcBase.Builder builder = GrpcBase.newBuilder();
|
||||
Optional.ofNullable(entityBO.getId())
|
||||
.ifPresentOrElse(builder::setId, () -> builder.setId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityBO.getRemark()).ifPresent(builder::setRemark);
|
||||
Optional.ofNullable(entityBO.getCreatorId())
|
||||
.ifPresentOrElse(builder::setCreatorId, () -> builder.setCreatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityBO.getCreatorName()).ifPresent(builder::setCreatorName);
|
||||
Optional.ofNullable(entityBO.getCreateTime())
|
||||
.ifPresent(value -> builder.setCreateTime(LocalDateTimeUtil.milliSeconds(value)));
|
||||
Optional.ofNullable(entityBO.getOperatorId())
|
||||
.ifPresentOrElse(builder::setOperatorId, () -> builder.setOperatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityBO.getOperatorName()).ifPresent(builder::setOperatorName);
|
||||
Optional.ofNullable(entityBO.getOperateTime())
|
||||
.ifPresent(value -> builder.setOperateTime(LocalDateTimeUtil.milliSeconds(value)));
|
||||
return builder.build();
|
||||
}
|
||||
GrpcBase.Builder builder = GrpcBase.newBuilder();
|
||||
Optional.ofNullable(entityBO.getId())
|
||||
.ifPresentOrElse(builder::setId, () -> builder.setId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityBO.getRemark()).ifPresent(builder::setRemark);
|
||||
Optional.ofNullable(entityBO.getCreatorId())
|
||||
.ifPresentOrElse(builder::setCreatorId, () -> builder.setCreatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityBO.getCreatorName()).ifPresent(builder::setCreatorName);
|
||||
Optional.ofNullable(entityBO.getCreateTime())
|
||||
.ifPresent(value -> builder.setCreateTime(LocalDateTimeUtil.milliSeconds(value)));
|
||||
Optional.ofNullable(entityBO.getOperatorId())
|
||||
.ifPresentOrElse(builder::setOperatorId, () -> builder.setOperatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityBO.getOperatorName()).ifPresent(builder::setOperatorName);
|
||||
Optional.ofNullable(entityBO.getOperateTime())
|
||||
.ifPresent(value -> builder.setOperateTime(LocalDateTimeUtil.milliSeconds(value)));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grpc Base to Base BO
|
||||
* @param entityGrpc GrpcBase
|
||||
* @param entityBO EntityBO
|
||||
* @param <T> EntityBO extends BaseBO
|
||||
*/
|
||||
public static <T extends BaseBO> void buildBaseBOByGrpcBase(GrpcBase entityGrpc, T entityBO) {
|
||||
if (Objects.isNull(entityGrpc)) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Grpc Base to Base BO
|
||||
*
|
||||
* @param entityGrpc GrpcBase
|
||||
* @param entityBO EntityBO
|
||||
* @param <T> EntityBO extends BaseBO
|
||||
*/
|
||||
public static <T extends BaseBO> void buildBaseBOByGrpcBase(GrpcBase entityGrpc, T entityBO) {
|
||||
if (Objects.isNull(entityGrpc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LongOptional.ofNullable(entityGrpc.getId()).ifPresent(entityBO::setId);
|
||||
StringOptional.ofNullable(entityGrpc.getRemark()).ifPresent(entityBO::setRemark);
|
||||
LongOptional.ofNullable(entityGrpc.getCreatorId()).ifPresent(entityBO::setCreatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getCreatorName()).ifPresent(entityBO::setCreatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getCreateTime())
|
||||
.ifPresent(value -> entityBO.setCreateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
LongOptional.ofNullable(entityGrpc.getOperatorId()).ifPresent(entityBO::setOperatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getOperatorName()).ifPresent(entityBO::setOperatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getOperateTime())
|
||||
.ifPresent(value -> entityBO.setOperateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
}
|
||||
LongOptional.ofNullable(entityGrpc.getId()).ifPresent(entityBO::setId);
|
||||
StringOptional.ofNullable(entityGrpc.getRemark()).ifPresent(entityBO::setRemark);
|
||||
LongOptional.ofNullable(entityGrpc.getCreatorId()).ifPresent(entityBO::setCreatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getCreatorName()).ifPresent(entityBO::setCreatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getCreateTime())
|
||||
.ifPresent(value -> entityBO.setCreateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
LongOptional.ofNullable(entityGrpc.getOperatorId()).ifPresent(entityBO::setOperatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getOperatorName()).ifPresent(entityBO::setOperatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getOperateTime())
|
||||
.ifPresent(value -> entityBO.setOperateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity Base DTO to Grpc Base DTO
|
||||
* @param entityDTO EntityDTO
|
||||
* @param <T> EntityDTO extends BaseDTO
|
||||
* @return GrpcBase
|
||||
*/
|
||||
public static <T extends BaseDTO> GrpcBase buildGrpcBaseByDTO(T entityDTO) {
|
||||
if (Objects.isNull(entityDTO)) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Entity Base DTO to Grpc Base DTO
|
||||
*
|
||||
* @param entityDTO EntityDTO
|
||||
* @param <T> EntityDTO extends BaseDTO
|
||||
* @return GrpcBase
|
||||
*/
|
||||
public static <T extends BaseDTO> GrpcBase buildGrpcBaseByDTO(T entityDTO) {
|
||||
if (Objects.isNull(entityDTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GrpcBase.Builder builder = GrpcBase.newBuilder();
|
||||
Optional.ofNullable(entityDTO.getId())
|
||||
.ifPresentOrElse(builder::setId, () -> builder.setId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityDTO.getRemark()).ifPresent(builder::setRemark);
|
||||
Optional.ofNullable(entityDTO.getCreatorId())
|
||||
.ifPresentOrElse(builder::setCreatorId, () -> builder.setCreatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityDTO.getCreatorName()).ifPresent(builder::setCreatorName);
|
||||
Optional.ofNullable(entityDTO.getCreateTime())
|
||||
.ifPresent(value -> builder.setCreateTime(LocalDateTimeUtil.milliSeconds(value)));
|
||||
Optional.ofNullable(entityDTO.getOperatorId())
|
||||
.ifPresentOrElse(builder::setOperatorId, () -> builder.setOperatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityDTO.getOperatorName()).ifPresent(builder::setOperatorName);
|
||||
Optional.ofNullable(entityDTO.getOperateTime())
|
||||
.ifPresent(time -> builder.setOperateTime(LocalDateTimeUtil.milliSeconds(time)));
|
||||
return builder.build();
|
||||
}
|
||||
GrpcBase.Builder builder = GrpcBase.newBuilder();
|
||||
Optional.ofNullable(entityDTO.getId())
|
||||
.ifPresentOrElse(builder::setId, () -> builder.setId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityDTO.getRemark()).ifPresent(builder::setRemark);
|
||||
Optional.ofNullable(entityDTO.getCreatorId())
|
||||
.ifPresentOrElse(builder::setCreatorId, () -> builder.setCreatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityDTO.getCreatorName()).ifPresent(builder::setCreatorName);
|
||||
Optional.ofNullable(entityDTO.getCreateTime())
|
||||
.ifPresent(value -> builder.setCreateTime(LocalDateTimeUtil.milliSeconds(value)));
|
||||
Optional.ofNullable(entityDTO.getOperatorId())
|
||||
.ifPresentOrElse(builder::setOperatorId, () -> builder.setOperatorId(DefaultConstant.NULL_INT));
|
||||
Optional.ofNullable(entityDTO.getOperatorName()).ifPresent(builder::setOperatorName);
|
||||
Optional.ofNullable(entityDTO.getOperateTime())
|
||||
.ifPresent(time -> builder.setOperateTime(LocalDateTimeUtil.milliSeconds(time)));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grpc Base to Base DTO
|
||||
* @param entityGrpc GrpcBase
|
||||
* @param entityDTO EntityDTO
|
||||
* @param <T> EntityDTO extends GrpcBase
|
||||
*/
|
||||
public static <T extends BaseDTO> void buildBaseDTOByGrpcBase(GrpcBase entityGrpc, T entityDTO) {
|
||||
if (Objects.isNull(entityGrpc)) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Grpc Base to Base DTO
|
||||
*
|
||||
* @param entityGrpc GrpcBase
|
||||
* @param entityDTO EntityDTO
|
||||
* @param <T> EntityDTO extends GrpcBase
|
||||
*/
|
||||
public static <T extends BaseDTO> void buildBaseDTOByGrpcBase(GrpcBase entityGrpc, T entityDTO) {
|
||||
if (Objects.isNull(entityGrpc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LongOptional.ofNullable(entityGrpc.getId()).ifPresent(entityDTO::setId);
|
||||
StringOptional.ofNullable(entityGrpc.getRemark()).ifPresent(entityDTO::setRemark);
|
||||
LongOptional.ofNullable(entityGrpc.getCreatorId()).ifPresent(entityDTO::setCreatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getCreatorName()).ifPresent(entityDTO::setCreatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getCreateTime())
|
||||
.ifPresent(value -> entityDTO.setCreateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
LongOptional.ofNullable(entityGrpc.getOperatorId()).ifPresent(entityDTO::setOperatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getOperatorName()).ifPresent(entityDTO::setOperatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getOperateTime())
|
||||
.ifPresent(value -> entityDTO.setOperateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
}
|
||||
LongOptional.ofNullable(entityGrpc.getId()).ifPresent(entityDTO::setId);
|
||||
StringOptional.ofNullable(entityGrpc.getRemark()).ifPresent(entityDTO::setRemark);
|
||||
LongOptional.ofNullable(entityGrpc.getCreatorId()).ifPresent(entityDTO::setCreatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getCreatorName()).ifPresent(entityDTO::setCreatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getCreateTime())
|
||||
.ifPresent(value -> entityDTO.setCreateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
LongOptional.ofNullable(entityGrpc.getOperatorId()).ifPresent(entityDTO::setOperatorId);
|
||||
StringOptional.ofNullable(entityGrpc.getOperatorName()).ifPresent(entityDTO::setOperatorName);
|
||||
LongOptional.ofNullable(entityGrpc.getOperateTime())
|
||||
.ifPresent(value -> entityDTO.setOperateTime(LocalDateTimeUtil.dateTime(value)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
## Overview
|
||||
|
||||
`dc3-common-auth` is the shared authentication business module of the IoT DC3 platform. It contains all controllers, service implementations, gRPC servers, mappers, and DAL classes
|
||||
`dc3-common-auth` is the shared authentication business module of the IoT DC3 platform. It contains all controllers,
|
||||
service implementations, gRPC servers, mappers, and DAL classes
|
||||
that implement the authentication center's functionality. It is wired directly into `dc3-center-auth`.
|
||||
|
||||
## Module Information
|
||||
|
||||
+6
-5
@@ -30,10 +30,11 @@ import java.util.List;
|
||||
*/
|
||||
public interface DictionaryForAuthService {
|
||||
|
||||
/**
|
||||
* Tenant
|
||||
* @return Dictionary Array
|
||||
*/
|
||||
List<DictionaryBO> tenantDictionary();
|
||||
/**
|
||||
* Tenant
|
||||
*
|
||||
* @return Dictionary Array
|
||||
*/
|
||||
List<DictionaryBO> tenantDictionary();
|
||||
|
||||
}
|
||||
|
||||
+24
-21
@@ -32,28 +32,31 @@ import io.github.pnoker.common.auth.entity.model.MenuDO;
|
||||
*/
|
||||
public interface ResourceRegistrySyncService {
|
||||
|
||||
/**
|
||||
* Perform a three-way diff against the DB state and apply the required mutations
|
||||
* inside a single transaction guarded by a Postgres advisory lock keyed on
|
||||
* {@link ResourceRegistrySyncCommand#getServiceName()}.
|
||||
* @param command the full API inventory for a single service
|
||||
* @return counters describing what was changed
|
||||
*/
|
||||
ResourceRegistrySyncResult sync(ResourceRegistrySyncCommand command);
|
||||
/**
|
||||
* Perform a three-way diff against the DB state and apply the required mutations
|
||||
* inside a single transaction guarded by a Postgres advisory lock keyed on
|
||||
* {@link ResourceRegistrySyncCommand#getServiceName()}.
|
||||
*
|
||||
* @param command the full API inventory for a single service
|
||||
* @return counters describing what was changed
|
||||
*/
|
||||
ResourceRegistrySyncResult sync(ResourceRegistrySyncCommand command);
|
||||
|
||||
/**
|
||||
* Mirror a single menu row into dc3_resource as a MENU-type leaf. Called by
|
||||
* MenuServiceImpl on save/update so the Resource tree always tracks menu state.
|
||||
* Idempotent — updates the existing resource row if one already exists for the menu.
|
||||
* @param menu the menu row that was just inserted or updated
|
||||
*/
|
||||
void syncMenuResource(MenuDO menu);
|
||||
/**
|
||||
* Mirror a single menu row into dc3_resource as a MENU-type leaf. Called by
|
||||
* MenuServiceImpl on save/update so the Resource tree always tracks menu state.
|
||||
* Idempotent — updates the existing resource row if one already exists for the menu.
|
||||
*
|
||||
* @param menu the menu row that was just inserted or updated
|
||||
*/
|
||||
void syncMenuResource(MenuDO menu);
|
||||
|
||||
/**
|
||||
* Soft-delete the resource row mirroring the given menu, if any. No-op when no mirror
|
||||
* exists.
|
||||
* @param menuId the id of the menu being removed
|
||||
*/
|
||||
void removeMenuResource(Long menuId);
|
||||
/**
|
||||
* Soft-delete the resource row mirroring the given menu, if any. No-op when no mirror
|
||||
* exists.
|
||||
*
|
||||
* @param menuId the id of the menu being removed
|
||||
*/
|
||||
void removeMenuResource(Long menuId);
|
||||
|
||||
}
|
||||
|
||||
+22
-22
@@ -28,29 +28,29 @@ import io.github.pnoker.common.auth.entity.bean.TokenValid;
|
||||
*/
|
||||
public interface TokenService {
|
||||
|
||||
/**
|
||||
* @param loginName Name
|
||||
* @param tenantCode TenantCode
|
||||
* @return R of String
|
||||
*/
|
||||
String generateSalt(String loginName, String tenantCode);
|
||||
/**
|
||||
* @param loginName Name
|
||||
* @param tenantCode TenantCode
|
||||
* @return R of String
|
||||
*/
|
||||
String generateSalt(String loginName, String tenantCode);
|
||||
|
||||
/**
|
||||
* @param loginName Name
|
||||
* @param salt User Salt
|
||||
* @param password User Password
|
||||
* @param tenantCode TenantCode
|
||||
* @return R of String
|
||||
*/
|
||||
String generateToken(String loginName, String salt, String password, String tenantCode);
|
||||
/**
|
||||
* @param loginName Name
|
||||
* @param salt User Salt
|
||||
* @param password User Password
|
||||
* @param tenantCode TenantCode
|
||||
* @return R of String
|
||||
*/
|
||||
String generateToken(String loginName, String salt, String password, String tenantCode);
|
||||
|
||||
/**
|
||||
* @param loginName Name
|
||||
* @param salt
|
||||
* @param token Token
|
||||
* @param tenantCode TenantCode
|
||||
* @return TokenValid
|
||||
*/
|
||||
TokenValid checkValid(String loginName, String salt, String token, String tenantCode);
|
||||
/**
|
||||
* @param loginName Name
|
||||
* @param salt
|
||||
* @param token Token
|
||||
* @param tenantCode TenantCode
|
||||
* @return TokenValid
|
||||
*/
|
||||
TokenValid checkValid(String loginName, String salt, String token, String tenantCode);
|
||||
|
||||
}
|
||||
|
||||
+14
-14
@@ -39,21 +39,21 @@ import java.util.List;
|
||||
@Service
|
||||
public class DictionaryForAuthServiceImpl implements DictionaryForAuthService {
|
||||
|
||||
@Resource
|
||||
private TenantManager tenantManager;
|
||||
@Resource
|
||||
private TenantManager tenantManager;
|
||||
|
||||
@Override
|
||||
public List<DictionaryBO> tenantDictionary() {
|
||||
LambdaQueryWrapper<TenantDO> wrapper = Wrappers.<TenantDO>query().lambda();
|
||||
wrapper.eq(TenantDO::getEnableFlag, EnableFlagEnum.ENABLE);
|
||||
List<TenantDO> entityDOList = tenantManager.list(wrapper);
|
||||
@Override
|
||||
public List<DictionaryBO> tenantDictionary() {
|
||||
LambdaQueryWrapper<TenantDO> wrapper = Wrappers.<TenantDO>query().lambda();
|
||||
wrapper.eq(TenantDO::getEnableFlag, EnableFlagEnum.ENABLE);
|
||||
List<TenantDO> entityDOList = tenantManager.list(wrapper);
|
||||
|
||||
return entityDOList.stream().map(entityDO -> {
|
||||
DictionaryBO driverDictionary = new DictionaryBO();
|
||||
driverDictionary.setLabel(entityDO.getTenantName());
|
||||
driverDictionary.setValue(entityDO.getId().toString());
|
||||
return driverDictionary;
|
||||
}).toList();
|
||||
}
|
||||
return entityDOList.stream().map(entityDO -> {
|
||||
DictionaryBO driverDictionary = new DictionaryBO();
|
||||
driverDictionary.setLabel(entityDO.getTenantName());
|
||||
driverDictionary.setValue(entityDO.getId().toString());
|
||||
return driverDictionary;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+435
-439
@@ -52,486 +52,482 @@ import java.util.*;
|
||||
@Service
|
||||
public class ResourceRegistrySyncServiceImpl implements ResourceRegistrySyncService {
|
||||
|
||||
/**
|
||||
* dc3_resource.resource_code prefix for API leaf rows (one per dc3_api row). Other
|
||||
* resource types should use their own prefixes (e.g. {@code menu:}).
|
||||
*/
|
||||
private static final String RESOURCE_CODE_PREFIX = "api:";
|
||||
/**
|
||||
* dc3_resource.resource_code prefix for API leaf rows (one per dc3_api row). Other
|
||||
* resource types should use their own prefixes (e.g. {@code menu:}).
|
||||
*/
|
||||
private static final String RESOURCE_CODE_PREFIX = "api:";
|
||||
|
||||
/**
|
||||
* Resource code prefix for the virtual service-grouping node — one per serviceName,
|
||||
* parent = 0, entity_id = 0. Exists only to give the Resource tree a root per
|
||||
* service.
|
||||
*/
|
||||
private static final String SERVICE_NODE_CODE_PREFIX = "api:service:";
|
||||
/**
|
||||
* Resource code prefix for the virtual service-grouping node — one per serviceName,
|
||||
* parent = 0, entity_id = 0. Exists only to give the Resource tree a root per
|
||||
* service.
|
||||
*/
|
||||
private static final String SERVICE_NODE_CODE_PREFIX = "api:service:";
|
||||
|
||||
/**
|
||||
* Resource code prefix for the virtual apiGroup-grouping node — one per (serviceName,
|
||||
* apiGroup) pair, parent = the corresponding service node, entity_id = 0. Clusters
|
||||
* sibling endpoints under their owning controller.
|
||||
*/
|
||||
private static final String GROUP_NODE_CODE_PREFIX = "api:group:";
|
||||
/**
|
||||
* Resource code prefix for the virtual apiGroup-grouping node — one per (serviceName,
|
||||
* apiGroup) pair, parent = the corresponding service node, entity_id = 0. Clusters
|
||||
* sibling endpoints under their owning controller.
|
||||
*/
|
||||
private static final String GROUP_NODE_CODE_PREFIX = "api:group:";
|
||||
|
||||
/**
|
||||
* Resource code prefix for MENU-type leaves. Each dc3_menu row owns one dc3_resource
|
||||
* row; parent_resource_id mirrors the parent menu's resource.
|
||||
*/
|
||||
private static final String MENU_RESOURCE_CODE_PREFIX = "menu:";
|
||||
/**
|
||||
* Resource code prefix for MENU-type leaves. Each dc3_menu row owns one dc3_resource
|
||||
* row; parent_resource_id mirrors the parent menu's resource.
|
||||
*/
|
||||
private static final String MENU_RESOURCE_CODE_PREFIX = "menu:";
|
||||
|
||||
@Resource
|
||||
private ApiManager apiManager;
|
||||
@Resource
|
||||
private ApiManager apiManager;
|
||||
|
||||
@Resource
|
||||
private ResourceManager resourceManager;
|
||||
@Resource
|
||||
private ResourceManager resourceManager;
|
||||
|
||||
@Resource
|
||||
private ResourceRegistryLockMapper resourceRegistryLockMapper;
|
||||
@Resource
|
||||
private ResourceRegistryLockMapper resourceRegistryLockMapper;
|
||||
|
||||
private static String apiCodeOf(String serviceName, String method, String path) {
|
||||
return serviceName + ":" + method.toUpperCase() + ":" + path;
|
||||
}
|
||||
private static String apiCodeOf(String serviceName, String method, String path) {
|
||||
return serviceName + ":" + method.toUpperCase() + ":" + path;
|
||||
}
|
||||
|
||||
private static ApiTypeFlagEnum methodToTypeFlag(String method) {
|
||||
String m = Objects.requireNonNullElse(method, "").toUpperCase();
|
||||
return switch (m) {
|
||||
case "POST" -> ApiTypeFlagEnum.POST;
|
||||
case "DELETE" -> ApiTypeFlagEnum.DELETE;
|
||||
case "PUT" -> ApiTypeFlagEnum.PUT;
|
||||
case "GET" -> ApiTypeFlagEnum.GET;
|
||||
default -> throw new IllegalArgumentException("Unsupported HTTP method: " + method);
|
||||
};
|
||||
}
|
||||
private static ApiTypeFlagEnum methodToTypeFlag(String method) {
|
||||
String m = Objects.requireNonNullElse(method, "").toUpperCase();
|
||||
return switch (m) {
|
||||
case "POST" -> ApiTypeFlagEnum.POST;
|
||||
case "DELETE" -> ApiTypeFlagEnum.DELETE;
|
||||
case "PUT" -> ApiTypeFlagEnum.PUT;
|
||||
case "GET" -> ApiTypeFlagEnum.GET;
|
||||
default -> throw new IllegalArgumentException("Unsupported HTTP method: " + method);
|
||||
};
|
||||
}
|
||||
|
||||
private static ResourceScopeFlagEnum methodToScopeFlag(Byte apiTypeFlag) {
|
||||
ApiTypeFlagEnum type = ApiTypeFlagEnum.ofIndex(apiTypeFlag);
|
||||
if (type == null) {
|
||||
return ResourceScopeFlagEnum.LIST;
|
||||
}
|
||||
return switch (type) {
|
||||
case POST -> ResourceScopeFlagEnum.ADD;
|
||||
case DELETE -> ResourceScopeFlagEnum.DELETE;
|
||||
case PUT -> ResourceScopeFlagEnum.UPDATE;
|
||||
case GET -> ResourceScopeFlagEnum.LIST;
|
||||
};
|
||||
}
|
||||
private static ResourceScopeFlagEnum methodToScopeFlag(Byte apiTypeFlag) {
|
||||
ApiTypeFlagEnum type = ApiTypeFlagEnum.ofIndex(apiTypeFlag);
|
||||
if (type == null) {
|
||||
return ResourceScopeFlagEnum.LIST;
|
||||
}
|
||||
return switch (type) {
|
||||
case POST -> ResourceScopeFlagEnum.ADD;
|
||||
case DELETE -> ResourceScopeFlagEnum.DELETE;
|
||||
case PUT -> ResourceScopeFlagEnum.UPDATE;
|
||||
case GET -> ResourceScopeFlagEnum.LIST;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResourceRegistrySyncResult sync(ResourceRegistrySyncCommand command) {
|
||||
if (Objects.isNull(command) || StringUtils.isBlank(command.getServiceName())) {
|
||||
throw new IllegalArgumentException("serviceName is required");
|
||||
}
|
||||
String serviceName = command.getServiceName();
|
||||
List<ResourceRegistryScannedApi> scanned = Objects.requireNonNullElse(command.getApis(), List.of());
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResourceRegistrySyncResult sync(ResourceRegistrySyncCommand command) {
|
||||
if (Objects.isNull(command) || StringUtils.isBlank(command.getServiceName())) {
|
||||
throw new IllegalArgumentException("serviceName is required");
|
||||
}
|
||||
String serviceName = command.getServiceName();
|
||||
List<ResourceRegistryScannedApi> scanned = Objects.requireNonNullElse(command.getApis(), List.of());
|
||||
|
||||
resourceRegistryLockMapper.advisoryLock(serviceName);
|
||||
resourceRegistryLockMapper.advisoryLock(serviceName);
|
||||
|
||||
Map<String, ApiDO> existingByCode = loadExisting(serviceName);
|
||||
Map<String, ResourceRegistryScannedApi> scannedByCode = indexScanned(scanned, serviceName);
|
||||
Map<String, ApiDO> existingByCode = loadExisting(serviceName);
|
||||
Map<String, ResourceRegistryScannedApi> scannedByCode = indexScanned(scanned, serviceName);
|
||||
|
||||
// Ensure the service + apiGroup virtual grouping nodes exist before writing
|
||||
// leaves,
|
||||
// so the leaf rows can set parent_resource_id to the right ancestor.
|
||||
Set<String> targetGroups = new LinkedHashSet<>();
|
||||
for (ResourceRegistryScannedApi spec : scannedByCode.values()) {
|
||||
targetGroups.add(Objects.requireNonNullElse(spec.getApiGroup(), ""));
|
||||
}
|
||||
Long serviceNodeId = null;
|
||||
Map<String, Long> groupNodeIds = Map.of();
|
||||
if (!targetGroups.isEmpty()) {
|
||||
serviceNodeId = ensureServiceNode(serviceName);
|
||||
groupNodeIds = ensureGroupNodes(serviceName, serviceNodeId, targetGroups);
|
||||
}
|
||||
// Ensure the service + apiGroup virtual grouping nodes exist before writing
|
||||
// leaves,
|
||||
// so the leaf rows can set parent_resource_id to the right ancestor.
|
||||
Set<String> targetGroups = new LinkedHashSet<>();
|
||||
for (ResourceRegistryScannedApi spec : scannedByCode.values()) {
|
||||
targetGroups.add(Objects.requireNonNullElse(spec.getApiGroup(), ""));
|
||||
}
|
||||
Long serviceNodeId = null;
|
||||
Map<String, Long> groupNodeIds = Map.of();
|
||||
if (!targetGroups.isEmpty()) {
|
||||
serviceNodeId = ensureServiceNode(serviceName);
|
||||
groupNodeIds = ensureGroupNodes(serviceName, serviceNodeId, targetGroups);
|
||||
}
|
||||
|
||||
int inserted = 0;
|
||||
int updated = 0;
|
||||
int deletedCount = 0;
|
||||
int unchanged = 0;
|
||||
int inserted = 0;
|
||||
int updated = 0;
|
||||
int deletedCount = 0;
|
||||
int unchanged = 0;
|
||||
|
||||
List<ApiDO> apisToInsert = new ArrayList<>();
|
||||
List<ResourceDO> resourcesToInsert = new ArrayList<>();
|
||||
List<ApiDO> apisToUpdate = new ArrayList<>();
|
||||
List<ResourceDO> resourcesToUpdate = new ArrayList<>();
|
||||
List<Long> apiIdsToDelete = new ArrayList<>();
|
||||
List<ApiDO> apisToInsert = new ArrayList<>();
|
||||
List<ResourceDO> resourcesToInsert = new ArrayList<>();
|
||||
List<ApiDO> apisToUpdate = new ArrayList<>();
|
||||
List<ResourceDO> resourcesToUpdate = new ArrayList<>();
|
||||
List<Long> apiIdsToDelete = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, ResourceRegistryScannedApi> entry : scannedByCode.entrySet()) {
|
||||
String apiCode = entry.getKey();
|
||||
ResourceRegistryScannedApi spec = entry.getValue();
|
||||
ApiDO existing = existingByCode.remove(apiCode);
|
||||
if (Objects.isNull(existing)) {
|
||||
ApiDO newApi = buildApiDO(spec, apiCode, serviceName);
|
||||
apisToInsert.add(newApi);
|
||||
continue;
|
||||
}
|
||||
if (needsUpdate(existing, spec, apiCode, serviceName)) {
|
||||
applyApiUpdates(existing, spec, apiCode, serviceName);
|
||||
apisToUpdate.add(existing);
|
||||
}
|
||||
else {
|
||||
unchanged++;
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, ResourceRegistryScannedApi> entry : scannedByCode.entrySet()) {
|
||||
String apiCode = entry.getKey();
|
||||
ResourceRegistryScannedApi spec = entry.getValue();
|
||||
ApiDO existing = existingByCode.remove(apiCode);
|
||||
if (Objects.isNull(existing)) {
|
||||
ApiDO newApi = buildApiDO(spec, apiCode, serviceName);
|
||||
apisToInsert.add(newApi);
|
||||
continue;
|
||||
}
|
||||
if (needsUpdate(existing, spec, apiCode, serviceName)) {
|
||||
applyApiUpdates(existing, spec, apiCode, serviceName);
|
||||
apisToUpdate.add(existing);
|
||||
} else {
|
||||
unchanged++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!apisToInsert.isEmpty()) {
|
||||
apiManager.saveBatch(apisToInsert);
|
||||
for (ApiDO api : apisToInsert) {
|
||||
Long groupNodeId = groupNodeIds.get(Objects.requireNonNullElse(api.getApiGroup(), ""));
|
||||
resourcesToInsert.add(buildLeafResourceDO(api, groupNodeId));
|
||||
}
|
||||
resourceManager.saveBatch(resourcesToInsert);
|
||||
inserted = apisToInsert.size();
|
||||
}
|
||||
if (!apisToInsert.isEmpty()) {
|
||||
apiManager.saveBatch(apisToInsert);
|
||||
for (ApiDO api : apisToInsert) {
|
||||
Long groupNodeId = groupNodeIds.get(Objects.requireNonNullElse(api.getApiGroup(), ""));
|
||||
resourcesToInsert.add(buildLeafResourceDO(api, groupNodeId));
|
||||
}
|
||||
resourceManager.saveBatch(resourcesToInsert);
|
||||
inserted = apisToInsert.size();
|
||||
}
|
||||
|
||||
if (!apisToUpdate.isEmpty()) {
|
||||
apiManager.updateBatchById(apisToUpdate);
|
||||
Map<Long, ResourceDO> resourceByEntityId = loadResourcesByEntityIds(
|
||||
apisToUpdate.stream().map(ApiDO::getId).toList());
|
||||
List<ResourceDO> resourcesToBackfill = new ArrayList<>();
|
||||
for (ApiDO api : apisToUpdate) {
|
||||
Long groupNodeId = groupNodeIds.get(Objects.requireNonNullElse(api.getApiGroup(), ""));
|
||||
ResourceDO resourceDO = resourceByEntityId.get(api.getId());
|
||||
if (Objects.isNull(resourceDO)) {
|
||||
resourcesToBackfill.add(buildLeafResourceDO(api, groupNodeId));
|
||||
}
|
||||
else {
|
||||
applyLeafResourceUpdates(resourceDO, api, groupNodeId);
|
||||
resourcesToUpdate.add(resourceDO);
|
||||
}
|
||||
}
|
||||
if (!resourcesToUpdate.isEmpty()) {
|
||||
resourceManager.updateBatchById(resourcesToUpdate);
|
||||
}
|
||||
if (!resourcesToBackfill.isEmpty()) {
|
||||
resourceManager.saveBatch(resourcesToBackfill);
|
||||
}
|
||||
updated = apisToUpdate.size();
|
||||
}
|
||||
if (!apisToUpdate.isEmpty()) {
|
||||
apiManager.updateBatchById(apisToUpdate);
|
||||
Map<Long, ResourceDO> resourceByEntityId = loadResourcesByEntityIds(
|
||||
apisToUpdate.stream().map(ApiDO::getId).toList());
|
||||
List<ResourceDO> resourcesToBackfill = new ArrayList<>();
|
||||
for (ApiDO api : apisToUpdate) {
|
||||
Long groupNodeId = groupNodeIds.get(Objects.requireNonNullElse(api.getApiGroup(), ""));
|
||||
ResourceDO resourceDO = resourceByEntityId.get(api.getId());
|
||||
if (Objects.isNull(resourceDO)) {
|
||||
resourcesToBackfill.add(buildLeafResourceDO(api, groupNodeId));
|
||||
} else {
|
||||
applyLeafResourceUpdates(resourceDO, api, groupNodeId);
|
||||
resourcesToUpdate.add(resourceDO);
|
||||
}
|
||||
}
|
||||
if (!resourcesToUpdate.isEmpty()) {
|
||||
resourceManager.updateBatchById(resourcesToUpdate);
|
||||
}
|
||||
if (!resourcesToBackfill.isEmpty()) {
|
||||
resourceManager.saveBatch(resourcesToBackfill);
|
||||
}
|
||||
updated = apisToUpdate.size();
|
||||
}
|
||||
|
||||
if (command.isDeleteMissing() && !existingByCode.isEmpty()) {
|
||||
for (ApiDO orphan : existingByCode.values()) {
|
||||
apiIdsToDelete.add(orphan.getId());
|
||||
}
|
||||
apiManager.removeByIds(apiIdsToDelete);
|
||||
List<Long> resourceIds = resourceManager
|
||||
.list(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.API.getIndex())
|
||||
.in(ResourceDO::getEntityId, apiIdsToDelete))
|
||||
.stream()
|
||||
.map(ResourceDO::getId)
|
||||
.toList();
|
||||
if (!resourceIds.isEmpty()) {
|
||||
resourceManager.removeByIds(resourceIds);
|
||||
}
|
||||
deletedCount = apiIdsToDelete.size();
|
||||
}
|
||||
if (command.isDeleteMissing() && !existingByCode.isEmpty()) {
|
||||
for (ApiDO orphan : existingByCode.values()) {
|
||||
apiIdsToDelete.add(orphan.getId());
|
||||
}
|
||||
apiManager.removeByIds(apiIdsToDelete);
|
||||
List<Long> resourceIds = resourceManager
|
||||
.list(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.API.getIndex())
|
||||
.in(ResourceDO::getEntityId, apiIdsToDelete))
|
||||
.stream()
|
||||
.map(ResourceDO::getId)
|
||||
.toList();
|
||||
if (!resourceIds.isEmpty()) {
|
||||
resourceManager.removeByIds(resourceIds);
|
||||
}
|
||||
deletedCount = apiIdsToDelete.size();
|
||||
}
|
||||
|
||||
// Sweep orphaned apiGroup / service virtual nodes that no longer cover any leaf.
|
||||
int removedGroupNodes = cleanupOrphanGroupingNodes(serviceName);
|
||||
// Sweep orphaned apiGroup / service virtual nodes that no longer cover any leaf.
|
||||
int removedGroupNodes = cleanupOrphanGroupingNodes(serviceName);
|
||||
|
||||
log.info(
|
||||
"Resource registry sync [{}]: inserted={}, updated={}, deleted={}, unchanged={}, prunedGroupingNodes={}",
|
||||
serviceName, inserted, updated, deletedCount, unchanged, removedGroupNodes);
|
||||
log.info(
|
||||
"Resource registry sync [{}]: inserted={}, updated={}, deleted={}, unchanged={}, prunedGroupingNodes={}",
|
||||
serviceName, inserted, updated, deletedCount, unchanged, removedGroupNodes);
|
||||
|
||||
return ResourceRegistrySyncResult.builder()
|
||||
.inserted(inserted)
|
||||
.updated(updated)
|
||||
.deleted(deletedCount)
|
||||
.unchanged(unchanged)
|
||||
.build();
|
||||
}
|
||||
return ResourceRegistrySyncResult.builder()
|
||||
.inserted(inserted)
|
||||
.updated(updated)
|
||||
.deleted(deletedCount)
|
||||
.unchanged(unchanged)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Map<String, ApiDO> loadExisting(String serviceName) {
|
||||
List<ApiDO> existing = apiManager.list(Wrappers.<ApiDO>lambdaQuery().eq(ApiDO::getServiceName, serviceName));
|
||||
Map<String, ApiDO> map = new HashMap<>(existing.size());
|
||||
for (ApiDO api : existing) {
|
||||
map.put(api.getApiCode(), api);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
private Map<String, ApiDO> loadExisting(String serviceName) {
|
||||
List<ApiDO> existing = apiManager.list(Wrappers.<ApiDO>lambdaQuery().eq(ApiDO::getServiceName, serviceName));
|
||||
Map<String, ApiDO> map = new HashMap<>(existing.size());
|
||||
for (ApiDO api : existing) {
|
||||
map.put(api.getApiCode(), api);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<Long, ResourceDO> loadResourcesByEntityIds(List<Long> entityIds) {
|
||||
if (entityIds.isEmpty()) {
|
||||
return Map.of();
|
||||
}
|
||||
// Exclude grouping nodes (entity_id=0) so the caller only sees real leaves.
|
||||
List<ResourceDO> rows = resourceManager.list(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.API.getIndex())
|
||||
.in(ResourceDO::getEntityId, entityIds)
|
||||
.ne(ResourceDO::getEntityId, 0L));
|
||||
Map<Long, ResourceDO> map = new HashMap<>(rows.size());
|
||||
for (ResourceDO row : rows) {
|
||||
map.put(row.getEntityId(), row);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
private Map<Long, ResourceDO> loadResourcesByEntityIds(List<Long> entityIds) {
|
||||
if (entityIds.isEmpty()) {
|
||||
return Map.of();
|
||||
}
|
||||
// Exclude grouping nodes (entity_id=0) so the caller only sees real leaves.
|
||||
List<ResourceDO> rows = resourceManager.list(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.API.getIndex())
|
||||
.in(ResourceDO::getEntityId, entityIds)
|
||||
.ne(ResourceDO::getEntityId, 0L));
|
||||
Map<Long, ResourceDO> map = new HashMap<>(rows.size());
|
||||
for (ResourceDO row : rows) {
|
||||
map.put(row.getEntityId(), row);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<String, ResourceRegistryScannedApi> indexScanned(List<ResourceRegistryScannedApi> scanned,
|
||||
String serviceName) {
|
||||
Map<String, ResourceRegistryScannedApi> map = new HashMap<>(scanned.size());
|
||||
for (ResourceRegistryScannedApi spec : scanned) {
|
||||
String code = apiCodeOf(serviceName, spec.getMethod(), spec.getPath());
|
||||
map.put(code, spec);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
private Map<String, ResourceRegistryScannedApi> indexScanned(List<ResourceRegistryScannedApi> scanned,
|
||||
String serviceName) {
|
||||
Map<String, ResourceRegistryScannedApi> map = new HashMap<>(scanned.size());
|
||||
for (ResourceRegistryScannedApi spec : scanned) {
|
||||
String code = apiCodeOf(serviceName, spec.getMethod(), spec.getPath());
|
||||
map.put(code, spec);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private ApiDO buildApiDO(ResourceRegistryScannedApi spec, String apiCode, String serviceName) {
|
||||
ApiDO api = new ApiDO();
|
||||
api.setServiceName(serviceName);
|
||||
api.setApiTypeFlag(methodToTypeFlag(spec.getMethod()).getIndex());
|
||||
api.setApiName(spec.getApiName());
|
||||
api.setApiCode(apiCode);
|
||||
api.setApiGroup(Objects.requireNonNullElse(spec.getApiGroup(), ""));
|
||||
api.setApiExt(buildApiExt(spec));
|
||||
api.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
api.setRemark(Objects.requireNonNullElse(spec.getRemark(), ""));
|
||||
return api;
|
||||
}
|
||||
private ApiDO buildApiDO(ResourceRegistryScannedApi spec, String apiCode, String serviceName) {
|
||||
ApiDO api = new ApiDO();
|
||||
api.setServiceName(serviceName);
|
||||
api.setApiTypeFlag(methodToTypeFlag(spec.getMethod()).getIndex());
|
||||
api.setApiName(spec.getApiName());
|
||||
api.setApiCode(apiCode);
|
||||
api.setApiGroup(Objects.requireNonNullElse(spec.getApiGroup(), ""));
|
||||
api.setApiExt(buildApiExt(spec));
|
||||
api.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
api.setRemark(Objects.requireNonNullElse(spec.getRemark(), ""));
|
||||
return api;
|
||||
}
|
||||
|
||||
private ResourceDO buildLeafResourceDO(ApiDO api, Long groupNodeId) {
|
||||
ResourceDO resource = new ResourceDO();
|
||||
resource.setParentResourceId(Objects.requireNonNullElse(groupNodeId, 0L));
|
||||
resource.setResourceName(api.getApiName());
|
||||
resource.setResourceCode(RESOURCE_CODE_PREFIX + api.getApiCode());
|
||||
resource.setResourceTypeFlag(ResourceTypeFlagEnum.API.getIndex());
|
||||
resource.setResourceScopeFlag(methodToScopeFlag(api.getApiTypeFlag()).getIndex());
|
||||
resource.setEntityId(api.getId());
|
||||
resource.setResourceExt(new JsonExt());
|
||||
resource.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
resource.setRemark(Objects.requireNonNullElse(api.getRemark(), ""));
|
||||
return resource;
|
||||
}
|
||||
private ResourceDO buildLeafResourceDO(ApiDO api, Long groupNodeId) {
|
||||
ResourceDO resource = new ResourceDO();
|
||||
resource.setParentResourceId(Objects.requireNonNullElse(groupNodeId, 0L));
|
||||
resource.setResourceName(api.getApiName());
|
||||
resource.setResourceCode(RESOURCE_CODE_PREFIX + api.getApiCode());
|
||||
resource.setResourceTypeFlag(ResourceTypeFlagEnum.API.getIndex());
|
||||
resource.setResourceScopeFlag(methodToScopeFlag(api.getApiTypeFlag()).getIndex());
|
||||
resource.setEntityId(api.getId());
|
||||
resource.setResourceExt(new JsonExt());
|
||||
resource.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
resource.setRemark(Objects.requireNonNullElse(api.getRemark(), ""));
|
||||
return resource;
|
||||
}
|
||||
|
||||
private boolean needsUpdate(ApiDO existing, ResourceRegistryScannedApi spec, String apiCode, String serviceName) {
|
||||
byte expectedType = methodToTypeFlag(spec.getMethod()).getIndex();
|
||||
if (existing.getApiTypeFlag() == null || existing.getApiTypeFlag() != expectedType) {
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(existing.getApiName(), spec.getApiName())) {
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(existing.getServiceName(), serviceName)) {
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(existing.getApiCode(), apiCode)) {
|
||||
return true;
|
||||
}
|
||||
String expectedGroup = Objects.requireNonNullElse(spec.getApiGroup(), "");
|
||||
if (!Objects.equals(Objects.requireNonNullElse(existing.getApiGroup(), ""), expectedGroup)) {
|
||||
return true;
|
||||
}
|
||||
ApiExt.Content expectedContent = buildContent(spec);
|
||||
ApiExt.Content currentContent = parseContent(existing.getApiExt());
|
||||
if (!equalsContent(currentContent, expectedContent)) {
|
||||
return true;
|
||||
}
|
||||
String expectedRemark = Objects.requireNonNullElse(spec.getRemark(), "");
|
||||
return !Objects.equals(Objects.requireNonNullElse(existing.getRemark(), ""), expectedRemark);
|
||||
}
|
||||
private boolean needsUpdate(ApiDO existing, ResourceRegistryScannedApi spec, String apiCode, String serviceName) {
|
||||
byte expectedType = methodToTypeFlag(spec.getMethod()).getIndex();
|
||||
if (existing.getApiTypeFlag() == null || existing.getApiTypeFlag() != expectedType) {
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(existing.getApiName(), spec.getApiName())) {
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(existing.getServiceName(), serviceName)) {
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(existing.getApiCode(), apiCode)) {
|
||||
return true;
|
||||
}
|
||||
String expectedGroup = Objects.requireNonNullElse(spec.getApiGroup(), "");
|
||||
if (!Objects.equals(Objects.requireNonNullElse(existing.getApiGroup(), ""), expectedGroup)) {
|
||||
return true;
|
||||
}
|
||||
ApiExt.Content expectedContent = buildContent(spec);
|
||||
ApiExt.Content currentContent = parseContent(existing.getApiExt());
|
||||
if (!equalsContent(currentContent, expectedContent)) {
|
||||
return true;
|
||||
}
|
||||
String expectedRemark = Objects.requireNonNullElse(spec.getRemark(), "");
|
||||
return !Objects.equals(Objects.requireNonNullElse(existing.getRemark(), ""), expectedRemark);
|
||||
}
|
||||
|
||||
private void applyApiUpdates(ApiDO existing, ResourceRegistryScannedApi spec, String apiCode, String serviceName) {
|
||||
existing.setServiceName(serviceName);
|
||||
existing.setApiCode(apiCode);
|
||||
existing.setApiGroup(Objects.requireNonNullElse(spec.getApiGroup(), ""));
|
||||
existing.setApiTypeFlag(methodToTypeFlag(spec.getMethod()).getIndex());
|
||||
existing.setApiName(spec.getApiName());
|
||||
existing.setApiExt(buildApiExt(spec));
|
||||
existing.setRemark(Objects.requireNonNullElse(spec.getRemark(), ""));
|
||||
existing.setOperateTime(null);
|
||||
}
|
||||
private void applyApiUpdates(ApiDO existing, ResourceRegistryScannedApi spec, String apiCode, String serviceName) {
|
||||
existing.setServiceName(serviceName);
|
||||
existing.setApiCode(apiCode);
|
||||
existing.setApiGroup(Objects.requireNonNullElse(spec.getApiGroup(), ""));
|
||||
existing.setApiTypeFlag(methodToTypeFlag(spec.getMethod()).getIndex());
|
||||
existing.setApiName(spec.getApiName());
|
||||
existing.setApiExt(buildApiExt(spec));
|
||||
existing.setRemark(Objects.requireNonNullElse(spec.getRemark(), ""));
|
||||
existing.setOperateTime(null);
|
||||
}
|
||||
|
||||
private void applyLeafResourceUpdates(ResourceDO resource, ApiDO api, Long groupNodeId) {
|
||||
resource.setParentResourceId(Objects.requireNonNullElse(groupNodeId, 0L));
|
||||
resource.setResourceName(api.getApiName());
|
||||
resource.setResourceCode(RESOURCE_CODE_PREFIX + api.getApiCode());
|
||||
resource.setResourceScopeFlag(methodToScopeFlag(api.getApiTypeFlag()).getIndex());
|
||||
resource.setRemark(Objects.requireNonNullElse(api.getRemark(), ""));
|
||||
resource.setOperateTime(null);
|
||||
}
|
||||
private void applyLeafResourceUpdates(ResourceDO resource, ApiDO api, Long groupNodeId) {
|
||||
resource.setParentResourceId(Objects.requireNonNullElse(groupNodeId, 0L));
|
||||
resource.setResourceName(api.getApiName());
|
||||
resource.setResourceCode(RESOURCE_CODE_PREFIX + api.getApiCode());
|
||||
resource.setResourceScopeFlag(methodToScopeFlag(api.getApiTypeFlag()).getIndex());
|
||||
resource.setRemark(Objects.requireNonNullElse(api.getRemark(), ""));
|
||||
resource.setOperateTime(null);
|
||||
}
|
||||
|
||||
private Long ensureServiceNode(String serviceName) {
|
||||
String code = SERVICE_NODE_CODE_PREFIX + serviceName;
|
||||
ResourceDO existing = findByResourceCode(code);
|
||||
if (existing != null) {
|
||||
return existing.getId();
|
||||
}
|
||||
ResourceDO node = new ResourceDO();
|
||||
node.setParentResourceId(0L);
|
||||
node.setResourceName(serviceName);
|
||||
node.setResourceCode(code);
|
||||
node.setResourceTypeFlag(ResourceTypeFlagEnum.API.getIndex());
|
||||
node.setResourceScopeFlag(ResourceScopeFlagEnum.LIST.getIndex());
|
||||
node.setEntityId(0L);
|
||||
node.setResourceExt(new JsonExt());
|
||||
node.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
node.setRemark("Service grouping node (auto-registered)");
|
||||
resourceManager.save(node);
|
||||
return node.getId();
|
||||
}
|
||||
private Long ensureServiceNode(String serviceName) {
|
||||
String code = SERVICE_NODE_CODE_PREFIX + serviceName;
|
||||
ResourceDO existing = findByResourceCode(code);
|
||||
if (existing != null) {
|
||||
return existing.getId();
|
||||
}
|
||||
ResourceDO node = new ResourceDO();
|
||||
node.setParentResourceId(0L);
|
||||
node.setResourceName(serviceName);
|
||||
node.setResourceCode(code);
|
||||
node.setResourceTypeFlag(ResourceTypeFlagEnum.API.getIndex());
|
||||
node.setResourceScopeFlag(ResourceScopeFlagEnum.LIST.getIndex());
|
||||
node.setEntityId(0L);
|
||||
node.setResourceExt(new JsonExt());
|
||||
node.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
node.setRemark("Service grouping node (auto-registered)");
|
||||
resourceManager.save(node);
|
||||
return node.getId();
|
||||
}
|
||||
|
||||
private Map<String, Long> ensureGroupNodes(String serviceName, Long serviceNodeId, Set<String> targetGroups) {
|
||||
Map<String, Long> result = new HashMap<>(targetGroups.size());
|
||||
for (String group : targetGroups) {
|
||||
String code = GROUP_NODE_CODE_PREFIX + serviceName + ":" + group;
|
||||
ResourceDO existing = findByResourceCode(code);
|
||||
if (existing == null) {
|
||||
ResourceDO node = new ResourceDO();
|
||||
node.setParentResourceId(serviceNodeId);
|
||||
node.setResourceName(group.isEmpty() ? "(ungrouped)" : group);
|
||||
node.setResourceCode(code);
|
||||
node.setResourceTypeFlag(ResourceTypeFlagEnum.API.getIndex());
|
||||
node.setResourceScopeFlag(ResourceScopeFlagEnum.LIST.getIndex());
|
||||
node.setEntityId(0L);
|
||||
node.setResourceExt(new JsonExt());
|
||||
node.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
node.setRemark("API grouping node (auto-registered)");
|
||||
resourceManager.save(node);
|
||||
result.put(group, node.getId());
|
||||
}
|
||||
else {
|
||||
if (!Objects.equals(existing.getParentResourceId(), serviceNodeId)) {
|
||||
existing.setParentResourceId(serviceNodeId);
|
||||
existing.setOperateTime(null);
|
||||
resourceManager.updateById(existing);
|
||||
}
|
||||
result.put(group, existing.getId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private Map<String, Long> ensureGroupNodes(String serviceName, Long serviceNodeId, Set<String> targetGroups) {
|
||||
Map<String, Long> result = new HashMap<>(targetGroups.size());
|
||||
for (String group : targetGroups) {
|
||||
String code = GROUP_NODE_CODE_PREFIX + serviceName + ":" + group;
|
||||
ResourceDO existing = findByResourceCode(code);
|
||||
if (existing == null) {
|
||||
ResourceDO node = new ResourceDO();
|
||||
node.setParentResourceId(serviceNodeId);
|
||||
node.setResourceName(group.isEmpty() ? "(ungrouped)" : group);
|
||||
node.setResourceCode(code);
|
||||
node.setResourceTypeFlag(ResourceTypeFlagEnum.API.getIndex());
|
||||
node.setResourceScopeFlag(ResourceScopeFlagEnum.LIST.getIndex());
|
||||
node.setEntityId(0L);
|
||||
node.setResourceExt(new JsonExt());
|
||||
node.setEnableFlag(EnableFlagEnum.ENABLE.getIndex());
|
||||
node.setRemark("API grouping node (auto-registered)");
|
||||
resourceManager.save(node);
|
||||
result.put(group, node.getId());
|
||||
} else {
|
||||
if (!Objects.equals(existing.getParentResourceId(), serviceNodeId)) {
|
||||
existing.setParentResourceId(serviceNodeId);
|
||||
existing.setOperateTime(null);
|
||||
resourceManager.updateById(existing);
|
||||
}
|
||||
result.put(group, existing.getId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ResourceDO findByResourceCode(String code) {
|
||||
return resourceManager
|
||||
.getOne(Wrappers.<ResourceDO>lambdaQuery().eq(ResourceDO::getResourceCode, code).last("LIMIT 1"));
|
||||
}
|
||||
private ResourceDO findByResourceCode(String code) {
|
||||
return resourceManager
|
||||
.getOne(Wrappers.<ResourceDO>lambdaQuery().eq(ResourceDO::getResourceCode, code).last("LIMIT 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Soft-delete apiGroup nodes that no longer have any leaf, then the service node
|
||||
* itself if it ends up with no remaining group children. Bounded to the given
|
||||
* serviceName so concurrent sync of sibling services is unaffected.
|
||||
*/
|
||||
private int cleanupOrphanGroupingNodes(String serviceName) {
|
||||
int removed = 0;
|
||||
List<ResourceDO> groupNodes = resourceManager.list(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.likeRight(ResourceDO::getResourceCode, GROUP_NODE_CODE_PREFIX + serviceName + ":")
|
||||
.eq(ResourceDO::getEntityId, 0L));
|
||||
List<Long> idsToDrop = new ArrayList<>();
|
||||
for (ResourceDO node : groupNodes) {
|
||||
long children = resourceManager
|
||||
.count(Wrappers.<ResourceDO>lambdaQuery().eq(ResourceDO::getParentResourceId, node.getId()));
|
||||
if (children == 0) {
|
||||
idsToDrop.add(node.getId());
|
||||
}
|
||||
}
|
||||
if (!idsToDrop.isEmpty()) {
|
||||
resourceManager.removeByIds(idsToDrop);
|
||||
removed += idsToDrop.size();
|
||||
}
|
||||
ResourceDO serviceNode = findByResourceCode(SERVICE_NODE_CODE_PREFIX + serviceName);
|
||||
if (serviceNode != null) {
|
||||
long children = resourceManager
|
||||
.count(Wrappers.<ResourceDO>lambdaQuery().eq(ResourceDO::getParentResourceId, serviceNode.getId()));
|
||||
if (children == 0) {
|
||||
resourceManager.removeById(serviceNode.getId());
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
/**
|
||||
* Soft-delete apiGroup nodes that no longer have any leaf, then the service node
|
||||
* itself if it ends up with no remaining group children. Bounded to the given
|
||||
* serviceName so concurrent sync of sibling services is unaffected.
|
||||
*/
|
||||
private int cleanupOrphanGroupingNodes(String serviceName) {
|
||||
int removed = 0;
|
||||
List<ResourceDO> groupNodes = resourceManager.list(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.likeRight(ResourceDO::getResourceCode, GROUP_NODE_CODE_PREFIX + serviceName + ":")
|
||||
.eq(ResourceDO::getEntityId, 0L));
|
||||
List<Long> idsToDrop = new ArrayList<>();
|
||||
for (ResourceDO node : groupNodes) {
|
||||
long children = resourceManager
|
||||
.count(Wrappers.<ResourceDO>lambdaQuery().eq(ResourceDO::getParentResourceId, node.getId()));
|
||||
if (children == 0) {
|
||||
idsToDrop.add(node.getId());
|
||||
}
|
||||
}
|
||||
if (!idsToDrop.isEmpty()) {
|
||||
resourceManager.removeByIds(idsToDrop);
|
||||
removed += idsToDrop.size();
|
||||
}
|
||||
ResourceDO serviceNode = findByResourceCode(SERVICE_NODE_CODE_PREFIX + serviceName);
|
||||
if (serviceNode != null) {
|
||||
long children = resourceManager
|
||||
.count(Wrappers.<ResourceDO>lambdaQuery().eq(ResourceDO::getParentResourceId, serviceNode.getId()));
|
||||
if (children == 0) {
|
||||
resourceManager.removeById(serviceNode.getId());
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
private JsonExt buildApiExt(ResourceRegistryScannedApi spec) {
|
||||
JsonExt ext = new JsonExt();
|
||||
ext.setVersion(1);
|
||||
ext.setContent(JsonUtil.toJsonString(buildContent(spec)));
|
||||
return ext;
|
||||
}
|
||||
private JsonExt buildApiExt(ResourceRegistryScannedApi spec) {
|
||||
JsonExt ext = new JsonExt();
|
||||
ext.setVersion(1);
|
||||
ext.setContent(JsonUtil.toJsonString(buildContent(spec)));
|
||||
return ext;
|
||||
}
|
||||
|
||||
private ApiExt.Content buildContent(ResourceRegistryScannedApi spec) {
|
||||
ApiExt.Content content = new ApiExt.Content();
|
||||
content.setTitle(spec.getTitle());
|
||||
content.setUrl(spec.getPath());
|
||||
content.setRemark(spec.getRemark());
|
||||
return content;
|
||||
}
|
||||
private ApiExt.Content buildContent(ResourceRegistryScannedApi spec) {
|
||||
ApiExt.Content content = new ApiExt.Content();
|
||||
content.setTitle(spec.getTitle());
|
||||
content.setUrl(spec.getPath());
|
||||
content.setRemark(spec.getRemark());
|
||||
return content;
|
||||
}
|
||||
|
||||
private ApiExt.Content parseContent(JsonExt ext) {
|
||||
if (Objects.isNull(ext) || StringUtils.isBlank(ext.getContent())) {
|
||||
return null;
|
||||
}
|
||||
return JsonUtil.parseObject(ext.getContent(), ApiExt.Content.class);
|
||||
}
|
||||
private ApiExt.Content parseContent(JsonExt ext) {
|
||||
if (Objects.isNull(ext) || StringUtils.isBlank(ext.getContent())) {
|
||||
return null;
|
||||
}
|
||||
return JsonUtil.parseObject(ext.getContent(), ApiExt.Content.class);
|
||||
}
|
||||
|
||||
private boolean equalsContent(ApiExt.Content a, ApiExt.Content b) {
|
||||
if (a == null || b == null) {
|
||||
return a == null && b == null;
|
||||
}
|
||||
return Objects.equals(a.getTitle(), b.getTitle()) && Objects.equals(a.getUrl(), b.getUrl())
|
||||
&& Objects.equals(a.getRemark(), b.getRemark());
|
||||
}
|
||||
private boolean equalsContent(ApiExt.Content a, ApiExt.Content b) {
|
||||
if (a == null || b == null) {
|
||||
return a == null && b == null;
|
||||
}
|
||||
return Objects.equals(a.getTitle(), b.getTitle()) && Objects.equals(a.getUrl(), b.getUrl())
|
||||
&& Objects.equals(a.getRemark(), b.getRemark());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncMenuResource(MenuDO menu) {
|
||||
if (menu == null || menu.getId() == null) {
|
||||
return;
|
||||
}
|
||||
String code = MENU_RESOURCE_CODE_PREFIX + Objects.requireNonNullElse(menu.getMenuCode(), "");
|
||||
// Prefer lookup by entity_id so a menu_code rename still resolves the mirror.
|
||||
ResourceDO existing = resourceManager.getOne(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.MENU.getIndex())
|
||||
.eq(ResourceDO::getEntityId, menu.getId())
|
||||
.last("LIMIT 1"));
|
||||
Long parentResourceId = resolveMenuParentResourceId(menu.getParentMenuId());
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncMenuResource(MenuDO menu) {
|
||||
if (menu == null || menu.getId() == null) {
|
||||
return;
|
||||
}
|
||||
String code = MENU_RESOURCE_CODE_PREFIX + Objects.requireNonNullElse(menu.getMenuCode(), "");
|
||||
// Prefer lookup by entity_id so a menu_code rename still resolves the mirror.
|
||||
ResourceDO existing = resourceManager.getOne(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.MENU.getIndex())
|
||||
.eq(ResourceDO::getEntityId, menu.getId())
|
||||
.last("LIMIT 1"));
|
||||
Long parentResourceId = resolveMenuParentResourceId(menu.getParentMenuId());
|
||||
|
||||
if (existing == null) {
|
||||
ResourceDO mirror = new ResourceDO();
|
||||
mirror.setParentResourceId(parentResourceId);
|
||||
mirror.setResourceName(Objects.requireNonNullElse(menu.getMenuName(), ""));
|
||||
mirror.setResourceCode(code);
|
||||
mirror.setResourceTypeFlag(ResourceTypeFlagEnum.MENU.getIndex());
|
||||
mirror.setResourceScopeFlag(ResourceScopeFlagEnum.LIST.getIndex());
|
||||
mirror.setEntityId(menu.getId());
|
||||
mirror.setResourceExt(new JsonExt());
|
||||
mirror.setEnableFlag(Objects.requireNonNullElse(menu.getEnableFlag(), EnableFlagEnum.ENABLE.getIndex()));
|
||||
mirror.setRemark(Objects.requireNonNullElse(menu.getRemark(), ""));
|
||||
resourceManager.save(mirror);
|
||||
log.info("Menu resource mirror inserted: menuId={}, code={}", menu.getId(), code);
|
||||
}
|
||||
else {
|
||||
existing.setParentResourceId(parentResourceId);
|
||||
existing.setResourceName(Objects.requireNonNullElse(menu.getMenuName(), ""));
|
||||
existing.setResourceCode(code);
|
||||
existing.setEnableFlag(Objects.requireNonNullElse(menu.getEnableFlag(), EnableFlagEnum.ENABLE.getIndex()));
|
||||
existing.setRemark(Objects.requireNonNullElse(menu.getRemark(), ""));
|
||||
existing.setOperateTime(null);
|
||||
resourceManager.updateById(existing);
|
||||
}
|
||||
}
|
||||
if (existing == null) {
|
||||
ResourceDO mirror = new ResourceDO();
|
||||
mirror.setParentResourceId(parentResourceId);
|
||||
mirror.setResourceName(Objects.requireNonNullElse(menu.getMenuName(), ""));
|
||||
mirror.setResourceCode(code);
|
||||
mirror.setResourceTypeFlag(ResourceTypeFlagEnum.MENU.getIndex());
|
||||
mirror.setResourceScopeFlag(ResourceScopeFlagEnum.LIST.getIndex());
|
||||
mirror.setEntityId(menu.getId());
|
||||
mirror.setResourceExt(new JsonExt());
|
||||
mirror.setEnableFlag(Objects.requireNonNullElse(menu.getEnableFlag(), EnableFlagEnum.ENABLE.getIndex()));
|
||||
mirror.setRemark(Objects.requireNonNullElse(menu.getRemark(), ""));
|
||||
resourceManager.save(mirror);
|
||||
log.info("Menu resource mirror inserted: menuId={}, code={}", menu.getId(), code);
|
||||
} else {
|
||||
existing.setParentResourceId(parentResourceId);
|
||||
existing.setResourceName(Objects.requireNonNullElse(menu.getMenuName(), ""));
|
||||
existing.setResourceCode(code);
|
||||
existing.setEnableFlag(Objects.requireNonNullElse(menu.getEnableFlag(), EnableFlagEnum.ENABLE.getIndex()));
|
||||
existing.setRemark(Objects.requireNonNullElse(menu.getRemark(), ""));
|
||||
existing.setOperateTime(null);
|
||||
resourceManager.updateById(existing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeMenuResource(Long menuId) {
|
||||
if (menuId == null) {
|
||||
return;
|
||||
}
|
||||
ResourceDO existing = resourceManager.getOne(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.MENU.getIndex())
|
||||
.eq(ResourceDO::getEntityId, menuId)
|
||||
.last("LIMIT 1"));
|
||||
if (existing != null) {
|
||||
resourceManager.removeById(existing.getId());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeMenuResource(Long menuId) {
|
||||
if (menuId == null) {
|
||||
return;
|
||||
}
|
||||
ResourceDO existing = resourceManager.getOne(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.MENU.getIndex())
|
||||
.eq(ResourceDO::getEntityId, menuId)
|
||||
.last("LIMIT 1"));
|
||||
if (existing != null) {
|
||||
resourceManager.removeById(existing.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private Long resolveMenuParentResourceId(Long parentMenuId) {
|
||||
if (parentMenuId == null || parentMenuId == 0L) {
|
||||
return 0L;
|
||||
}
|
||||
ResourceDO parent = resourceManager.getOne(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.MENU.getIndex())
|
||||
.eq(ResourceDO::getEntityId, parentMenuId)
|
||||
.last("LIMIT 1"));
|
||||
return parent == null ? 0L : parent.getId();
|
||||
}
|
||||
private Long resolveMenuParentResourceId(Long parentMenuId) {
|
||||
if (parentMenuId == null || parentMenuId == 0L) {
|
||||
return 0L;
|
||||
}
|
||||
ResourceDO parent = resourceManager.getOne(Wrappers.<ResourceDO>lambdaQuery()
|
||||
.eq(ResourceDO::getResourceTypeFlag, ResourceTypeFlagEnum.MENU.getIndex())
|
||||
.eq(ResourceDO::getEntityId, parentMenuId)
|
||||
.last("LIMIT 1"));
|
||||
return parent == null ? 0L : parent.getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+63
-64
@@ -49,77 +49,76 @@ import java.util.UUID;
|
||||
@Service
|
||||
public class TokenServiceImpl implements TokenService {
|
||||
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
|
||||
@Resource
|
||||
private UserLoginService userLoginService;
|
||||
@Resource
|
||||
private UserLoginService userLoginService;
|
||||
|
||||
@Resource
|
||||
private UserPasswordService userPasswordService;
|
||||
@Resource
|
||||
private UserPasswordService userPasswordService;
|
||||
|
||||
@Resource
|
||||
private TenantBindService tenantBindService;
|
||||
@Resource
|
||||
private TenantBindService tenantBindService;
|
||||
|
||||
@Override
|
||||
public String generateSalt(String loginName, String tenantCode) {
|
||||
TenantBO tenantBO = tenantService.selectByCode(tenantCode);
|
||||
if (Objects.isNull(tenantBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
@Override
|
||||
public String generateSalt(String loginName, String tenantCode) {
|
||||
TenantBO tenantBO = tenantService.selectByCode(tenantCode);
|
||||
if (Objects.isNull(tenantBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateToken(String loginName, String salt, String password, String tenantCode) {
|
||||
TenantBO tenantBO = tenantService.selectByCode(tenantCode);
|
||||
if (Objects.isNull(tenantBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
UserLoginBO userLogin = userLoginService.selectByLoginName(loginName, false);
|
||||
if (Objects.isNull(userLogin)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
TenantBindBO tenantBindBO = tenantBindService.selectByTenantIdAndUserId(tenantBO.getId(),
|
||||
userLogin.getUserId());
|
||||
if (Objects.isNull(tenantBindBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
UserPasswordBO userPasswordBO = userPasswordService.selectById(userLogin.getUserPasswordId());
|
||||
if (Objects.isNull(userPasswordBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
if (StringUtils.isEmpty(salt)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
String md5Password = DecodeUtil.md5(userPasswordBO.getLoginPassword(), salt);
|
||||
if (!md5Password.equals(password)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
return KeyUtil.generateToken(loginName, salt, tenantBO.getId());
|
||||
}
|
||||
@Override
|
||||
public String generateToken(String loginName, String salt, String password, String tenantCode) {
|
||||
TenantBO tenantBO = tenantService.selectByCode(tenantCode);
|
||||
if (Objects.isNull(tenantBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
UserLoginBO userLogin = userLoginService.selectByLoginName(loginName, false);
|
||||
if (Objects.isNull(userLogin)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
TenantBindBO tenantBindBO = tenantBindService.selectByTenantIdAndUserId(tenantBO.getId(),
|
||||
userLogin.getUserId());
|
||||
if (Objects.isNull(tenantBindBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
UserPasswordBO userPasswordBO = userPasswordService.selectById(userLogin.getUserPasswordId());
|
||||
if (Objects.isNull(userPasswordBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
if (StringUtils.isEmpty(salt)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
String md5Password = DecodeUtil.md5(userPasswordBO.getLoginPassword(), salt);
|
||||
if (!md5Password.equals(password)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
return KeyUtil.generateToken(loginName, salt, tenantBO.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenValid checkValid(String loginName, String salt, String token, String tenantCode) {
|
||||
TenantBO tenantBO = tenantService.selectByCode(tenantCode);
|
||||
if (Objects.isNull(tenantBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
@Override
|
||||
public TokenValid checkValid(String loginName, String salt, String token, String tenantCode) {
|
||||
TenantBO tenantBO = tenantService.selectByCode(tenantCode);
|
||||
if (Objects.isNull(tenantBO)) {
|
||||
throw new UnAuthorizedException(ExceptionConstant.NO_AVAILABLE_AUTH);
|
||||
}
|
||||
|
||||
TokenValid tokenValid = new TokenValid(false, null);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return tokenValid;
|
||||
}
|
||||
TokenValid tokenValid = new TokenValid(false, null);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return tokenValid;
|
||||
}
|
||||
|
||||
try {
|
||||
Claims claims = KeyUtil.parserToken(loginName, salt, token, tenantBO.getId());
|
||||
tokenValid.setValid(true);
|
||||
tokenValid.setExpireTime(claims.getExpiration());
|
||||
return tokenValid;
|
||||
}
|
||||
catch (Exception e) {
|
||||
return tokenValid;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Claims claims = KeyUtil.parserToken(loginName, salt, token, tenantBO.getId());
|
||||
tokenValid.setValid(true);
|
||||
tokenValid.setExpireTime(claims.getExpiration());
|
||||
return tokenValid;
|
||||
} catch (Exception e) {
|
||||
return tokenValid;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+63
-68
@@ -49,80 +49,75 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.API_URL_PREFIX)
|
||||
public class ApiController implements BaseController {
|
||||
|
||||
private final ApiBuilder apiBuilder;
|
||||
private final ApiBuilder apiBuilder;
|
||||
|
||||
private final ApiService apiService;
|
||||
private final ApiService apiService;
|
||||
|
||||
public ApiController(ApiBuilder apiBuilder, ApiService apiService) {
|
||||
this.apiBuilder = apiBuilder;
|
||||
this.apiService = apiService;
|
||||
}
|
||||
public ApiController(ApiBuilder apiBuilder, ApiService apiService) {
|
||||
this.apiBuilder = apiBuilder;
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody ApiVO entityVO) {
|
||||
try {
|
||||
ApiBO entityBO = apiBuilder.buildBOByVO(entityVO);
|
||||
apiService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody ApiVO entityVO) {
|
||||
try {
|
||||
ApiBO entityBO = apiBuilder.buildBOByVO(entityVO);
|
||||
apiService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
apiService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
apiService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody ApiVO entityVO) {
|
||||
try {
|
||||
ApiBO entityBO = apiBuilder.buildBOByVO(entityVO);
|
||||
apiService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody ApiVO entityVO) {
|
||||
try {
|
||||
ApiBO entityBO = apiBuilder.buildBOByVO(entityVO);
|
||||
apiService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<ApiVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
ApiBO entityBO = apiService.selectById(id);
|
||||
ApiVO entityVO = apiBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<ApiVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
ApiBO entityBO = apiService.selectById(id);
|
||||
ApiVO entityVO = apiBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<ApiVO>>> list(@RequestBody(required = false) ApiQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new ApiQuery();
|
||||
}
|
||||
Page<ApiBO> entityPageBO = apiService.selectByPage(entityQuery);
|
||||
Page<ApiVO> entityPageVO = apiBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<ApiVO>>> list(@RequestBody(required = false) ApiQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new ApiQuery();
|
||||
}
|
||||
Page<ApiBO> entityPageBO = apiService.selectByPage(entityQuery);
|
||||
Page<ApiVO> entityPageVO = apiBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+23
-23
@@ -44,31 +44,31 @@ import java.util.List;
|
||||
@RequestMapping(AuthConstant.DICTIONARY_URL_PREFIX)
|
||||
public class DictionaryForAuthController implements BaseController {
|
||||
|
||||
private final DictionaryForAuthBuilder dictionaryForAuthBuilder;
|
||||
private final DictionaryForAuthBuilder dictionaryForAuthBuilder;
|
||||
|
||||
private final DictionaryForAuthService dictionaryForAuthService;
|
||||
private final DictionaryForAuthService dictionaryForAuthService;
|
||||
|
||||
public DictionaryForAuthController(DictionaryForAuthBuilder dictionaryForAuthBuilder,
|
||||
DictionaryForAuthService dictionaryForAuthService) {
|
||||
this.dictionaryForAuthBuilder = dictionaryForAuthBuilder;
|
||||
this.dictionaryForAuthService = dictionaryForAuthService;
|
||||
}
|
||||
public DictionaryForAuthController(DictionaryForAuthBuilder dictionaryForAuthBuilder,
|
||||
DictionaryForAuthService dictionaryForAuthService) {
|
||||
this.dictionaryForAuthBuilder = dictionaryForAuthBuilder;
|
||||
this.dictionaryForAuthService = dictionaryForAuthService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tenant
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/tenant")
|
||||
public Mono<R<List<DictionaryVO>>> tenantDictionary() {
|
||||
try {
|
||||
List<DictionaryBO> entityBOList = dictionaryForAuthService.tenantDictionary();
|
||||
List<DictionaryVO> entityVOList = dictionaryForAuthBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Tenant
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/tenant")
|
||||
public Mono<R<List<DictionaryVO>>> tenantDictionary() {
|
||||
try {
|
||||
List<DictionaryBO> entityBOList = dictionaryForAuthService.tenantDictionary();
|
||||
List<DictionaryVO> entityVOList = dictionaryForAuthBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+115
-121
@@ -53,135 +53,129 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.MENU_URL_PREFIX)
|
||||
public class MenuController implements BaseController {
|
||||
|
||||
private final MenuBuilder menuBuilder;
|
||||
private final MenuBuilder menuBuilder;
|
||||
|
||||
private final MenuService menuService;
|
||||
private final MenuService menuService;
|
||||
|
||||
public MenuController(MenuBuilder menuBuilder, MenuService menuService) {
|
||||
this.menuBuilder = menuBuilder;
|
||||
this.menuService = menuService;
|
||||
}
|
||||
public MenuController(MenuBuilder menuBuilder, MenuService menuService) {
|
||||
this.menuBuilder = menuBuilder;
|
||||
this.menuService = menuService;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody MenuVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
MenuBO entityBO = menuBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
menuService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody MenuVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
MenuBO entityBO = menuBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
menuService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
menuService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
menuService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody MenuVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
MenuBO entityBO = menuBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
menuService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody MenuVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
MenuBO entityBO = menuBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
menuService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<MenuVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
MenuBO entityBO = menuService.selectById(id);
|
||||
MenuVO entityVO = menuBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<MenuVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
MenuBO entityBO = menuService.selectById(id);
|
||||
MenuVO entityVO = menuBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<MenuVO>>> list(@RequestBody(required = false) MenuQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new MenuQuery();
|
||||
}
|
||||
Page<MenuBO> entityPageBO = menuService.selectByPage(entityQuery);
|
||||
Page<MenuVO> entityPageVO = menuBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<MenuVO>>> list(@RequestBody(required = false) MenuQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new MenuQuery();
|
||||
}
|
||||
Page<MenuBO> entityPageBO = menuService.selectByPage(entityQuery);
|
||||
Page<MenuVO> entityPageVO = menuBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/tree")
|
||||
public Mono<R<List<MenuTreeVO>>> tree(@RequestBody(required = false) MenuQuery entityQuery) {
|
||||
try {
|
||||
List<MenuTreeBO> entityBOList = menuService.selectTree(entityQuery);
|
||||
List<MenuTreeVO> entityVOList = new ArrayList<>(entityBOList.size());
|
||||
for (MenuTreeBO node : entityBOList) {
|
||||
entityVOList.add(toTreeVO(node));
|
||||
}
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/tree")
|
||||
public Mono<R<List<MenuTreeVO>>> tree(@RequestBody(required = false) MenuQuery entityQuery) {
|
||||
try {
|
||||
List<MenuTreeBO> entityBOList = menuService.selectTree(entityQuery);
|
||||
List<MenuTreeVO> entityVOList = new ArrayList<>(entityBOList.size());
|
||||
for (MenuTreeBO node : entityBOList) {
|
||||
entityVOList.add(toTreeVO(node));
|
||||
}
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
private MenuTreeVO toTreeVO(MenuTreeBO node) {
|
||||
MenuVO flat = menuBuilder.buildVOByBO(node);
|
||||
MenuTreeVO out = new MenuTreeVO();
|
||||
out.setId(flat.getId());
|
||||
out.setParentMenuId(flat.getParentMenuId());
|
||||
out.setMenuTypeFlag(flat.getMenuTypeFlag());
|
||||
out.setMenuName(flat.getMenuName());
|
||||
out.setMenuCode(flat.getMenuCode());
|
||||
out.setMenuLevel(flat.getMenuLevel());
|
||||
out.setMenuIndex(flat.getMenuIndex());
|
||||
out.setMenuExt(flat.getMenuExt());
|
||||
out.setEnableFlag(flat.getEnableFlag());
|
||||
out.setRemark(flat.getRemark());
|
||||
out.setCreatorId(flat.getCreatorId());
|
||||
out.setCreatorName(flat.getCreatorName());
|
||||
out.setCreateTime(flat.getCreateTime());
|
||||
out.setOperatorId(flat.getOperatorId());
|
||||
out.setOperatorName(flat.getOperatorName());
|
||||
out.setOperateTime(flat.getOperateTime());
|
||||
if (node.getChildren() != null) {
|
||||
List<MenuTreeVO> childVOs = new ArrayList<>(node.getChildren().size());
|
||||
for (MenuTreeBO child : node.getChildren()) {
|
||||
childVOs.add(toTreeVO(child));
|
||||
}
|
||||
out.setChildren(childVOs);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
private MenuTreeVO toTreeVO(MenuTreeBO node) {
|
||||
MenuVO flat = menuBuilder.buildVOByBO(node);
|
||||
MenuTreeVO out = new MenuTreeVO();
|
||||
out.setId(flat.getId());
|
||||
out.setParentMenuId(flat.getParentMenuId());
|
||||
out.setMenuTypeFlag(flat.getMenuTypeFlag());
|
||||
out.setMenuName(flat.getMenuName());
|
||||
out.setMenuCode(flat.getMenuCode());
|
||||
out.setMenuLevel(flat.getMenuLevel());
|
||||
out.setMenuIndex(flat.getMenuIndex());
|
||||
out.setMenuExt(flat.getMenuExt());
|
||||
out.setEnableFlag(flat.getEnableFlag());
|
||||
out.setRemark(flat.getRemark());
|
||||
out.setCreatorId(flat.getCreatorId());
|
||||
out.setCreatorName(flat.getCreatorName());
|
||||
out.setCreateTime(flat.getCreateTime());
|
||||
out.setOperatorId(flat.getOperatorId());
|
||||
out.setOperatorName(flat.getOperatorName());
|
||||
out.setOperateTime(flat.getOperateTime());
|
||||
if (node.getChildren() != null) {
|
||||
List<MenuTreeVO> childVOs = new ArrayList<>(node.getChildren().size());
|
||||
for (MenuTreeBO child : node.getChildren()) {
|
||||
childVOs.add(toTreeVO(child));
|
||||
}
|
||||
out.setChildren(childVOs);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+115
-121
@@ -53,135 +53,129 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.RESOURCE_URL_PREFIX)
|
||||
public class ResourceController implements BaseController {
|
||||
|
||||
private final ResourceBuilder resourceBuilder;
|
||||
private final ResourceBuilder resourceBuilder;
|
||||
|
||||
private final ResourceService resourceService;
|
||||
private final ResourceService resourceService;
|
||||
|
||||
public ResourceController(ResourceBuilder resourceBuilder, ResourceService resourceService) {
|
||||
this.resourceBuilder = resourceBuilder;
|
||||
this.resourceService = resourceService;
|
||||
}
|
||||
public ResourceController(ResourceBuilder resourceBuilder, ResourceService resourceService) {
|
||||
this.resourceBuilder = resourceBuilder;
|
||||
this.resourceService = resourceService;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody ResourceVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
ResourceBO entityBO = resourceBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
resourceService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody ResourceVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
ResourceBO entityBO = resourceBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
resourceService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
resourceService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
resourceService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody ResourceVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
ResourceBO entityBO = resourceBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
resourceService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody ResourceVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
ResourceBO entityBO = resourceBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
resourceService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<ResourceVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
ResourceBO entityBO = resourceService.selectById(id);
|
||||
ResourceVO entityVO = resourceBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<ResourceVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
ResourceBO entityBO = resourceService.selectById(id);
|
||||
ResourceVO entityVO = resourceBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<ResourceVO>>> list(@RequestBody(required = false) ResourceQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new ResourceQuery();
|
||||
}
|
||||
Page<ResourceBO> entityPageBO = resourceService.selectByPage(entityQuery);
|
||||
Page<ResourceVO> entityPageVO = resourceBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<ResourceVO>>> list(@RequestBody(required = false) ResourceQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new ResourceQuery();
|
||||
}
|
||||
Page<ResourceBO> entityPageBO = resourceService.selectByPage(entityQuery);
|
||||
Page<ResourceVO> entityPageVO = resourceBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/tree")
|
||||
public Mono<R<List<ResourceTreeVO>>> tree(@RequestBody(required = false) ResourceQuery entityQuery) {
|
||||
try {
|
||||
List<ResourceTreeBO> entityBOList = resourceService.selectTree(entityQuery);
|
||||
List<ResourceTreeVO> entityVOList = new ArrayList<>(entityBOList.size());
|
||||
for (ResourceTreeBO node : entityBOList) {
|
||||
entityVOList.add(toTreeVO(node));
|
||||
}
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/tree")
|
||||
public Mono<R<List<ResourceTreeVO>>> tree(@RequestBody(required = false) ResourceQuery entityQuery) {
|
||||
try {
|
||||
List<ResourceTreeBO> entityBOList = resourceService.selectTree(entityQuery);
|
||||
List<ResourceTreeVO> entityVOList = new ArrayList<>(entityBOList.size());
|
||||
for (ResourceTreeBO node : entityBOList) {
|
||||
entityVOList.add(toTreeVO(node));
|
||||
}
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceTreeVO toTreeVO(ResourceTreeBO node) {
|
||||
ResourceVO flat = resourceBuilder.buildVOByBO(node);
|
||||
ResourceTreeVO out = new ResourceTreeVO();
|
||||
out.setId(flat.getId());
|
||||
out.setParentResourceId(flat.getParentResourceId());
|
||||
out.setResourceName(flat.getResourceName());
|
||||
out.setResourceCode(flat.getResourceCode());
|
||||
out.setResourceTypeFlag(flat.getResourceTypeFlag());
|
||||
out.setResourceScopeFlag(flat.getResourceScopeFlag());
|
||||
out.setEntityId(flat.getEntityId());
|
||||
out.setResourceExt(flat.getResourceExt());
|
||||
out.setEnableFlag(flat.getEnableFlag());
|
||||
out.setRemark(flat.getRemark());
|
||||
out.setCreatorId(flat.getCreatorId());
|
||||
out.setCreatorName(flat.getCreatorName());
|
||||
out.setCreateTime(flat.getCreateTime());
|
||||
out.setOperatorId(flat.getOperatorId());
|
||||
out.setOperatorName(flat.getOperatorName());
|
||||
out.setOperateTime(flat.getOperateTime());
|
||||
if (node.getChildren() != null) {
|
||||
List<ResourceTreeVO> childVOs = new ArrayList<>(node.getChildren().size());
|
||||
for (ResourceTreeBO child : node.getChildren()) {
|
||||
childVOs.add(toTreeVO(child));
|
||||
}
|
||||
out.setChildren(childVOs);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
private ResourceTreeVO toTreeVO(ResourceTreeBO node) {
|
||||
ResourceVO flat = resourceBuilder.buildVOByBO(node);
|
||||
ResourceTreeVO out = new ResourceTreeVO();
|
||||
out.setId(flat.getId());
|
||||
out.setParentResourceId(flat.getParentResourceId());
|
||||
out.setResourceName(flat.getResourceName());
|
||||
out.setResourceCode(flat.getResourceCode());
|
||||
out.setResourceTypeFlag(flat.getResourceTypeFlag());
|
||||
out.setResourceScopeFlag(flat.getResourceScopeFlag());
|
||||
out.setEntityId(flat.getEntityId());
|
||||
out.setResourceExt(flat.getResourceExt());
|
||||
out.setEnableFlag(flat.getEnableFlag());
|
||||
out.setRemark(flat.getRemark());
|
||||
out.setCreatorId(flat.getCreatorId());
|
||||
out.setCreatorName(flat.getCreatorName());
|
||||
out.setCreateTime(flat.getCreateTime());
|
||||
out.setOperatorId(flat.getOperatorId());
|
||||
out.setOperatorName(flat.getOperatorName());
|
||||
out.setOperateTime(flat.getOperateTime());
|
||||
if (node.getChildren() != null) {
|
||||
List<ResourceTreeVO> childVOs = new ArrayList<>(node.getChildren().size());
|
||||
for (ResourceTreeBO child : node.getChildren()) {
|
||||
childVOs.add(toTreeVO(child));
|
||||
}
|
||||
out.setChildren(childVOs);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+119
-125
@@ -53,139 +53,133 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.ROLE_URL_PREFIX)
|
||||
public class RoleController implements BaseController {
|
||||
|
||||
private final RoleBuilder roleBuilder;
|
||||
private final RoleBuilder roleBuilder;
|
||||
|
||||
private final RoleService roleService;
|
||||
private final RoleService roleService;
|
||||
|
||||
public RoleController(RoleBuilder roleBuilder, RoleService roleService) {
|
||||
this.roleBuilder = roleBuilder;
|
||||
this.roleService = roleService;
|
||||
}
|
||||
public RoleController(RoleBuilder roleBuilder, RoleService roleService) {
|
||||
this.roleBuilder = roleBuilder;
|
||||
this.roleService = roleService;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody RoleVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
RoleBO entityBO = roleBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setTenantId(header.getTenantId());
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
roleService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody RoleVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
RoleBO entityBO = roleBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setTenantId(header.getTenantId());
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
roleService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
roleService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
roleService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody RoleVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
RoleBO entityBO = roleBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setTenantId(header.getTenantId());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
roleService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody RoleVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
RoleBO entityBO = roleBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setTenantId(header.getTenantId());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
roleService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<RoleVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
RoleBO entityBO = roleService.selectById(id);
|
||||
RoleVO entityVO = roleBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<RoleVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
RoleBO entityBO = roleService.selectById(id);
|
||||
RoleVO entityVO = roleBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<RoleVO>>> list(@RequestBody(required = false) RoleQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleQuery query = Objects.isNull(entityQuery) ? new RoleQuery() : entityQuery;
|
||||
query.setTenantId(tenantId);
|
||||
Page<RoleBO> entityPageBO = roleService.selectByPage(query);
|
||||
Page<RoleVO> entityPageVO = roleBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<RoleVO>>> list(@RequestBody(required = false) RoleQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleQuery query = Objects.isNull(entityQuery) ? new RoleQuery() : entityQuery;
|
||||
query.setTenantId(tenantId);
|
||||
Page<RoleBO> entityPageBO = roleService.selectByPage(query);
|
||||
Page<RoleVO> entityPageVO = roleBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/tree")
|
||||
public Mono<R<List<RoleTreeVO>>> tree(@RequestBody(required = false) RoleQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleQuery query = Objects.isNull(entityQuery) ? new RoleQuery() : entityQuery;
|
||||
query.setTenantId(tenantId);
|
||||
List<RoleTreeBO> entityBOList = roleService.selectTree(query);
|
||||
List<RoleTreeVO> entityVOList = new ArrayList<>(entityBOList.size());
|
||||
for (RoleTreeBO node : entityBOList) {
|
||||
entityVOList.add(toTreeVO(node));
|
||||
}
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/tree")
|
||||
public Mono<R<List<RoleTreeVO>>> tree(@RequestBody(required = false) RoleQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleQuery query = Objects.isNull(entityQuery) ? new RoleQuery() : entityQuery;
|
||||
query.setTenantId(tenantId);
|
||||
List<RoleTreeBO> entityBOList = roleService.selectTree(query);
|
||||
List<RoleTreeVO> entityVOList = new ArrayList<>(entityBOList.size());
|
||||
for (RoleTreeBO node : entityBOList) {
|
||||
entityVOList.add(toTreeVO(node));
|
||||
}
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private RoleTreeVO toTreeVO(RoleTreeBO node) {
|
||||
RoleVO flat = roleBuilder.buildVOByBO(node);
|
||||
RoleTreeVO out = new RoleTreeVO();
|
||||
out.setId(flat.getId());
|
||||
out.setParentRoleId(flat.getParentRoleId());
|
||||
out.setRoleName(flat.getRoleName());
|
||||
out.setRoleCode(flat.getRoleCode());
|
||||
out.setRoleExt(flat.getRoleExt());
|
||||
out.setEnableFlag(flat.getEnableFlag());
|
||||
out.setRemark(flat.getRemark());
|
||||
out.setCreatorId(flat.getCreatorId());
|
||||
out.setCreatorName(flat.getCreatorName());
|
||||
out.setCreateTime(flat.getCreateTime());
|
||||
out.setOperatorId(flat.getOperatorId());
|
||||
out.setOperatorName(flat.getOperatorName());
|
||||
out.setOperateTime(flat.getOperateTime());
|
||||
if (node.getChildren() != null) {
|
||||
List<RoleTreeVO> childVOs = new ArrayList<>(node.getChildren().size());
|
||||
for (RoleTreeBO child : node.getChildren()) {
|
||||
childVOs.add(toTreeVO(child));
|
||||
}
|
||||
out.setChildren(childVOs);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
private RoleTreeVO toTreeVO(RoleTreeBO node) {
|
||||
RoleVO flat = roleBuilder.buildVOByBO(node);
|
||||
RoleTreeVO out = new RoleTreeVO();
|
||||
out.setId(flat.getId());
|
||||
out.setParentRoleId(flat.getParentRoleId());
|
||||
out.setRoleName(flat.getRoleName());
|
||||
out.setRoleCode(flat.getRoleCode());
|
||||
out.setRoleExt(flat.getRoleExt());
|
||||
out.setEnableFlag(flat.getEnableFlag());
|
||||
out.setRemark(flat.getRemark());
|
||||
out.setCreatorId(flat.getCreatorId());
|
||||
out.setCreatorName(flat.getCreatorName());
|
||||
out.setCreateTime(flat.getCreateTime());
|
||||
out.setOperatorId(flat.getOperatorId());
|
||||
out.setOperatorName(flat.getOperatorName());
|
||||
out.setOperateTime(flat.getOperateTime());
|
||||
if (node.getChildren() != null) {
|
||||
List<RoleTreeVO> childVOs = new ArrayList<>(node.getChildren().size());
|
||||
for (RoleTreeBO child : node.getChildren()) {
|
||||
childVOs.add(toTreeVO(child));
|
||||
}
|
||||
out.setChildren(childVOs);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+85
-91
@@ -55,106 +55,100 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.ROLE_RESOURCE_URL_PREFIX)
|
||||
public class RoleResourceBindController implements BaseController {
|
||||
|
||||
private final RoleResourceBindBuilder roleResourceBindBuilder;
|
||||
private final RoleResourceBindBuilder roleResourceBindBuilder;
|
||||
|
||||
private final RoleResourceBindService roleResourceBindService;
|
||||
private final RoleResourceBindService roleResourceBindService;
|
||||
|
||||
private final ResourceBuilder resourceBuilder;
|
||||
private final ResourceBuilder resourceBuilder;
|
||||
|
||||
private final RoleBuilder roleBuilder;
|
||||
private final RoleBuilder roleBuilder;
|
||||
|
||||
public RoleResourceBindController(RoleResourceBindBuilder roleResourceBindBuilder,
|
||||
RoleResourceBindService roleResourceBindService, ResourceBuilder resourceBuilder, RoleBuilder roleBuilder) {
|
||||
this.roleResourceBindBuilder = roleResourceBindBuilder;
|
||||
this.roleResourceBindService = roleResourceBindService;
|
||||
this.resourceBuilder = resourceBuilder;
|
||||
this.roleBuilder = roleBuilder;
|
||||
}
|
||||
public RoleResourceBindController(RoleResourceBindBuilder roleResourceBindBuilder,
|
||||
RoleResourceBindService roleResourceBindService, ResourceBuilder resourceBuilder, RoleBuilder roleBuilder) {
|
||||
this.roleResourceBindBuilder = roleResourceBindBuilder;
|
||||
this.roleResourceBindService = roleResourceBindService;
|
||||
this.resourceBuilder = resourceBuilder;
|
||||
this.roleBuilder = roleBuilder;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody RoleResourceBindVO entityVO) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleResourceBindBO entityBO = roleResourceBindBuilder.buildBOByVO(entityVO);
|
||||
roleResourceBindService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody RoleResourceBindVO entityVO) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleResourceBindBO entityBO = roleResourceBindBuilder.buildBOByVO(entityVO);
|
||||
roleResourceBindService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
roleResourceBindService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
roleResourceBindService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<RoleResourceBindVO>>> list(@RequestBody(required = false) RoleResourceBindQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleResourceBindQuery query = Objects.isNull(entityQuery) ? new RoleResourceBindQuery() : entityQuery;
|
||||
Page<RoleResourceBindBO> entityPageBO = roleResourceBindService.selectByPage(query, tenantId);
|
||||
Page<RoleResourceBindVO> entityPageVO = roleResourceBindBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<RoleResourceBindVO>>> list(@RequestBody(required = false) RoleResourceBindQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleResourceBindQuery query = Objects.isNull(entityQuery) ? new RoleResourceBindQuery() : entityQuery;
|
||||
Page<RoleResourceBindBO> entityPageBO = roleResourceBindService.selectByPage(query, tenantId);
|
||||
Page<RoleResourceBindVO> entityPageVO = roleResourceBindBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/list-resource-by-role/{roleId}")
|
||||
public Mono<R<List<ResourceVO>>> listResourceByRole(@NotNull @PathVariable(value = "roleId") Long roleId) {
|
||||
try {
|
||||
List<ResourceBO> entityBOList = roleResourceBindService.listResourceByRoleId(roleId);
|
||||
List<ResourceVO> entityVOList = resourceBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/list-resource-by-role/{roleId}")
|
||||
public Mono<R<List<ResourceVO>>> listResourceByRole(@NotNull @PathVariable(value = "roleId") Long roleId) {
|
||||
try {
|
||||
List<ResourceBO> entityBOList = roleResourceBindService.listResourceByRoleId(roleId);
|
||||
List<ResourceVO> entityVOList = resourceBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/list-resource-by-user/{userId}")
|
||||
public Mono<R<List<ResourceVO>>> listResourceByUser(@NotNull @PathVariable(value = "userId") Long userId) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
List<ResourceBO> entityBOList = roleResourceBindService.listResourceByUserId(userId, tenantId);
|
||||
List<ResourceVO> entityVOList = resourceBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@GetMapping("/list-resource-by-user/{userId}")
|
||||
public Mono<R<List<ResourceVO>>> listResourceByUser(@NotNull @PathVariable(value = "userId") Long userId) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
List<ResourceBO> entityBOList = roleResourceBindService.listResourceByUserId(userId, tenantId);
|
||||
List<ResourceVO> entityVOList = resourceBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/list-role-by-resource/{resourceId}")
|
||||
public Mono<R<List<RoleVO>>> listRoleByResource(@NotNull @PathVariable(value = "resourceId") Long resourceId) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
List<RoleBO> entityBOList = roleResourceBindService.listRoleByResourceId(resourceId, tenantId);
|
||||
List<RoleVO> entityVOList = roleBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@GetMapping("/list-role-by-resource/{resourceId}")
|
||||
public Mono<R<List<RoleVO>>> listRoleByResource(@NotNull @PathVariable(value = "resourceId") Long resourceId) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
List<RoleBO> entityBOList = roleResourceBindService.listRoleByResourceId(resourceId, tenantId);
|
||||
List<RoleVO> entityVOList = roleBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+71
-76
@@ -55,90 +55,85 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.ROLE_USER_URL_PREFIX)
|
||||
public class RoleUserBindController implements BaseController {
|
||||
|
||||
private final RoleUserBindBuilder roleUserBindBuilder;
|
||||
private final RoleUserBindBuilder roleUserBindBuilder;
|
||||
|
||||
private final RoleUserBindService roleUserBindService;
|
||||
private final RoleUserBindService roleUserBindService;
|
||||
|
||||
private final RoleBuilder roleBuilder;
|
||||
private final RoleBuilder roleBuilder;
|
||||
|
||||
private final UserBuilder userBuilder;
|
||||
private final UserBuilder userBuilder;
|
||||
|
||||
public RoleUserBindController(RoleUserBindBuilder roleUserBindBuilder, RoleUserBindService roleUserBindService,
|
||||
RoleBuilder roleBuilder, UserBuilder userBuilder) {
|
||||
this.roleUserBindBuilder = roleUserBindBuilder;
|
||||
this.roleUserBindService = roleUserBindService;
|
||||
this.roleBuilder = roleBuilder;
|
||||
this.userBuilder = userBuilder;
|
||||
}
|
||||
public RoleUserBindController(RoleUserBindBuilder roleUserBindBuilder, RoleUserBindService roleUserBindService,
|
||||
RoleBuilder roleBuilder, UserBuilder userBuilder) {
|
||||
this.roleUserBindBuilder = roleUserBindBuilder;
|
||||
this.roleUserBindService = roleUserBindService;
|
||||
this.roleBuilder = roleBuilder;
|
||||
this.userBuilder = userBuilder;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody RoleUserBindVO entityVO) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleUserBindBO entityBO = roleUserBindBuilder.buildBOByVO(entityVO);
|
||||
roleUserBindService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody RoleUserBindVO entityVO) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleUserBindBO entityBO = roleUserBindBuilder.buildBOByVO(entityVO);
|
||||
roleUserBindService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
roleUserBindService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
roleUserBindService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<RoleUserBindVO>>> list(@RequestBody(required = false) RoleUserBindQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleUserBindQuery query = Objects.isNull(entityQuery) ? new RoleUserBindQuery() : entityQuery;
|
||||
Page<RoleUserBindBO> entityPageBO = roleUserBindService.selectByPage(query, tenantId);
|
||||
Page<RoleUserBindVO> entityPageVO = roleUserBindBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<RoleUserBindVO>>> list(@RequestBody(required = false) RoleUserBindQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
RoleUserBindQuery query = Objects.isNull(entityQuery) ? new RoleUserBindQuery() : entityQuery;
|
||||
Page<RoleUserBindBO> entityPageBO = roleUserBindService.selectByPage(query, tenantId);
|
||||
Page<RoleUserBindVO> entityPageVO = roleUserBindBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/list-role-by-user/{userId}")
|
||||
public Mono<R<List<RoleVO>>> listRoleByUser(@NotNull @PathVariable(value = "userId") Long userId,
|
||||
@RequestParam(value = "tenantId", required = false) Long tenantId) {
|
||||
try {
|
||||
List<RoleBO> entityBOList = roleUserBindService.listRoleByTenantIdAndUserId(tenantId, userId);
|
||||
List<RoleVO> entityVOList = roleBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/list-role-by-user/{userId}")
|
||||
public Mono<R<List<RoleVO>>> listRoleByUser(@NotNull @PathVariable(value = "userId") Long userId,
|
||||
@RequestParam(value = "tenantId", required = false) Long tenantId) {
|
||||
try {
|
||||
List<RoleBO> entityBOList = roleUserBindService.listRoleByTenantIdAndUserId(tenantId, userId);
|
||||
List<RoleVO> entityVOList = roleBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/list-user-by-role/{roleId}")
|
||||
public Mono<R<List<UserVO>>> listUserByRole(@NotNull @PathVariable(value = "roleId") Long roleId) {
|
||||
try {
|
||||
List<UserBO> entityBOList = roleUserBindService.listUserByRoleId(roleId);
|
||||
List<UserVO> entityVOList = userBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/list-user-by-role/{roleId}")
|
||||
public Mono<R<List<UserVO>>> listUserByRole(@NotNull @PathVariable(value = "roleId") Long roleId) {
|
||||
try {
|
||||
List<UserBO> entityBOList = roleUserBindService.listUserByRoleId(roleId);
|
||||
List<UserVO> entityVOList = userBuilder.buildVOListByBOList(entityBOList);
|
||||
return Mono.just(R.ok(entityVOList));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+116
-116
@@ -49,129 +49,129 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.TENANT_URL_PREFIX)
|
||||
public class TenantController implements BaseController {
|
||||
|
||||
private final TenantBuilder tenantBuilder;
|
||||
private final TenantBuilder tenantBuilder;
|
||||
|
||||
private final TenantService tenantService;
|
||||
private final TenantService tenantService;
|
||||
|
||||
public TenantController(TenantBuilder tenantBuilder, TenantService tenantService) {
|
||||
this.tenantBuilder = tenantBuilder;
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
public TenantController(TenantBuilder tenantBuilder, TenantService tenantService) {
|
||||
this.tenantBuilder = tenantBuilder;
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tenant
|
||||
* @param entityVO {@link TenantVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody TenantVO entityVO) {
|
||||
try {
|
||||
TenantBO entityBO = tenantBuilder.buildBOByVO(entityVO);
|
||||
tenantService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Tenant
|
||||
*
|
||||
* @param entityVO {@link TenantVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody TenantVO entityVO) {
|
||||
try {
|
||||
TenantBO entityBO = tenantBuilder.buildBOByVO(entityVO);
|
||||
tenantService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ID Tenant
|
||||
* @param id ID
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
tenantService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ID Tenant
|
||||
*
|
||||
* @param id ID
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
tenantService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ID Tenant
|
||||
* <ol>
|
||||
* <li>: Enable</li>
|
||||
* <li>: Name</li>
|
||||
* </ol>
|
||||
* @param entityVO {@link TenantVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody TenantVO entityVO) {
|
||||
try {
|
||||
TenantBO entityBO = tenantBuilder.buildBOByVO(entityVO);
|
||||
tenantService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ID Tenant
|
||||
* <ol>
|
||||
* <li>: Enable</li>
|
||||
* <li>: Name</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param entityVO {@link TenantVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody TenantVO entityVO) {
|
||||
try {
|
||||
TenantBO entityBO = tenantBuilder.buildBOByVO(entityVO);
|
||||
tenantService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ID Tenant
|
||||
* @param id ID
|
||||
* @return TenantVO {@link TenantVO}
|
||||
*/
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<TenantVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
TenantBO entityBO = tenantService.selectById(id);
|
||||
TenantVO entityVO = tenantBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ID Tenant
|
||||
*
|
||||
* @param id ID
|
||||
* @return TenantVO {@link TenantVO}
|
||||
*/
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<TenantVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
TenantBO entityBO = tenantService.selectById(id);
|
||||
TenantVO entityVO = tenantBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Code Tenant
|
||||
* @param code TenantCode
|
||||
* @return {@link TenantBO}
|
||||
*/
|
||||
@GetMapping("/code/{code}")
|
||||
public Mono<R<TenantBO>> selectByCode(@NotNull @PathVariable(value = "code") String code) {
|
||||
try {
|
||||
TenantBO select = tenantService.selectByCode(code);
|
||||
if (Objects.nonNull(select)) {
|
||||
return Mono.just(R.ok(select));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
return Mono.just(R.fail(ResponseEnum.NO_RESOURCE.getText()));
|
||||
}
|
||||
/**
|
||||
* Code Tenant
|
||||
*
|
||||
* @param code TenantCode
|
||||
* @return {@link TenantBO}
|
||||
*/
|
||||
@GetMapping("/code/{code}")
|
||||
public Mono<R<TenantBO>> selectByCode(@NotNull @PathVariable(value = "code") String code) {
|
||||
try {
|
||||
TenantBO select = tenantService.selectByCode(code);
|
||||
if (Objects.nonNull(select)) {
|
||||
return Mono.just(R.ok(select));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
return Mono.just(R.fail(ResponseEnum.NO_RESOURCE.getText()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tenant
|
||||
* @param entityQuery Tenant
|
||||
* @return {@link TenantBO}
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<TenantVO>>> list(@RequestBody(required = false) TenantQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new TenantQuery();
|
||||
}
|
||||
Page<TenantBO> entityPageBO = tenantService.selectByPage(entityQuery);
|
||||
Page<TenantVO> entityPageVO = tenantBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Tenant
|
||||
*
|
||||
* @param entityQuery Tenant
|
||||
* @return {@link TenantBO}
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<TenantVO>>> list(@RequestBody(required = false) TenantQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new TenantQuery();
|
||||
}
|
||||
Page<TenantBO> entityPageBO = tenantService.selectByPage(entityQuery);
|
||||
Page<TenantVO> entityPageVO = tenantBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+47
-46
@@ -46,57 +46,58 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.TOKEN_URL_PREFIX)
|
||||
public class TokenController implements BaseController {
|
||||
|
||||
private final TokenService tokenService;
|
||||
private final TokenService tokenService;
|
||||
|
||||
public TokenController(TokenService tokenService) {
|
||||
this.tokenService = tokenService;
|
||||
}
|
||||
public TokenController(TokenService tokenService) {
|
||||
this.tokenService = tokenService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityVO {@link TokenQuery}
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/salt")
|
||||
public Mono<R<String>> generateSalt(@Validated @RequestBody TokenQuery entityVO) {
|
||||
String salt = tokenService.generateSalt(entityVO.getName(), entityVO.getTenant());
|
||||
return Objects.nonNull(salt) ? Mono.just(R.ok(salt, "The salt will expire in 5 minutes")) : Mono.just(R.fail());
|
||||
}
|
||||
/**
|
||||
* @param entityVO {@link TokenQuery}
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/salt")
|
||||
public Mono<R<String>> generateSalt(@Validated @RequestBody TokenQuery entityVO) {
|
||||
String salt = tokenService.generateSalt(entityVO.getName(), entityVO.getTenant());
|
||||
return Objects.nonNull(salt) ? Mono.just(R.ok(salt, "The salt will expire in 5 minutes")) : Mono.just(R.fail());
|
||||
}
|
||||
|
||||
/**
|
||||
* Token
|
||||
* @param entityVO {@link TokenQuery}
|
||||
* @return Token
|
||||
*/
|
||||
@PostMapping("/generate")
|
||||
public Mono<R<String>> generateToken(@Validated @RequestBody TokenQuery entityVO) {
|
||||
String token = tokenService.generateToken(entityVO.getName(), entityVO.getSalt(), entityVO.getPassword(),
|
||||
entityVO.getTenant());
|
||||
return Objects.nonNull(token) ? Mono.just(R.ok(token, "The token will expire in 12 hours."))
|
||||
: Mono.just(R.fail());
|
||||
}
|
||||
/**
|
||||
* Token
|
||||
*
|
||||
* @param entityVO {@link TokenQuery}
|
||||
* @return Token
|
||||
*/
|
||||
@PostMapping("/generate")
|
||||
public Mono<R<String>> generateToken(@Validated @RequestBody TokenQuery entityVO) {
|
||||
String token = tokenService.generateToken(entityVO.getName(), entityVO.getSalt(), entityVO.getPassword(),
|
||||
entityVO.getTenant());
|
||||
return Objects.nonNull(token) ? Mono.just(R.ok(token, "The token will expire in 12 hours."))
|
||||
: Mono.just(R.fail());
|
||||
}
|
||||
|
||||
/**
|
||||
* Token
|
||||
* @param entityVO {@link TokenQuery}
|
||||
* @return ,
|
||||
*/
|
||||
@PostMapping("/check")
|
||||
public Mono<R<Boolean>> checkValid(@Validated @RequestBody TokenQuery entityVO) {
|
||||
TokenValid tokenValid = tokenService.checkValid(entityVO.getName(), entityVO.getSalt(), entityVO.getToken(),
|
||||
entityVO.getTenant());
|
||||
/**
|
||||
* Token
|
||||
*
|
||||
* @param entityVO {@link TokenQuery}
|
||||
* @return ,
|
||||
*/
|
||||
@PostMapping("/check")
|
||||
public Mono<R<Boolean>> checkValid(@Validated @RequestBody TokenQuery entityVO) {
|
||||
TokenValid tokenValid = tokenService.checkValid(entityVO.getName(), entityVO.getSalt(), entityVO.getToken(),
|
||||
entityVO.getTenant());
|
||||
|
||||
boolean valid = tokenValid.isValid();
|
||||
String message = "The token has expired";
|
||||
if (valid && Objects.nonNull(tokenValid.getExpireTime())) {
|
||||
String expireTime = TimeUtil.completeFormat(tokenValid.getExpireTime());
|
||||
message = "The token will expire in " + expireTime;
|
||||
}
|
||||
else if (!valid && Objects.nonNull(tokenValid.getExpireTime())) {
|
||||
String expireTime = TimeUtil.completeFormat(tokenValid.getExpireTime());
|
||||
message = "The token has expired in " + expireTime;
|
||||
}
|
||||
boolean valid = tokenValid.isValid();
|
||||
String message = "The token has expired";
|
||||
if (valid && Objects.nonNull(tokenValid.getExpireTime())) {
|
||||
String expireTime = TimeUtil.completeFormat(tokenValid.getExpireTime());
|
||||
message = "The token will expire in " + expireTime;
|
||||
} else if (!valid && Objects.nonNull(tokenValid.getExpireTime())) {
|
||||
String expireTime = TimeUtil.completeFormat(tokenValid.getExpireTime());
|
||||
message = "The token has expired in " + expireTime;
|
||||
}
|
||||
|
||||
return Mono.just(R.ok(valid, message));
|
||||
}
|
||||
return Mono.just(R.ok(valid, message));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+90
-96
@@ -49,109 +49,103 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.USER_PROFILE_URL_PREFIX)
|
||||
public class UserController implements BaseController {
|
||||
|
||||
private final UserBuilder userBuilder;
|
||||
private final UserBuilder userBuilder;
|
||||
|
||||
private final UserService userService;
|
||||
private final UserService userService;
|
||||
|
||||
public UserController(UserBuilder userBuilder, UserService userService) {
|
||||
this.userBuilder = userBuilder;
|
||||
this.userService = userService;
|
||||
}
|
||||
public UserController(UserBuilder userBuilder, UserService userService) {
|
||||
this.userBuilder = userBuilder;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody UserVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
UserBO entityBO = userBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
userService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody UserVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
UserBO entityBO = userBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setCreatorId(header.getUserId());
|
||||
entityBO.setCreatorName(header.getNickName());
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
userService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
userService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
userService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody UserVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
UserBO entityBO = userBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
userService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody UserVO entityVO) {
|
||||
return getUserHeader().flatMap(header -> {
|
||||
try {
|
||||
UserBO entityBO = userBuilder.buildBOByVO(entityVO);
|
||||
entityBO.setOperatorId(header.getUserId());
|
||||
entityBO.setOperatorName(header.getNickName());
|
||||
userService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<UserVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
UserBO entityBO = userService.selectById(id);
|
||||
UserVO entityVO = userBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<UserVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
UserBO entityBO = userService.selectById(id);
|
||||
UserVO entityVO = userBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/name/{name}")
|
||||
public Mono<R<UserVO>> selectByName(@NotNull @PathVariable(value = "name") String name) {
|
||||
try {
|
||||
UserBO entityBO = userService.selectByUserName(name, false);
|
||||
if (Objects.isNull(entityBO)) {
|
||||
return Mono.just(R.fail(ResponseEnum.NO_RESOURCE.getText()));
|
||||
}
|
||||
UserVO entityVO = userBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
@GetMapping("/name/{name}")
|
||||
public Mono<R<UserVO>> selectByName(@NotNull @PathVariable(value = "name") String name) {
|
||||
try {
|
||||
UserBO entityBO = userService.selectByUserName(name, false);
|
||||
if (Objects.isNull(entityBO)) {
|
||||
return Mono.just(R.fail(ResponseEnum.NO_RESOURCE.getText()));
|
||||
}
|
||||
UserVO entityVO = userBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<UserVO>>> list(@RequestBody(required = false) UserQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
UserQuery query = Objects.isNull(entityQuery) ? new UserQuery() : entityQuery;
|
||||
// Overwrite whatever the client sent. Tenant scope is a hard
|
||||
// boundary, not a filter — a caller cannot reach across tenants.
|
||||
query.setTenantId(tenantId);
|
||||
Page<UserBO> entityPageBO = userService.selectByPage(query);
|
||||
Page<UserVO> entityPageVO = userBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<UserVO>>> list(@RequestBody(required = false) UserQuery entityQuery) {
|
||||
return getTenantId().flatMap(tenantId -> {
|
||||
try {
|
||||
UserQuery query = Objects.isNull(entityQuery) ? new UserQuery() : entityQuery;
|
||||
// Overwrite whatever the client sent. Tenant scope is a hard
|
||||
// boundary, not a filter — a caller cannot reach across tenants.
|
||||
query.setTenantId(tenantId);
|
||||
Page<UserBO> entityPageBO = userService.selectByPage(query);
|
||||
Page<UserVO> entityPageVO = userBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+147
-148
@@ -50,164 +50,163 @@ import java.util.Objects;
|
||||
@RequestMapping(AuthConstant.USER_URL_PREFIX)
|
||||
public class UserLoginController implements BaseController {
|
||||
|
||||
private final UserLoginBuilder userLoginBuilder;
|
||||
private final UserLoginBuilder userLoginBuilder;
|
||||
|
||||
private final UserLoginService userLoginService;
|
||||
private final UserLoginService userLoginService;
|
||||
|
||||
private final UserPasswordService userPasswordService;
|
||||
private final UserPasswordService userPasswordService;
|
||||
|
||||
public UserLoginController(UserLoginBuilder userLoginBuilder, UserLoginService userLoginService,
|
||||
UserPasswordService userPasswordService) {
|
||||
this.userLoginBuilder = userLoginBuilder;
|
||||
this.userLoginService = userLoginService;
|
||||
this.userPasswordService = userPasswordService;
|
||||
}
|
||||
public UserLoginController(UserLoginBuilder userLoginBuilder, UserLoginService userLoginService,
|
||||
UserPasswordService userPasswordService) {
|
||||
this.userLoginBuilder = userLoginBuilder;
|
||||
this.userLoginService = userLoginService;
|
||||
this.userPasswordService = userPasswordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityVO {@link UserLoginVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody UserLoginVO entityVO) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginBuilder.buildBOByVO(entityVO);
|
||||
userLoginService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param entityVO {@link UserLoginVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Mono<R<String>> add(@Validated(Add.class) @RequestBody UserLoginVO entityVO) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginBuilder.buildBOByVO(entityVO);
|
||||
userLoginService.save(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ID
|
||||
* @param id ID
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
userLoginService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ID
|
||||
*
|
||||
* @param id ID
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/delete/{id}")
|
||||
public Mono<R<String>> delete(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
userLoginService.remove(id);
|
||||
return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <ol>
|
||||
* <li>: Enable,Password</li>
|
||||
* <li>: Name</li>
|
||||
* </ol>
|
||||
* @param entityVO {@link UserLoginVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody UserLoginVO entityVO) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginBuilder.buildBOByVO(entityVO);
|
||||
userLoginService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* <ol>
|
||||
* <li>: Enable,Password</li>
|
||||
* <li>: Name</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param entityVO {@link UserLoginVO}
|
||||
* @return R of String
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Mono<R<String>> update(@Validated(Update.class) @RequestBody UserLoginVO entityVO) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginBuilder.buildBOByVO(entityVO);
|
||||
userLoginService.update(entityBO);
|
||||
return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ID
|
||||
* @param id ID
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/reset/{id}")
|
||||
public Mono<R<Boolean>> restPassword(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
userPasswordService.restPassword(id);
|
||||
return Mono.just(R.ok());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ID
|
||||
*
|
||||
* @param id ID
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/reset/{id}")
|
||||
public Mono<R<Boolean>> restPassword(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
userPasswordService.restPassword(id);
|
||||
return Mono.just(R.ok());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ID
|
||||
* @param id ID
|
||||
* @return UserLoginVO {@link UserLoginVO}
|
||||
*/
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<UserLoginVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginService.selectById(id);
|
||||
UserLoginVO entityVO = userLoginBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ID
|
||||
*
|
||||
* @param id ID
|
||||
* @return UserLoginVO {@link UserLoginVO}
|
||||
*/
|
||||
@GetMapping("/id/{id}")
|
||||
public Mono<R<UserLoginVO>> selectById(@NotNull @PathVariable(value = "id") Long id) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginService.selectById(id);
|
||||
UserLoginVO entityVO = userLoginBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Name User
|
||||
* @param name Name
|
||||
* @return {@link UserLoginBO}
|
||||
*/
|
||||
@GetMapping("/name/{name}")
|
||||
public Mono<R<UserLoginVO>> selectByName(@NotNull @PathVariable(value = "name") String name) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginService.selectByLoginName(name, false);
|
||||
UserLoginVO entityVO = userLoginBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Name User
|
||||
*
|
||||
* @param name Name
|
||||
* @return {@link UserLoginBO}
|
||||
*/
|
||||
@GetMapping("/name/{name}")
|
||||
public Mono<R<UserLoginVO>> selectByName(@NotNull @PathVariable(value = "name") String name) {
|
||||
try {
|
||||
UserLoginBO entityBO = userLoginService.selectByLoginName(name, false);
|
||||
UserLoginVO entityVO = userLoginBuilder.buildVOByBO(entityBO);
|
||||
return Mono.just(R.ok(entityVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User
|
||||
* @param entityQuery
|
||||
* @return {@link UserLoginBO}
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<UserLoginVO>>> list(@RequestBody(required = false) UserLoginQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new UserLoginQuery();
|
||||
}
|
||||
Page<UserLoginBO> entityPageBO = userLoginService.selectByPage(entityQuery);
|
||||
Page<UserLoginVO> entityPageVO = userLoginBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @param entityQuery
|
||||
* @return {@link UserLoginBO}
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Mono<R<Page<UserLoginVO>>> list(@RequestBody(required = false) UserLoginQuery entityQuery) {
|
||||
try {
|
||||
if (Objects.isNull(entityQuery)) {
|
||||
entityQuery = new UserLoginQuery();
|
||||
}
|
||||
Page<UserLoginBO> entityPageBO = userLoginService.selectByPage(entityQuery);
|
||||
Page<UserLoginVO> entityPageVO = userLoginBuilder.buildVOPageByBOPage(entityPageBO);
|
||||
return Mono.just(R.ok(entityPageVO));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Name
|
||||
* @param name Name
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/check/{name}")
|
||||
public Mono<R<Boolean>> checkLoginNameValid(@NotNull @PathVariable(value = "name") String name) {
|
||||
try {
|
||||
return Boolean.TRUE.equals(userLoginService.checkLoginNameValid(name)) ? Mono.just(R.ok())
|
||||
: Mono.just(R.fail());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @param name Name
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/check/{name}")
|
||||
public Mono<R<Boolean>> checkLoginNameValid(@NotNull @PathVariable(value = "name") String name) {
|
||||
try {
|
||||
return Boolean.TRUE.equals(userLoginService.checkLoginNameValid(name)) ? Mono.just(R.ok())
|
||||
: Mono.just(R.fail());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Mono.just(R.fail(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,6 +34,6 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class DriverTokenManagerImpl extends ServiceImpl<DriverTokenMapper, DriverTokenDO>
|
||||
implements DriverTokenManager {
|
||||
implements DriverTokenManager {
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,6 +34,6 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class RoleResourceBindManagerImpl extends ServiceImpl<RoleResourceBindMapper, RoleResourceBindDO>
|
||||
implements RoleResourceBindManager {
|
||||
implements RoleResourceBindManager {
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,6 +34,6 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class RoleUserBindManagerImpl extends ServiceImpl<RoleUserBindMapper, RoleUserBindDO>
|
||||
implements RoleUserBindManager {
|
||||
implements RoleUserBindManager {
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,6 +34,6 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class UserPasswordManagerImpl extends ServiceImpl<UserPasswordMapper, UserPasswordDO>
|
||||
implements UserPasswordManager {
|
||||
implements UserPasswordManager {
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -34,13 +34,13 @@ import java.io.Serializable;
|
||||
@AllArgsConstructor
|
||||
public class AuthHeader implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String user;
|
||||
private String user;
|
||||
|
||||
private String salt;
|
||||
private String salt;
|
||||
|
||||
private String token;
|
||||
private String token;
|
||||
|
||||
}
|
||||
|
||||
+12
-12
@@ -40,22 +40,22 @@ import java.io.Serializable;
|
||||
@AllArgsConstructor
|
||||
public class Login implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "租户不能为空", groups = { Auth.class })
|
||||
private String tenant;
|
||||
@NotBlank(message = "租户不能为空", groups = {Auth.class})
|
||||
private String tenant;
|
||||
|
||||
@NotBlank(message = "名称不能为空", groups = { Check.class, Auth.class, Update.class })
|
||||
private String name;
|
||||
@NotBlank(message = "名称不能为空", groups = {Check.class, Auth.class, Update.class})
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "盐值不能为空", groups = { Check.class, Auth.class })
|
||||
private String salt;
|
||||
@NotBlank(message = "盐值不能为空", groups = {Check.class, Auth.class})
|
||||
private String salt;
|
||||
|
||||
@NotBlank(message = "密码不能为空", groups = { Auth.class })
|
||||
private String password;
|
||||
@NotBlank(message = "密码不能为空", groups = {Auth.class})
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "令牌不能为空", groups = { Check.class })
|
||||
private String token;
|
||||
@NotBlank(message = "令牌不能为空", groups = {Check.class})
|
||||
private String token;
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -35,11 +35,11 @@ import java.util.Date;
|
||||
@AllArgsConstructor
|
||||
public class TokenValid implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean valid;
|
||||
private boolean valid;
|
||||
|
||||
private Date expireTime;
|
||||
private Date expireTime;
|
||||
|
||||
}
|
||||
|
||||
+28
-28
@@ -37,39 +37,39 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class ApiBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* Owning service name, populated by resource registrar
|
||||
*/
|
||||
private String serviceName;
|
||||
/**
|
||||
* Owning service name, populated by resource registrar
|
||||
*/
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
* ApiType
|
||||
*/
|
||||
private ApiTypeFlagEnum apiTypeFlag;
|
||||
/**
|
||||
* ApiType
|
||||
*/
|
||||
private ApiTypeFlagEnum apiTypeFlag;
|
||||
|
||||
/**
|
||||
* ApiName
|
||||
*/
|
||||
private String apiName;
|
||||
/**
|
||||
* ApiName
|
||||
*/
|
||||
private String apiName;
|
||||
|
||||
/**
|
||||
* ApiCode, URLMD5
|
||||
*/
|
||||
private String apiCode;
|
||||
/**
|
||||
* ApiCode, URLMD5
|
||||
*/
|
||||
private String apiCode;
|
||||
|
||||
/**
|
||||
* API grouping, usually the owning controller simple class name
|
||||
*/
|
||||
private String apiGroup;
|
||||
/**
|
||||
* API grouping, usually the owning controller simple class name
|
||||
*/
|
||||
private String apiGroup;
|
||||
|
||||
/**
|
||||
* Api
|
||||
*/
|
||||
private ApiExt apiExt;
|
||||
/**
|
||||
* Api
|
||||
*/
|
||||
private ApiExt apiExt;
|
||||
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+28
-28
@@ -38,39 +38,39 @@ import java.time.LocalDateTime;
|
||||
@ToString(callSuper = true)
|
||||
public class DriverTokenBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* Driver ID
|
||||
*/
|
||||
private String driverCode;
|
||||
/**
|
||||
* Driver ID
|
||||
*/
|
||||
private String driverCode;
|
||||
|
||||
/**
|
||||
* AppID
|
||||
*/
|
||||
private String driverAppId;
|
||||
/**
|
||||
* AppID
|
||||
*/
|
||||
private String driverAppId;
|
||||
|
||||
/**
|
||||
* AppKey
|
||||
*/
|
||||
private String driverAppKey;
|
||||
/**
|
||||
* AppKey
|
||||
*/
|
||||
private String driverAppKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private ExpireFlagEnum expireFlag;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private ExpireFlagEnum expireFlag;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private LocalDateTime expireTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
|
||||
/**
|
||||
* Tenant ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
/**
|
||||
* Tenant ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
|
||||
+32
-32
@@ -38,44 +38,44 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class MenuBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long parentMenuId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long parentMenuId;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
private MenuTypeFlagEnum menuTypeFlag;
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
private MenuTypeFlagEnum menuTypeFlag;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String menuName;
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* Code, URLMD5
|
||||
*/
|
||||
private String menuCode;
|
||||
/**
|
||||
* Code, URLMD5
|
||||
*/
|
||||
private String menuCode;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private MenuLevelFlagEnum menuLevel;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private MenuLevelFlagEnum menuLevel;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer menuIndex;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer menuIndex;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private MenuExt menuExt;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private MenuExt menuExt;
|
||||
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+27
-27
@@ -36,34 +36,34 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MenuTreeBO extends MenuBO {
|
||||
|
||||
private List<MenuTreeBO> children = new ArrayList<>();
|
||||
private List<MenuTreeBO> children = new ArrayList<>();
|
||||
|
||||
public static MenuTreeBO fromBO(MenuBO source) {
|
||||
MenuTreeBO node = new MenuTreeBO();
|
||||
node.setId(source.getId());
|
||||
node.setParentMenuId(source.getParentMenuId());
|
||||
node.setMenuTypeFlag(source.getMenuTypeFlag());
|
||||
node.setMenuName(source.getMenuName());
|
||||
node.setMenuCode(source.getMenuCode());
|
||||
node.setMenuLevel(source.getMenuLevel());
|
||||
node.setMenuIndex(source.getMenuIndex());
|
||||
node.setMenuExt(source.getMenuExt());
|
||||
node.setEnableFlag(source.getEnableFlag());
|
||||
node.setRemark(source.getRemark());
|
||||
node.setCreatorId(source.getCreatorId());
|
||||
node.setCreatorName(source.getCreatorName());
|
||||
node.setCreateTime(source.getCreateTime());
|
||||
node.setOperatorId(source.getOperatorId());
|
||||
node.setOperatorName(source.getOperatorName());
|
||||
node.setOperateTime(source.getOperateTime());
|
||||
return node;
|
||||
}
|
||||
public static MenuTreeBO fromBO(MenuBO source) {
|
||||
MenuTreeBO node = new MenuTreeBO();
|
||||
node.setId(source.getId());
|
||||
node.setParentMenuId(source.getParentMenuId());
|
||||
node.setMenuTypeFlag(source.getMenuTypeFlag());
|
||||
node.setMenuName(source.getMenuName());
|
||||
node.setMenuCode(source.getMenuCode());
|
||||
node.setMenuLevel(source.getMenuLevel());
|
||||
node.setMenuIndex(source.getMenuIndex());
|
||||
node.setMenuExt(source.getMenuExt());
|
||||
node.setEnableFlag(source.getEnableFlag());
|
||||
node.setRemark(source.getRemark());
|
||||
node.setCreatorId(source.getCreatorId());
|
||||
node.setCreatorName(source.getCreatorName());
|
||||
node.setCreateTime(source.getCreateTime());
|
||||
node.setOperatorId(source.getOperatorId());
|
||||
node.setOperatorName(source.getOperatorName());
|
||||
node.setOperateTime(source.getOperateTime());
|
||||
return node;
|
||||
}
|
||||
|
||||
public void addChild(MenuTreeBO child) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(child);
|
||||
}
|
||||
public void addChild(MenuTreeBO child) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+39
-39
@@ -38,51 +38,51 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class ResourceBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long parentResourceId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long parentResourceId;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String resourceName;
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String resourceName;
|
||||
|
||||
/**
|
||||
* Code
|
||||
*/
|
||||
private String resourceCode;
|
||||
/**
|
||||
* Code
|
||||
*/
|
||||
private String resourceCode;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
private ResourceTypeFlagEnum resourceTypeFlag;
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
private ResourceTypeFlagEnum resourceTypeFlag;
|
||||
|
||||
/**
|
||||
* , : ResourceScopeFlagEnum
|
||||
* <ul>
|
||||
* <li>0x01:</li>
|
||||
* <li>0x02:</li>
|
||||
* <li>0x04:</li>
|
||||
* <li>0x08:</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
private ResourceScopeFlagEnum resourceScopeFlag;
|
||||
/**
|
||||
* , : ResourceScopeFlagEnum
|
||||
* <ul>
|
||||
* <li>0x01:</li>
|
||||
* <li>0x02:</li>
|
||||
* <li>0x04:</li>
|
||||
* <li>0x08:</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
private ResourceScopeFlagEnum resourceScopeFlag;
|
||||
|
||||
/**
|
||||
* Entity ID
|
||||
*/
|
||||
private Long entityId;
|
||||
/**
|
||||
* Entity ID
|
||||
*/
|
||||
private Long entityId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private ResourceExt resourceExt;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private ResourceExt resourceExt;
|
||||
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+26
-26
@@ -34,36 +34,36 @@ import lombok.*;
|
||||
@AllArgsConstructor
|
||||
public class ResourceRegistryScannedApi {
|
||||
|
||||
/**
|
||||
* HTTP method: GET / POST / PUT / DELETE.
|
||||
*/
|
||||
private String method;
|
||||
/**
|
||||
* HTTP method: GET / POST / PUT / DELETE.
|
||||
*/
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* Full path (post gateway strip), e.g. /device/add.
|
||||
*/
|
||||
private String path;
|
||||
/**
|
||||
* Full path (post gateway strip), e.g. /device/add.
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* Human-readable name, typically ClassSimpleName.methodName.
|
||||
*/
|
||||
private String apiName;
|
||||
/**
|
||||
* Human-readable name, typically ClassSimpleName.methodName.
|
||||
*/
|
||||
private String apiName;
|
||||
|
||||
/**
|
||||
* Short title, usually the controller method name.
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* Short title, usually the controller method name.
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Optional description.
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* Optional description.
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* API grouping label — usually the owning controller's simple class name, e.g.
|
||||
* "ApiController". Endpoints sharing the same apiGroup become siblings under the same
|
||||
* resource-tree node.
|
||||
*/
|
||||
private String apiGroup;
|
||||
/**
|
||||
* API grouping label — usually the owning controller's simple class name, e.g.
|
||||
* "ApiController". Endpoints sharing the same apiGroup become siblings under the same
|
||||
* resource-tree node.
|
||||
*/
|
||||
private String apiGroup;
|
||||
|
||||
}
|
||||
|
||||
+13
-13
@@ -36,20 +36,20 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class ResourceRegistrySyncCommand {
|
||||
|
||||
/**
|
||||
* Owning service name, e.g. dc3-center-manager.
|
||||
*/
|
||||
private String serviceName;
|
||||
/**
|
||||
* Owning service name, e.g. dc3-center-manager.
|
||||
*/
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
* When true, endpoints that exist in the DB but are absent from the current scan are
|
||||
* soft-deleted. When false, such endpoints are left untouched.
|
||||
*/
|
||||
private boolean deleteMissing;
|
||||
/**
|
||||
* When true, endpoints that exist in the DB but are absent from the current scan are
|
||||
* soft-deleted. When false, such endpoints are left untouched.
|
||||
*/
|
||||
private boolean deleteMissing;
|
||||
|
||||
/**
|
||||
* Complete list of endpoints discovered by the registrar on the calling service.
|
||||
*/
|
||||
private List<ResourceRegistryScannedApi> apis;
|
||||
/**
|
||||
* Complete list of endpoints discovered by the registrar on the calling service.
|
||||
*/
|
||||
private List<ResourceRegistryScannedApi> apis;
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -34,12 +34,12 @@ import lombok.*;
|
||||
@AllArgsConstructor
|
||||
public class ResourceRegistrySyncResult {
|
||||
|
||||
private int inserted;
|
||||
private int inserted;
|
||||
|
||||
private int updated;
|
||||
private int updated;
|
||||
|
||||
private int deleted;
|
||||
private int deleted;
|
||||
|
||||
private int unchanged;
|
||||
private int unchanged;
|
||||
|
||||
}
|
||||
|
||||
+30
-30
@@ -37,37 +37,37 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ResourceTreeBO extends ResourceBO {
|
||||
|
||||
private List<ResourceTreeBO> children = new ArrayList<>();
|
||||
private List<ResourceTreeBO> children = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Copy shared fields from a flat {@link ResourceBO} into a new tree node.
|
||||
*/
|
||||
public static ResourceTreeBO fromBO(ResourceBO source) {
|
||||
ResourceTreeBO node = new ResourceTreeBO();
|
||||
node.setId(source.getId());
|
||||
node.setParentResourceId(source.getParentResourceId());
|
||||
node.setResourceName(source.getResourceName());
|
||||
node.setResourceCode(source.getResourceCode());
|
||||
node.setResourceTypeFlag(source.getResourceTypeFlag());
|
||||
node.setResourceScopeFlag(source.getResourceScopeFlag());
|
||||
node.setEntityId(source.getEntityId());
|
||||
node.setResourceExt(source.getResourceExt());
|
||||
node.setEnableFlag(source.getEnableFlag());
|
||||
node.setRemark(source.getRemark());
|
||||
node.setCreatorId(source.getCreatorId());
|
||||
node.setCreatorName(source.getCreatorName());
|
||||
node.setCreateTime(source.getCreateTime());
|
||||
node.setOperatorId(source.getOperatorId());
|
||||
node.setOperatorName(source.getOperatorName());
|
||||
node.setOperateTime(source.getOperateTime());
|
||||
return node;
|
||||
}
|
||||
/**
|
||||
* Copy shared fields from a flat {@link ResourceBO} into a new tree node.
|
||||
*/
|
||||
public static ResourceTreeBO fromBO(ResourceBO source) {
|
||||
ResourceTreeBO node = new ResourceTreeBO();
|
||||
node.setId(source.getId());
|
||||
node.setParentResourceId(source.getParentResourceId());
|
||||
node.setResourceName(source.getResourceName());
|
||||
node.setResourceCode(source.getResourceCode());
|
||||
node.setResourceTypeFlag(source.getResourceTypeFlag());
|
||||
node.setResourceScopeFlag(source.getResourceScopeFlag());
|
||||
node.setEntityId(source.getEntityId());
|
||||
node.setResourceExt(source.getResourceExt());
|
||||
node.setEnableFlag(source.getEnableFlag());
|
||||
node.setRemark(source.getRemark());
|
||||
node.setCreatorId(source.getCreatorId());
|
||||
node.setCreatorName(source.getCreatorName());
|
||||
node.setCreateTime(source.getCreateTime());
|
||||
node.setOperatorId(source.getOperatorId());
|
||||
node.setOperatorName(source.getOperatorName());
|
||||
node.setOperateTime(source.getOperateTime());
|
||||
return node;
|
||||
}
|
||||
|
||||
public void addChild(ResourceTreeBO child) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(child);
|
||||
}
|
||||
public void addChild(ResourceTreeBO child) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-24
@@ -36,34 +36,34 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class RoleBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String parentRoleId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String parentRoleId;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String roleName;
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* Code
|
||||
*/
|
||||
private String roleCode;
|
||||
/**
|
||||
* Code
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private RoleExt roleExt;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private RoleExt roleExt;
|
||||
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
|
||||
/**
|
||||
* Tenant ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
/**
|
||||
* Tenant ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -34,14 +34,14 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class RoleResourceBindBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long resourceId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long resourceId;
|
||||
|
||||
}
|
||||
|
||||
+28
-28
@@ -38,35 +38,35 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RoleTreeBO extends RoleBO {
|
||||
|
||||
private List<RoleTreeBO> children = new ArrayList<>();
|
||||
private List<RoleTreeBO> children = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Copy shared fields from a flat {@link RoleBO} into a new tree node.
|
||||
*/
|
||||
public static RoleTreeBO fromBO(RoleBO source) {
|
||||
RoleTreeBO node = new RoleTreeBO();
|
||||
node.setId(source.getId());
|
||||
node.setParentRoleId(source.getParentRoleId());
|
||||
node.setRoleName(source.getRoleName());
|
||||
node.setRoleCode(source.getRoleCode());
|
||||
node.setRoleExt(source.getRoleExt());
|
||||
node.setEnableFlag(source.getEnableFlag());
|
||||
node.setTenantId(source.getTenantId());
|
||||
node.setRemark(source.getRemark());
|
||||
node.setCreatorId(source.getCreatorId());
|
||||
node.setCreatorName(source.getCreatorName());
|
||||
node.setCreateTime(source.getCreateTime());
|
||||
node.setOperatorId(source.getOperatorId());
|
||||
node.setOperatorName(source.getOperatorName());
|
||||
node.setOperateTime(source.getOperateTime());
|
||||
return node;
|
||||
}
|
||||
/**
|
||||
* Copy shared fields from a flat {@link RoleBO} into a new tree node.
|
||||
*/
|
||||
public static RoleTreeBO fromBO(RoleBO source) {
|
||||
RoleTreeBO node = new RoleTreeBO();
|
||||
node.setId(source.getId());
|
||||
node.setParentRoleId(source.getParentRoleId());
|
||||
node.setRoleName(source.getRoleName());
|
||||
node.setRoleCode(source.getRoleCode());
|
||||
node.setRoleExt(source.getRoleExt());
|
||||
node.setEnableFlag(source.getEnableFlag());
|
||||
node.setTenantId(source.getTenantId());
|
||||
node.setRemark(source.getRemark());
|
||||
node.setCreatorId(source.getCreatorId());
|
||||
node.setCreatorName(source.getCreatorName());
|
||||
node.setCreateTime(source.getCreateTime());
|
||||
node.setOperatorId(source.getOperatorId());
|
||||
node.setOperatorName(source.getOperatorName());
|
||||
node.setOperateTime(source.getOperateTime());
|
||||
return node;
|
||||
}
|
||||
|
||||
public void addChild(RoleTreeBO child) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(child);
|
||||
}
|
||||
public void addChild(RoleTreeBO child) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -34,14 +34,14 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class RoleUserBindBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
|
||||
+16
-16
@@ -36,24 +36,24 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class TenantBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* TenantName
|
||||
*/
|
||||
private String tenantName;
|
||||
/**
|
||||
* TenantName
|
||||
*/
|
||||
private String tenantName;
|
||||
|
||||
/**
|
||||
* TenantCode
|
||||
*/
|
||||
private String tenantCode;
|
||||
/**
|
||||
* TenantCode
|
||||
*/
|
||||
private String tenantCode;
|
||||
|
||||
/**
|
||||
* Tenant
|
||||
*/
|
||||
private TenantExt tenantExt;
|
||||
/**
|
||||
* Tenant
|
||||
*/
|
||||
private TenantExt tenantExt;
|
||||
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -34,14 +34,14 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class TenantBindBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* Tenant ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
/**
|
||||
* Tenant ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
|
||||
+28
-28
@@ -36,39 +36,39 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class UserBO extends BaseBO {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String nickName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private UserSocialExt socialExt;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private UserSocialExt socialExt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private UserIdentityExt identityExt;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private UserIdentityExt identityExt;
|
||||
|
||||
/**
|
||||
* Enable flag, 0:, 1:Disable
|
||||
*/
|
||||
private Byte enableFlag;
|
||||
/**
|
||||
* Enable flag, 0:, 1:Disable
|
||||
*/
|
||||
private Byte enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+16
-16
@@ -35,24 +35,24 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class UserLoginBO extends BaseBO {
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String loginName;
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
private String loginName;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userPasswordId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long userPasswordId;
|
||||
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
/**
|
||||
* Enable flag
|
||||
*/
|
||||
private EnableFlagEnum enableFlag;
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -34,9 +34,9 @@ import lombok.*;
|
||||
@ToString(callSuper = true)
|
||||
public class UserPasswordBO extends BaseBO {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String loginPassword;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String loginPassword;
|
||||
|
||||
}
|
||||
|
||||
+133
-123
@@ -45,146 +45,156 @@ import java.util.Optional;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface ApiBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
ApiBO buildBOByVO(ApiVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
ApiBO buildBOByVO(ApiVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ApiBO> buildBOListByVOList(List<ApiVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ApiBO> buildBOListByVOList(List<ApiVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "apiExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "apiTypeFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
ApiDO buildDOByBO(ApiBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "apiExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "apiTypeFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
ApiDO buildDOByBO(ApiBO entityBO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(ApiBO entityBO, @MappingTarget ApiDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getApiCode())) {
|
||||
entityDO.setApiCode(CodeUtil.getCode());
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(ApiBO entityBO, @MappingTarget ApiDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getApiCode())) {
|
||||
entityDO.setApiCode(CodeUtil.getCode());
|
||||
}
|
||||
|
||||
// Json Ext
|
||||
ApiExt entityExt = entityBO.getApiExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setApiExt(ext);
|
||||
// Json Ext
|
||||
ApiExt entityExt = entityBO.getApiExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setApiExt(ext);
|
||||
|
||||
// ApiType Flag
|
||||
ApiTypeFlagEnum apiTypeFlag = entityBO.getApiTypeFlag();
|
||||
entityDO.setApiTypeFlag(apiTypeFlag.getIndex());
|
||||
Optional.ofNullable(apiTypeFlag).ifPresent(value -> entityDO.setApiTypeFlag(value.getIndex()));
|
||||
// ApiType Flag
|
||||
ApiTypeFlagEnum apiTypeFlag = entityBO.getApiTypeFlag();
|
||||
entityDO.setApiTypeFlag(apiTypeFlag.getIndex());
|
||||
Optional.ofNullable(apiTypeFlag).ifPresent(value -> entityDO.setApiTypeFlag(value.getIndex()));
|
||||
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<ApiDO> buildDOListByBOList(List<ApiBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<ApiDO> buildDOListByBOList(List<ApiBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "apiExt", ignore = true)
|
||||
@Mapping(target = "apiTypeFlag", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
ApiBO buildBOByDO(ApiDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "apiExt", ignore = true)
|
||||
@Mapping(target = "apiTypeFlag", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
ApiBO buildBOByDO(ApiDO entityDO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(ApiDO entityDO, @MappingTarget ApiBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getApiExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ApiExt ext = new ApiExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), ApiExt.Content.class));
|
||||
entityBO.setApiExt(ext);
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(ApiDO entityDO, @MappingTarget ApiBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getApiExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ApiExt ext = new ApiExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), ApiExt.Content.class));
|
||||
entityBO.setApiExt(ext);
|
||||
}
|
||||
|
||||
// ApiType Flag
|
||||
Byte apiTypeFlag = entityDO.getApiTypeFlag();
|
||||
entityBO.setApiTypeFlag(ApiTypeFlagEnum.ofIndex(apiTypeFlag));
|
||||
// ApiType Flag
|
||||
Byte apiTypeFlag = entityDO.getApiTypeFlag();
|
||||
entityBO.setApiTypeFlag(ApiTypeFlagEnum.ofIndex(apiTypeFlag));
|
||||
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ApiBO> buildBOListByDOList(List<ApiDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ApiBO> buildBOListByDOList(List<ApiDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
ApiVO buildVOByBO(ApiBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
ApiVO buildVOByBO(ApiBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<ApiVO> buildVOListByBOList(List<ApiBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<ApiVO> buildVOListByBOList(List<ApiBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ApiBO> buildBOPageByDOPage(Page<ApiDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ApiBO> buildBOPageByDOPage(Page<ApiDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ApiVO> buildVOPageByBOPage(Page<ApiBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ApiVO> buildVOPageByBOPage(Page<ApiBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+47
-43
@@ -33,55 +33,59 @@ import org.mapstruct.Mapping;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface DictionaryForAuthBuilder extends DictionaryBuilder {
|
||||
|
||||
// Tenant
|
||||
// Tenant
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
default DictionaryBO buildVOByTenantBO(TenantBO entityBO) {
|
||||
return DictionaryBO.builder().label(entityBO.getTenantName()).value(entityBO.getId().toString()).build();
|
||||
}
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
default DictionaryBO buildVOByTenantBO(TenantBO entityBO) {
|
||||
return DictionaryBO.builder().label(entityBO.getTenantName()).value(entityBO.getId().toString()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<DictionaryBO> buildVOPageByTenantBOPage(Page<TenantBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<DictionaryBO> buildVOPageByTenantBOPage(Page<TenantBO> entityPageBO);
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
default DictionaryBO buildVOByUserLoginBO(UserLoginBO entityBO) {
|
||||
return DictionaryBO.builder().label(entityBO.getLoginName()).value(entityBO.getId().toString()).build();
|
||||
}
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
default DictionaryBO buildVOByUserLoginBO(UserLoginBO entityBO) {
|
||||
return DictionaryBO.builder().label(entityBO.getLoginName()).value(entityBO.getId().toString()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<DictionaryBO> buildVOPageByUserLoginBOPage(Page<UserLoginBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<DictionaryBO> buildVOPageByUserLoginBOPage(Page<UserLoginBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+140
-130
@@ -46,155 +46,165 @@ import java.util.Optional;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface MenuBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
MenuBO buildBOByVO(MenuVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
MenuBO buildBOByVO(MenuVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<MenuBO> buildBOListByVOList(List<MenuVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<MenuBO> buildBOListByVOList(List<MenuVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "menuExt", ignore = true)
|
||||
@Mapping(target = "menuTypeFlag", ignore = true)
|
||||
@Mapping(target = "menuLevel", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
MenuDO buildDOByBO(MenuBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "menuExt", ignore = true)
|
||||
@Mapping(target = "menuTypeFlag", ignore = true)
|
||||
@Mapping(target = "menuLevel", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
MenuDO buildDOByBO(MenuBO entityBO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(MenuBO entityBO, @MappingTarget MenuDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getMenuCode())) {
|
||||
entityDO.setMenuCode(CodeUtil.getCode());
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(MenuBO entityBO, @MappingTarget MenuDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getMenuCode())) {
|
||||
entityDO.setMenuCode(CodeUtil.getCode());
|
||||
}
|
||||
|
||||
// Json Ext
|
||||
MenuExt entityExt = entityBO.getMenuExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setMenuExt(ext);
|
||||
// Json Ext
|
||||
MenuExt entityExt = entityBO.getMenuExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setMenuExt(ext);
|
||||
|
||||
// MenuType Flag
|
||||
MenuTypeFlagEnum menuTypeFlag = entityBO.getMenuTypeFlag();
|
||||
Optional.ofNullable(menuTypeFlag).ifPresent(value -> entityDO.setMenuTypeFlag(value.getIndex()));
|
||||
// MenuType Flag
|
||||
MenuTypeFlagEnum menuTypeFlag = entityBO.getMenuTypeFlag();
|
||||
Optional.ofNullable(menuTypeFlag).ifPresent(value -> entityDO.setMenuTypeFlag(value.getIndex()));
|
||||
|
||||
// MenuLevel Flag
|
||||
MenuLevelFlagEnum menuLevel = entityBO.getMenuLevel();
|
||||
Optional.ofNullable(menuLevel).ifPresent(value -> entityDO.setMenuLevel(value.getIndex()));
|
||||
// MenuLevel Flag
|
||||
MenuLevelFlagEnum menuLevel = entityBO.getMenuLevel();
|
||||
Optional.ofNullable(menuLevel).ifPresent(value -> entityDO.setMenuLevel(value.getIndex()));
|
||||
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<MenuDO> buildDOListByBOList(List<MenuBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<MenuDO> buildDOListByBOList(List<MenuBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "menuExt", ignore = true)
|
||||
@Mapping(target = "menuTypeFlag", ignore = true)
|
||||
@Mapping(target = "menuLevel", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
MenuBO buildBOByDO(MenuDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "menuExt", ignore = true)
|
||||
@Mapping(target = "menuTypeFlag", ignore = true)
|
||||
@Mapping(target = "menuLevel", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
MenuBO buildBOByDO(MenuDO entityDO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(MenuDO entityDO, @MappingTarget MenuBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getMenuExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
MenuExt ext = new MenuExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), MenuExt.Content.class));
|
||||
entityBO.setMenuExt(ext);
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(MenuDO entityDO, @MappingTarget MenuBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getMenuExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
MenuExt ext = new MenuExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), MenuExt.Content.class));
|
||||
entityBO.setMenuExt(ext);
|
||||
}
|
||||
|
||||
// MenuType Flag
|
||||
Byte menuTypeFlag = entityDO.getMenuTypeFlag();
|
||||
entityBO.setMenuTypeFlag(MenuTypeFlagEnum.ofIndex(menuTypeFlag));
|
||||
// MenuType Flag
|
||||
Byte menuTypeFlag = entityDO.getMenuTypeFlag();
|
||||
entityBO.setMenuTypeFlag(MenuTypeFlagEnum.ofIndex(menuTypeFlag));
|
||||
|
||||
// MenuLevel Flag
|
||||
Byte menuLevel = entityDO.getMenuLevel();
|
||||
entityBO.setMenuLevel(MenuLevelFlagEnum.ofIndex(menuLevel));
|
||||
// MenuLevel Flag
|
||||
Byte menuLevel = entityDO.getMenuLevel();
|
||||
entityBO.setMenuLevel(MenuLevelFlagEnum.ofIndex(menuLevel));
|
||||
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<MenuBO> buildBOListByDOList(List<MenuDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<MenuBO> buildBOListByDOList(List<MenuDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
MenuVO buildVOByBO(MenuBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
MenuVO buildVOByBO(MenuBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<MenuVO> buildVOListByBOList(List<MenuBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<MenuVO> buildVOListByBOList(List<MenuBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<MenuBO> buildBOPageByDOPage(Page<MenuDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<MenuBO> buildBOPageByDOPage(Page<MenuDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<MenuVO> buildVOPageByBOPage(Page<MenuBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<MenuVO> buildVOPageByBOPage(Page<MenuBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+140
-130
@@ -46,155 +46,165 @@ import java.util.Optional;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface ResourceBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
ResourceBO buildBOByVO(ResourceVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
ResourceBO buildBOByVO(ResourceVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ResourceBO> buildBOListByVOList(List<ResourceVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ResourceBO> buildBOListByVOList(List<ResourceVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "resourceExt", ignore = true)
|
||||
@Mapping(target = "resourceTypeFlag", ignore = true)
|
||||
@Mapping(target = "resourceScopeFlag", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
ResourceDO buildDOByBO(ResourceBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "resourceExt", ignore = true)
|
||||
@Mapping(target = "resourceTypeFlag", ignore = true)
|
||||
@Mapping(target = "resourceScopeFlag", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
ResourceDO buildDOByBO(ResourceBO entityBO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(ResourceBO entityBO, @MappingTarget ResourceDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getResourceCode())) {
|
||||
entityDO.setResourceCode(CodeUtil.getCode());
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(ResourceBO entityBO, @MappingTarget ResourceDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getResourceCode())) {
|
||||
entityDO.setResourceCode(CodeUtil.getCode());
|
||||
}
|
||||
|
||||
// Json Ext
|
||||
ResourceExt entityExt = entityBO.getResourceExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setResourceExt(ext);
|
||||
// Json Ext
|
||||
ResourceExt entityExt = entityBO.getResourceExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setResourceExt(ext);
|
||||
|
||||
// ResourceType Flag
|
||||
ResourceTypeFlagEnum resourceTypeFlag = entityBO.getResourceTypeFlag();
|
||||
Optional.ofNullable(resourceTypeFlag).ifPresent(value -> entityDO.setResourceTypeFlag(value.getIndex()));
|
||||
// ResourceType Flag
|
||||
ResourceTypeFlagEnum resourceTypeFlag = entityBO.getResourceTypeFlag();
|
||||
Optional.ofNullable(resourceTypeFlag).ifPresent(value -> entityDO.setResourceTypeFlag(value.getIndex()));
|
||||
|
||||
// ResourceScope Flag
|
||||
ResourceScopeFlagEnum resourceScopeFlag = entityBO.getResourceScopeFlag();
|
||||
Optional.ofNullable(resourceScopeFlag).ifPresent(value -> entityDO.setResourceScopeFlag(value.getIndex()));
|
||||
// ResourceScope Flag
|
||||
ResourceScopeFlagEnum resourceScopeFlag = entityBO.getResourceScopeFlag();
|
||||
Optional.ofNullable(resourceScopeFlag).ifPresent(value -> entityDO.setResourceScopeFlag(value.getIndex()));
|
||||
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<ResourceDO> buildDOListByBOList(List<ResourceBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<ResourceDO> buildDOListByBOList(List<ResourceBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "resourceExt", ignore = true)
|
||||
@Mapping(target = "resourceTypeFlag", ignore = true)
|
||||
@Mapping(target = "resourceScopeFlag", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
ResourceBO buildBOByDO(ResourceDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "resourceExt", ignore = true)
|
||||
@Mapping(target = "resourceTypeFlag", ignore = true)
|
||||
@Mapping(target = "resourceScopeFlag", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
ResourceBO buildBOByDO(ResourceDO entityDO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(ResourceDO entityDO, @MappingTarget ResourceBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getResourceExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ResourceExt ext = new ResourceExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), ResourceExt.Content.class));
|
||||
entityBO.setResourceExt(ext);
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(ResourceDO entityDO, @MappingTarget ResourceBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getResourceExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ResourceExt ext = new ResourceExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), ResourceExt.Content.class));
|
||||
entityBO.setResourceExt(ext);
|
||||
}
|
||||
|
||||
// ResourceType Flag
|
||||
Byte resourceTypeFlag = entityDO.getResourceTypeFlag();
|
||||
entityBO.setResourceTypeFlag(ResourceTypeFlagEnum.ofIndex(resourceTypeFlag));
|
||||
// ResourceType Flag
|
||||
Byte resourceTypeFlag = entityDO.getResourceTypeFlag();
|
||||
entityBO.setResourceTypeFlag(ResourceTypeFlagEnum.ofIndex(resourceTypeFlag));
|
||||
|
||||
// ResourceScope Flag
|
||||
Byte resourceScopeFlag = entityDO.getResourceScopeFlag();
|
||||
entityBO.setResourceScopeFlag(ResourceScopeFlagEnum.ofIndex(resourceScopeFlag));
|
||||
// ResourceScope Flag
|
||||
Byte resourceScopeFlag = entityDO.getResourceScopeFlag();
|
||||
entityBO.setResourceScopeFlag(ResourceScopeFlagEnum.ofIndex(resourceScopeFlag));
|
||||
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ResourceBO> buildBOListByDOList(List<ResourceDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<ResourceBO> buildBOListByDOList(List<ResourceDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
ResourceVO buildVOByBO(ResourceBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
ResourceVO buildVOByBO(ResourceBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<ResourceVO> buildVOListByBOList(List<ResourceBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<ResourceVO> buildVOListByBOList(List<ResourceBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ResourceBO> buildBOPageByDOPage(Page<ResourceDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ResourceBO> buildBOPageByDOPage(Page<ResourceDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ResourceVO> buildVOPageByBOPage(Page<ResourceBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<ResourceVO> buildVOPageByBOPage(Page<ResourceBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+125
-115
@@ -44,136 +44,146 @@ import java.util.Optional;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface RoleBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "tenantId", ignore = true)
|
||||
RoleBO buildBOByVO(RoleVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "tenantId", ignore = true)
|
||||
RoleBO buildBOByVO(RoleVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleBO> buildBOListByVOList(List<RoleVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleBO> buildBOListByVOList(List<RoleVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "roleExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
RoleDO buildDOByBO(RoleBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "roleExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
RoleDO buildDOByBO(RoleBO entityBO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(RoleBO entityBO, @MappingTarget RoleDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getRoleCode())) {
|
||||
entityDO.setRoleCode(CodeUtil.getCode());
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(RoleBO entityBO, @MappingTarget RoleDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getRoleCode())) {
|
||||
entityDO.setRoleCode(CodeUtil.getCode());
|
||||
}
|
||||
|
||||
// Json Ext
|
||||
RoleExt entityExt = entityBO.getRoleExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setRoleExt(ext);
|
||||
// Json Ext
|
||||
RoleExt entityExt = entityBO.getRoleExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setRoleExt(ext);
|
||||
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<RoleDO> buildDOListByBOList(List<RoleBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<RoleDO> buildDOListByBOList(List<RoleBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "roleExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
RoleBO buildBOByDO(RoleDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "roleExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
RoleBO buildBOByDO(RoleDO entityDO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(RoleDO entityDO, @MappingTarget RoleBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getRoleExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
RoleExt ext = new RoleExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), RoleExt.Content.class));
|
||||
entityBO.setRoleExt(ext);
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(RoleDO entityDO, @MappingTarget RoleBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getRoleExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
RoleExt ext = new RoleExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), RoleExt.Content.class));
|
||||
entityBO.setRoleExt(ext);
|
||||
}
|
||||
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleBO> buildBOListByDOList(List<RoleDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleBO> buildBOListByDOList(List<RoleDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
RoleVO buildVOByBO(RoleBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
RoleVO buildVOByBO(RoleBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<RoleVO> buildVOListByBOList(List<RoleBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<RoleVO> buildVOListByBOList(List<RoleBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleBO> buildBOPageByDOPage(Page<RoleDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleBO> buildBOPageByDOPage(Page<RoleDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleVO> buildVOPageByBOPage(Page<RoleBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleVO> buildVOPageByBOPage(Page<RoleBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+84
-74
@@ -34,90 +34,100 @@ import java.util.List;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface RoleResourceBindBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleResourceBindBO buildBOByVO(RoleResourceBindVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleResourceBindBO buildBOByVO(RoleResourceBindVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleResourceBindBO> buildBOListByVOList(List<RoleResourceBindVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleResourceBindBO> buildBOListByVOList(List<RoleResourceBindVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
RoleResourceBindDO buildDOByBO(RoleResourceBindBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
RoleResourceBindDO buildDOByBO(RoleResourceBindBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<RoleResourceBindDO> buildDOListByBOList(List<RoleResourceBindBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<RoleResourceBindDO> buildDOListByBOList(List<RoleResourceBindBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleResourceBindBO buildBOByDO(RoleResourceBindDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleResourceBindBO buildBOByDO(RoleResourceBindDO entityDO);
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleResourceBindBO> buildBOListByDOList(List<RoleResourceBindDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleResourceBindBO> buildBOListByDOList(List<RoleResourceBindDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
RoleResourceBindVO buildVOByBO(RoleResourceBindBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
RoleResourceBindVO buildVOByBO(RoleResourceBindBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<RoleResourceBindVO> buildVOListByBOList(List<RoleResourceBindBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<RoleResourceBindVO> buildVOListByBOList(List<RoleResourceBindBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleResourceBindBO> buildBOPageByDOPage(Page<RoleResourceBindDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleResourceBindBO> buildBOPageByDOPage(Page<RoleResourceBindDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleResourceBindVO> buildVOPageByBOPage(Page<RoleResourceBindBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleResourceBindVO> buildVOPageByBOPage(Page<RoleResourceBindBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+84
-74
@@ -34,90 +34,100 @@ import java.util.List;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface RoleUserBindBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleUserBindBO buildBOByVO(RoleUserBindVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleUserBindBO buildBOByVO(RoleUserBindVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleUserBindBO> buildBOListByVOList(List<RoleUserBindVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleUserBindBO> buildBOListByVOList(List<RoleUserBindVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
RoleUserBindDO buildDOByBO(RoleUserBindBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
RoleUserBindDO buildDOByBO(RoleUserBindBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<RoleUserBindDO> buildDOListByBOList(List<RoleUserBindBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<RoleUserBindDO> buildDOListByBOList(List<RoleUserBindBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleUserBindBO buildBOByDO(RoleUserBindDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
RoleUserBindBO buildBOByDO(RoleUserBindDO entityDO);
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleUserBindBO> buildBOListByDOList(List<RoleUserBindDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<RoleUserBindBO> buildBOListByDOList(List<RoleUserBindDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
RoleUserBindVO buildVOByBO(RoleUserBindBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
RoleUserBindVO buildVOByBO(RoleUserBindBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<RoleUserBindVO> buildVOListByBOList(List<RoleUserBindBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<RoleUserBindVO> buildVOListByBOList(List<RoleUserBindBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleUserBindBO> buildBOPageByDOPage(Page<RoleUserBindDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleUserBindBO> buildBOPageByDOPage(Page<RoleUserBindDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleUserBindVO> buildVOPageByBOPage(Page<RoleUserBindBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<RoleUserBindVO> buildVOPageByBOPage(Page<RoleUserBindBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+84
-74
@@ -34,90 +34,100 @@ import java.util.List;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface TenantBindBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
TenantBindBO buildBOByVO(TenantBindVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
TenantBindBO buildBOByVO(TenantBindVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBindBO> buildBOListByVOList(List<TenantBindVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBindBO> buildBOListByVOList(List<TenantBindVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
TenantBindDO buildDOByBO(TenantBindBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
TenantBindDO buildDOByBO(TenantBindBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<TenantBindDO> buildDOListByBOList(List<TenantBindBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<TenantBindDO> buildDOListByBOList(List<TenantBindBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
TenantBindBO buildBOByDO(TenantBindDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
TenantBindBO buildBOByDO(TenantBindDO entityDO);
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBindBO> buildBOListByDOList(List<TenantBindDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBindBO> buildBOListByDOList(List<TenantBindDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
TenantBindVO buildVOByBO(TenantBindBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
TenantBindVO buildVOByBO(TenantBindBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<TenantBindVO> buildVOListByBOList(List<TenantBindBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<TenantBindVO> buildVOListByBOList(List<TenantBindBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantBindBO> buildBOPageByDOPage(Page<TenantBindDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantBindBO> buildBOPageByDOPage(Page<TenantBindDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantBindVO> buildVOPageByBOPage(Page<TenantBindBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantBindVO> buildVOPageByBOPage(Page<TenantBindBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
+124
-114
@@ -44,135 +44,145 @@ import java.util.Optional;
|
||||
* @version 2025.9.0
|
||||
* @since 2022.1.0
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = { MapStructUtil.class })
|
||||
@Mapper(componentModel = "spring", uses = {MapStructUtil.class})
|
||||
public interface TenantBuilder {
|
||||
|
||||
/**
|
||||
* VO to BO
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
TenantBO buildBOByVO(TenantVO entityVO);
|
||||
/**
|
||||
* VO to BO
|
||||
*
|
||||
* @param entityVO EntityVO
|
||||
* @return EntityBO
|
||||
*/
|
||||
TenantBO buildBOByVO(TenantVO entityVO);
|
||||
|
||||
/**
|
||||
* VOList to BOList
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBO> buildBOListByVOList(List<TenantVO> entityVOList);
|
||||
/**
|
||||
* VOList to BOList
|
||||
*
|
||||
* @param entityVOList EntityVO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBO> buildBOListByVOList(List<TenantVO> entityVOList);
|
||||
|
||||
/**
|
||||
* BO to DO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "tenantExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
TenantDO buildDOByBO(TenantBO entityBO);
|
||||
/**
|
||||
* BO to DO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityDO
|
||||
*/
|
||||
@Mapping(target = "tenantExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
TenantDO buildDOByBO(TenantBO entityBO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(TenantBO entityBO, @MappingTarget TenantDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getTenantCode())) {
|
||||
entityDO.setTenantCode(CodeUtil.getCode());
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(TenantBO entityBO, @MappingTarget TenantDO entityDO) {
|
||||
// Code
|
||||
if (StringUtils.isEmpty(entityBO.getTenantCode())) {
|
||||
entityDO.setTenantCode(CodeUtil.getCode());
|
||||
}
|
||||
|
||||
// Json Ext
|
||||
TenantExt entityExt = entityBO.getTenantExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setTenantExt(ext);
|
||||
// Json Ext
|
||||
TenantExt entityExt = entityBO.getTenantExt();
|
||||
JsonExt ext = new JsonExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.toJsonString(entityExt.getContent()));
|
||||
}
|
||||
entityDO.setTenantExt(ext);
|
||||
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
// Enable Flag
|
||||
EnableFlagEnum enableFlag = entityBO.getEnableFlag();
|
||||
Optional.ofNullable(enableFlag).ifPresent(value -> entityDO.setEnableFlag(value.getIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* BOList to DOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<TenantDO> buildDOListByBOList(List<TenantBO> entityBOList);
|
||||
/**
|
||||
* BOList to DOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityDO Array
|
||||
*/
|
||||
List<TenantDO> buildDOListByBOList(List<TenantBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DO to BO
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "tenantExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
TenantBO buildBOByDO(TenantDO entityDO);
|
||||
/**
|
||||
* DO to BO
|
||||
*
|
||||
* @param entityDO EntityDO
|
||||
* @return EntityBO
|
||||
*/
|
||||
@Mapping(target = "tenantExt", ignore = true)
|
||||
@Mapping(target = "enableFlag", ignore = true)
|
||||
TenantBO buildBOByDO(TenantDO entityDO);
|
||||
|
||||
@AfterMapping
|
||||
default void afterProcess(TenantDO entityDO, @MappingTarget TenantBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getTenantExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
TenantExt ext = new TenantExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), TenantExt.Content.class));
|
||||
entityBO.setTenantExt(ext);
|
||||
}
|
||||
@AfterMapping
|
||||
default void afterProcess(TenantDO entityDO, @MappingTarget TenantBO entityBO) {
|
||||
// Json Ext
|
||||
JsonExt entityExt = entityDO.getTenantExt();
|
||||
if (Objects.nonNull(entityExt)) {
|
||||
TenantExt ext = new TenantExt();
|
||||
ext.setType(entityExt.getType());
|
||||
ext.setVersion(entityExt.getVersion());
|
||||
ext.setRemark(entityExt.getRemark());
|
||||
ext.setContent(JsonUtil.parseObject(entityExt.getContent(), TenantExt.Content.class));
|
||||
entityBO.setTenantExt(ext);
|
||||
}
|
||||
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
// Enable Flag
|
||||
Byte enableFlag = entityDO.getEnableFlag();
|
||||
entityBO.setEnableFlag(EnableFlagEnum.ofIndex(enableFlag));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOList to BOList
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBO> buildBOListByDOList(List<TenantDO> entityDOList);
|
||||
/**
|
||||
* DOList to BOList
|
||||
*
|
||||
* @param entityDOList EntityDO Array
|
||||
* @return EntityBO Array
|
||||
*/
|
||||
List<TenantBO> buildBOListByDOList(List<TenantDO> entityDOList);
|
||||
|
||||
/**
|
||||
* BO to VO
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
TenantVO buildVOByBO(TenantBO entityBO);
|
||||
/**
|
||||
* BO to VO
|
||||
*
|
||||
* @param entityBO EntityBO
|
||||
* @return EntityVO
|
||||
*/
|
||||
TenantVO buildVOByBO(TenantBO entityBO);
|
||||
|
||||
/**
|
||||
* BOList to VOList
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<TenantVO> buildVOListByBOList(List<TenantBO> entityBOList);
|
||||
/**
|
||||
* BOList to VOList
|
||||
*
|
||||
* @param entityBOList EntityBO Array
|
||||
* @return EntityVO Array
|
||||
*/
|
||||
List<TenantVO> buildVOListByBOList(List<TenantBO> entityBOList);
|
||||
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantBO> buildBOPageByDOPage(Page<TenantDO> entityPageDO);
|
||||
/**
|
||||
* DOPage to BOPage
|
||||
*
|
||||
* @param entityPageDO EntityDO Page
|
||||
* @return EntityBO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantBO> buildBOPageByDOPage(Page<TenantDO> entityPageDO);
|
||||
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantVO> buildVOPageByBOPage(Page<TenantBO> entityPageBO);
|
||||
/**
|
||||
* BOPage to VOPage
|
||||
*
|
||||
* @param entityPageBO EntityBO Page
|
||||
* @return EntityVO Page
|
||||
*/
|
||||
@Mapping(target = "orders", ignore = true)
|
||||
@Mapping(target = "countId", ignore = true)
|
||||
@Mapping(target = "maxLimit", ignore = true)
|
||||
@Mapping(target = "searchCount", ignore = true)
|
||||
@Mapping(target = "optimizeCountSql", ignore = true)
|
||||
@Mapping(target = "optimizeJoinOfCountSql", ignore = true)
|
||||
Page<TenantVO> buildVOPageByBOPage(Page<TenantBO> entityPageBO);
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user