406 lines
18 KiB
Markdown
406 lines
18 KiB
Markdown
# sisvietnamvn
|
|
|
|
This application was generated using JHipster 9.1.0, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v9.1.0](https://www.jhipster.tech/documentation-archive/v9.1.0).
|
|
|
|
## Project Structure
|
|
|
|
Node is required for generation and recommended for development. `package.json` is always generated for a better development experience with prettier, commit hooks, scripts and so on.
|
|
|
|
In the project root, JHipster generates configuration files for tools like git, prettier, eslint, husky, and others that are well known and you can find references in the web.
|
|
|
|
`/src/*` structure follows default Java structure.
|
|
|
|
- `.yo-rc.json` - Yeoman configuration file
|
|
JHipster configuration is stored in this file at `generator-jhipster` key. You may find `generator-jhipster-*` for specific blueprints configuration.
|
|
- `.yo-resolve` (optional) - Yeoman conflict resolver
|
|
Allows to use a specific action when conflicts are found skipping prompts for files that matches a pattern. Each line should match `[pattern] [action]` with pattern been a [Minimatch](https://github.com/isaacs/minimatch#minimatch) pattern and action been one of skip (default if omitted) or force. Lines starting with `#` are considered comments and are ignored.
|
|
- `.jhipster/*.json` - JHipster entity configuration files
|
|
- `/src/main/docker` - Docker configurations for the application and services that the application depends on
|
|
|
|
## Database Configuration
|
|
|
|
### Development Database (H2 Console)
|
|
- **Profile**: `dev`
|
|
- **Database Type**: H2 (File-based, embedded)
|
|
- **JDBC URL**: `jdbc:h2:file:./build/h2db/db/sisvietnamvn`
|
|
- **Username**: `sisvietnamvn`
|
|
- **Password**: *(leave blank)*
|
|
- **Console Access**: [http://localhost:8080/h2-console](http://localhost:8080/h2-console) (requires app running in dev profile)
|
|
- **Config File**: [application-dev.yml](file:///d:/website_sisvietnam_moi/website_sisvietnam.vn/sisvietnamvn/src/main/resources/config/application-dev.yml)
|
|
|
|
### Production Database
|
|
- **Profile**: `prod`
|
|
- **Database Type**: Oracle Database
|
|
- **JDBC URL**: `jdbc:oracle:thin:@localhost:1521:xe`
|
|
- **Username**: `sisvietnamvn`
|
|
- **Config File**: [application-prod.yml](file:///d:/website_sisvietnam_moi/website_sisvietnam.vn/sisvietnamvn/src/main/resources/config/application-prod.yml)
|
|
|
|
### Schema Management
|
|
- **Tool**: Liquibase
|
|
- **Changelog Folder**: [src/main/resources/config/liquibase/](file:///d:/website_sisvietnam_moi/website_sisvietnam.vn/sisvietnamvn/src/main/resources/config/liquibase/)
|
|
|
|
## Development
|
|
|
|
To start your application in the dev profile, run:
|
|
|
|
```bash
|
|
./gradlew
|
|
```
|
|
|
|
For further instructions on how to develop with JHipster, have a look at [Using JHipster in development][].
|
|
|
|
## Building for production
|
|
|
|
### Packaging as jar
|
|
|
|
To build the final jar and optimize the sisvietnamvn application for production, run:
|
|
|
|
```bash
|
|
./gradlew -Pprod clean bootJar
|
|
```
|
|
|
|
To ensure everything worked, run:
|
|
|
|
```bash
|
|
java -jar build/libs/*.jar
|
|
```
|
|
|
|
Refer to [Using JHipster in production][] for more details.
|
|
|
|
### Packaging as war
|
|
|
|
To package your application as a war in order to deploy it to an application server, run:
|
|
|
|
```bash
|
|
./gradlew -Pprod -Pwar clean bootWar
|
|
```
|
|
|
|
### JHipster Control Center
|
|
|
|
JHipster Control Center can help you manage and control your application(s). You can start a local control center server (accessible on http://localhost:7419) with:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/jhipster-control-center.yml up
|
|
```
|
|
|
|
## Testing
|
|
|
|
### Spring Boot tests
|
|
|
|
To launch your application's tests, run:
|
|
|
|
```bash
|
|
./gradlew test integrationTest jacocoTestReport
|
|
```
|
|
|
|
## Others
|
|
|
|
### Code quality using Sonar
|
|
|
|
Sonar is used to analyse code quality. You can start a local Sonar server (accessible on http://localhost:9001) with:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/sonar.yml up -d
|
|
```
|
|
|
|
Note: we have turned off forced authentication redirect for UI in [src/main/docker/sonar.yml](src/main/docker/sonar.yml) for out of the box experience while trying out SonarQube, for real use cases turn it back on.
|
|
|
|
You can run a Sonar analysis with using the [sonar-scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner) or by using the gradle plugin.
|
|
|
|
Then, run a Sonar analysis:
|
|
|
|
```bash
|
|
./gradlew -Pprod clean check jacocoTestReport sonarqube -Dsonar.login=admin -Dsonar.password=admin
|
|
```
|
|
|
|
Additionally, Instead of passing `sonar.password` and `sonar.login` as CLI arguments, these parameters can be configured from [sonar-project.properties](sonar-project.properties) as shown below:
|
|
|
|
```bash
|
|
sonar.login=admin
|
|
sonar.password=admin
|
|
```
|
|
|
|
For more information, refer to the [Code quality page][].
|
|
|
|
### Docker Compose support
|
|
|
|
JHipster generates a number of Docker Compose configuration files in the [src/main/docker/](src/main/docker/) folder to launch required third party services.
|
|
|
|
For example, to start required services in Docker containers, run:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/services.yml up -d
|
|
```
|
|
|
|
To stop and remove the containers, run:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/services.yml down
|
|
```
|
|
|
|
[Spring Docker Compose Integration](https://docs.spring.io/spring-boot/reference/features/dev-services.html) is enabled by default. It's possible to disable it in `application.yml`:
|
|
|
|
```yaml
|
|
spring:
|
|
...
|
|
docker:
|
|
compose:
|
|
enabled: false
|
|
```
|
|
|
|
You can also fully dockerize your application and all the services that it depends on.
|
|
To achieve this, first build a Docker image of your app by running:
|
|
|
|
```bash
|
|
npm run java:docker
|
|
```
|
|
|
|
Or build an arm64 Docker image when using an arm64 processor OS, i.e., Apple Silicon chips (M\*), running:
|
|
|
|
```bash
|
|
npm run java:docker:arm64
|
|
```
|
|
|
|
Then run:
|
|
|
|
```bash
|
|
docker compose -f src/main/docker/app.yml up -d
|
|
```
|
|
|
|
For more information refer to [Docker and Docker-Compose](https://www.jhipster.tech/documentation-archive/v9.1.0/docker-compose/), this page also contains information on the Docker Compose sub-generator (`jhipster docker-compose`), which is able to generate Docker configurations for one or several JHipster applications.
|
|
|
|
## Continuous Integration (optional)
|
|
|
|
To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration](https://www.jhipster.tech/documentation-archive/v9.1.0/setting-up-ci/) page for more information.
|
|
|
|
## References
|
|
|
|
- [JHipster Homepage and latest documentation](https://www.jhipster.tech/)
|
|
- [JHipster 9.1.0 archive](https://www.jhipster.tech/documentation-archive/v9.1.0)
|
|
- [Using JHipster in development](https://www.jhipster.tech/documentation-archive/v9.1.0/development/)
|
|
- [Using Docker and Docker-Compose](https://www.jhipster.tech/documentation-archive/v9.1.0/docker-compose)
|
|
- [Using JHipster in production](https://www.jhipster.tech/documentation-archive/v9.1.0/production/)
|
|
- [Running tests page](https://www.jhipster.tech/documentation-archive/v9.1.0/running-tests/)
|
|
- [Code quality page](https://www.jhipster.tech/documentation-archive/v9.1.0/code-quality/)
|
|
- [Setting up Continuous Integration](https://www.jhipster.tech/documentation-archive/v9.1.0/setting-up-ci/)
|
|
- [Node.js](https://nodejs.org/)
|
|
- [NPM](https://www.npmjs.com/)
|
|
|
|
## Deployment Guide (Ubuntu server + aaPanel + Executable JAR)
|
|
|
|
### 1. Build the JAR file (on Windows)
|
|
Spring Boot applications come with a built-in web server, meaning you can package your entire application into a single executable `.jar` file!
|
|
Run the following command on your Windows PC to build the production-ready `.jar` file:
|
|
```powershell
|
|
./gradlew -Pprod clean bootJar
|
|
```
|
|
Alternatively, you can use the built-in npm script:
|
|
```powershell
|
|
npm run java:jar:prod
|
|
```
|
|
The generated `.jar` file will be located at `build/libs/sisvietnamvn-1.0.3.jar`.
|
|
|
|
### 2. Deploy and Run the application (on Ubuntu Server)
|
|
|
|
You have two main options to run the application on Ubuntu: using **aaPanel** or using standard **systemd**.
|
|
|
|
#### Option A: Using aaPanel (Recommended)
|
|
If you are using aaPanel, it is highly recommended to use its built-in **Java Project** manager to easily run the JAR file.
|
|
|
|
1. **Install Java 21**: Make sure Java 21 is installed on your Ubuntu server via aaPanel.
|
|
2. **Upload the JAR**: Upload the `sisvietnamvn-1.0.3.jar` file to a folder on your server (e.g., `/www/wwwroot/sisvietnam.vn/`).
|
|
3. **Add Java Project**: In aaPanel, go to **Website** -> **Java Project** -> **Add Java project**.
|
|
4. **Configure Project**:
|
|
- **Project Type**: `Spring_boot`
|
|
- **Project jar**: Select the `sisvietnamvn-1.0.3.jar` file you just uploaded.
|
|
- **Project Port**: `8080` (or whichever port your app is configured to use).
|
|
- **Run user**: `www` (or `root`)
|
|
- Click **Submit**. aaPanel will automatically run your JAR file in the background!
|
|
|
|
#### Option B: Using systemd (Standard Ubuntu)
|
|
If you prefer managing the server manually via terminal, you can register the JAR as a `systemd` service so it runs continuously in the background and starts automatically on boot.
|
|
|
|
1. **Upload the JAR**: Upload the `sisvietnamvn-1.0.3.jar` file to your server (e.g., `/var/www/sisvietnam/sisvietnamvn.jar`).
|
|
2. **Create the Service File**:
|
|
```bash
|
|
sudo nano /etc/systemd/system/sisvietnam.service
|
|
```
|
|
3. **Add Configuration**: Paste the following, making sure the `ExecStart` path matches where you put the jar.
|
|
```ini
|
|
[Unit]
|
|
Description=SIS Vietnam Spring Boot Application
|
|
After=syslog.target network.target
|
|
|
|
[Service]
|
|
User=root
|
|
ExecStart=/usr/bin/java -jar /var/www/sisvietnam/sisvietnamvn.jar
|
|
SuccessExitStatus=143
|
|
Restart=always
|
|
RestartSec=10
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
4. **Start the Service**: Run the following commands to reload systemd, enable the service to start on boot, and start it now:
|
|
```bash
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable sisvietnam.service
|
|
sudo systemctl start sisvietnam.service
|
|
```
|
|
5. **Check Status & Logs**:
|
|
- To check if it's running: `sudo systemctl status sisvietnam.service`
|
|
- To view the live terminal output: `sudo journalctl -u sisvietnam.service -f`
|
|
|
|
### 3. Configure NGINX Reverse Proxy (aaPanel)
|
|
When you set up a Java Project in aaPanel, it can automatically map your domain and set up a reverse proxy. If you need to verify or set it up manually:
|
|
|
|
1. **Add Site**: Go to aaPanel -> Website -> Add site. Enter your domain (e.g., `sisvietnam.vn`) and select **Static** for the PHP version.
|
|
2. **Setup Reverse Proxy**: Click "Settings" for the site -> "Reverse proxy" -> "Add reverse proxy".
|
|
- **Proxy name**: `JavaProxy`
|
|
- **Target URL**: `http://127.0.0.1:8080`
|
|
- **Sent Domain**: `$host`
|
|
3. **Spring Boot Proxy Trust**: Ensure Spring Boot knows it is behind a proxy so it can read client IPs correctly. In `src/main/resources/config/application-prod.yml`, verify this exists:
|
|
```yaml
|
|
server:
|
|
forward-headers-strategy: framework
|
|
```
|
|
4. **SSL**: Use aaPanel's built-in SSL manager to apply Let's Encrypt certificates to your NGINX site. You don't need to configure SSL inside Spring Boot itself.
|
|
|
|
|
|
debug mode
|
|
|
|
.\gradlew.bat bootRun --debug-jvm
|
|
## Troubleshooting: Oracle DB ORA-01017 during Development
|
|
If you encounter an `ORA-01017: invalid credential or not authorized` error when starting the application using `bootRun`, ensure the following steps have been taken:
|
|
|
|
### 1. Database & User Creation (Oracle 23ai Free)
|
|
You need to create a dedicated Pluggable Database (PDB) and a user inside the Oracle Docker container.
|
|
1. Connect to your LXC container host (e.g. `192.168.1.15`).
|
|
2. Open a `sqlplus` session inside the Oracle container:
|
|
```bash
|
|
docker exec -it sisvietnam-oracle-sisvietnam-oracle-1 sqlplus sys/Oracle123 as sysdba
|
|
```
|
|
3. Run the following SQL to create the PDB and User:
|
|
```sql
|
|
CREATE PLUGGABLE DATABASE sisvietnam ADMIN USER pdbadmin IDENTIFIED BY Oracle123 FILE_NAME_CONVERT = ('/opt/oracle/oradata/FREE/pdbseed/', '/opt/oracle/oradata/FREE/sisvietnam/');
|
|
ALTER PLUGGABLE DATABASE sisvietnam OPEN;
|
|
ALTER PLUGGABLE DATABASE sisvietnam SAVE STATE;
|
|
ALTER SESSION SET CONTAINER = sisvietnam;
|
|
CREATE USER sisvietnam IDENTIFIED BY "sisvietnam";
|
|
GRANT DBA TO sisvietnam;
|
|
GRANT ALL PRIVILEGES TO sisvietnam;
|
|
```
|
|
|
|
### 2. Configure Spring Boot
|
|
Update your `application-dev.yml` to point to the newly created `sisvietnam` PDB:
|
|
```yaml
|
|
spring:
|
|
datasource:
|
|
url: jdbc:oracle:thin:@192.168.1.15:1521/sisvietnam
|
|
username: sisvietnam
|
|
password: "sisvietnam"
|
|
```
|
|
|
|
### 3. Check for Overriding Profiles (Important!)
|
|
By default, the JHipster setup might enable the `secret-samples` profile. This profile aggressively overrides the database username and blanks out the password. Check `src/main/resources/config/application-secret-samples.yml`. If you encounter an `ORA-01017`, ensure that the `dev` section in the `secret-samples` profile correctly mirrors your real credentials:
|
|
```yaml
|
|
spring:
|
|
config:
|
|
activate:
|
|
on-profile: dev
|
|
datasource:
|
|
username: sisvietnam
|
|
password: sisvietnam
|
|
```
|
|
|
|
## Admin Pages & Block Editor Management
|
|
|
|
We have implemented a WordPress-like static pages management feature at `/manage/pages`. This includes an interactive block-based editor powered by **Editor.js**.
|
|
|
|
### 1. How to Run and Access
|
|
1. Start your Oracle database or ensure it is accessible.
|
|
2. Run the application in development mode:
|
|
```powershell
|
|
./gradlew bootRun
|
|
```
|
|
3. Open your browser and navigate to the Page Management dashboard: [http://localhost:8080/manage/pages](http://localhost:8080/manage/pages)
|
|
4. Navigate to the Posts Management dashboards:
|
|
- **All Posts**: [http://localhost:8080/manage/posts](http://localhost:8080/manage/posts)
|
|
- **Categories**: [http://localhost:8080/manage/categories](http://localhost:8080/manage/categories)
|
|
- **Tags**: [http://localhost:8080/manage/tags](http://localhost:8080/manage/tags)
|
|
|
|
### 2. Form Fields & Features
|
|
When creating or editing a page (`/manage/pages/new` or `/manage/pages/{id}/edit`):
|
|
- **Title**: Name of the page (e.g. `About Us`, `Giới thiệu`).
|
|
- **Slug**: The URL path. If left blank, it is automatically generated from the Title, supporting clean Vietnamese character conversions (e.g. `Bệnh viện S.I.S Cần Thơ` -> `benh-vien-s-i-s-can-tho`).
|
|
- **Status**: Status of the page (`DRAFT`, `PUBLISHED`, `ARCHIVED`).
|
|
- **Display Order**: Controls sorting of page links (lower numbers appear first).
|
|
- **Meta Description**: A short summary used for SEO metadata in `<meta name="description">`.
|
|
- **Page Content (Block Editor)**: Interactive wysiwyg editor utilizing Editor.js.
|
|
|
|
### 3. Using the Block Editor
|
|
- **Add a Block**: Press `Enter` to create a new paragraph, or click the `+` icon (or press `Tab` on an empty line) to pick a block type:
|
|
- **Heading**: Formatted HTML headers (H2, H3, H4).
|
|
- **List**: Bulleted or numbered lists (supports nested lists via `Tab`).
|
|
- **Quote**: Stylized blockquotes with a caption field.
|
|
- **Table**: Simple tables with columns and rows.
|
|
- **Code**: Formatted code block.
|
|
- **Warning**: Notice or alert box with title & message.
|
|
- **Delimiter**: Horizontal dividers.
|
|
- **Inline Styling**: Highlight any text in a paragraph to apply **Bold**, *Italic*, Links, Underlines, `Inline Code`, or Highlighter.
|
|
- **Reorder & Actions**: Hover over any block and use the handle menu (`⋮⋮`) to drag-and-drop, move up/down, convert to another block type, or delete.
|
|
|
|
### 4. How the Plugin System Works (Extensibility)
|
|
If you want to create new custom block types (e.g., custom slider, doctor list, video embed) in the future:
|
|
1. Create your plugin script file inside `src/main/resources/static/js/manage/editor-plugins/` (e.g. `video-embed-plugin.js`).
|
|
2. Implement your custom block class or wrap an existing Editor.js tool.
|
|
3. Register your tool globally by adding it to `window.SISEditorPlugins`:
|
|
```javascript
|
|
window.SISEditorPlugins = window.SISEditorPlugins || {};
|
|
window.SISEditorPlugins['videoEmbed'] = {
|
|
class: VideoEmbedToolClass,
|
|
inlineToolbar: true,
|
|
config: {
|
|
placeholder: 'Enter video URL...'
|
|
}
|
|
};
|
|
```
|
|
4. In `src/main/resources/templates/manage/pages/form.html`, load the script in the `<section layout:fragment="scripts">` tag **before** the main configuration script:
|
|
```html
|
|
<script th:src="@{/js/manage/editor-plugins/video-embed-plugin.js}"></script>
|
|
```
|
|
5. The initialization logic in [editor-config.js](file:///c:/Users/laptop01/Documents/sisvietnamvn_01/sisvietnamvn_main/src/main/resources/static/js/manage/editor-config.js) will automatically scan `window.SISEditorPlugins` and register them.
|
|
|
|
## User Management & Profiles
|
|
|
|
We have implemented a comprehensive User Management system in the Admin Dashboard, located under the **Users** menu. This allows administrators to manage all registered accounts on the platform.
|
|
|
|
### 1. How to Run and Access
|
|
1. Start your Oracle database or ensure it is accessible.
|
|
2. Run the application in development mode:
|
|
```powershell
|
|
./gradlew bootRun
|
|
```
|
|
3. Log in with an Administrator account (e.g., `admin`).
|
|
4. In the left sidebar, locate the **Users** menu to access the user management tools:
|
|
- **All Users**: `http://localhost:8080/manage/users`
|
|
- **Add New**: `http://localhost:8080/manage/users/new`
|
|
|
|
### 2. Managing Users (Admin Only)
|
|
- **All Users List**: Displays a table of all registered users with their `Login`, `Email`, `Status` (Activated/Deactivated), `Language`, `Profiles` (Roles such as `ROLE_ADMIN`, `ROLE_USER`), and `Created Date`.
|
|
- **Add New User**:
|
|
- Fill in the required fields: `Login`, `Email`.
|
|
- Optionally set `First Name`, `Last Name`, and `Language`.
|
|
- Assign Roles by checking the corresponding profile boxes.
|
|
- Set the user as **Activated** (if they are ready to log in).
|
|
- *Note: New users are created with a randomly generated password and a reset key. They must use the "Forgot your password?" flow to set their initial password before they can log in.*
|
|
- **Edit User**: Click the blue Edit icon next to any user in the list to modify their email, name, language, active status, or roles. Note that the `Login` cannot be changed after creation.
|
|
- **Delete User**: Click the red Trash icon to permanently remove a user. A confirmation modal will prevent accidental deletions.
|
|
|
|
### 3. User Profiles (All Authenticated Users)
|
|
Every logged-in user (regardless of role) can manage their personal profile by clicking their username in the top right corner and selecting **Profile**, or navigating to `http://localhost:8080/manage/profile`.
|
|
|
|
The Profile page contains two sections:
|
|
- **Personal Information**: Users can update their Email, First Name, Last Name, and Display Language.
|
|
- **Change Password**: Users can securely change their password by providing their current password, a new password, and confirming the new password.
|