### Project Initialization and Development
Source: https://www.ruoyi.plus/frontend/configuration.html
Commands to install dependencies and start the development server.
```bash
pnpm install
```
```bash
pnpm dev
```
--------------------------------
### Start the Frontend Application
Source: https://www.ruoyi.plus/practices
Commands to navigate to the frontend directory, install dependencies, and launch the development server.
```bash
# 进入前端目录
cd plus-ui
# 安装依赖
pnpm install
# 启动开发服务器
pnpm dev
```
--------------------------------
### Install and Run Ollama
Source: https://www.ruoyi.plus/backend/common/langchain4j/model-factory.html
Commands for installing Ollama on Linux/Mac and starting the service.
```bash
curl -fsSL https://ollama.com/install.sh | sh
# 下载模型
ollama pull llama3.2
ollama pull mistral
ollama pull codellama
# 启动服务
ollama serve
```
--------------------------------
### get Usage Examples
Source: https://www.ruoyi.plus/frontend/utils/object.html
Demonstrates usage with dot notation, array indices, and array paths.
```typescript
import { get } from '@/utils/object'
const data = {
users: [
{
name: 'John',
roles: ['admin', 'user'],
address: { city: 'New York' }
},
{
name: 'Jane',
roles: ['user']
}
],
config: {
features: {
darkMode: true
}
}
}
// 点表示法
get(data, 'config.features.darkMode') // true
// 数组索引语法
get(data, 'users[0].name') // 'John'
get(data, 'users[0].roles[0]') // 'admin'
get(data, 'users[1].address.city', 'Unknown') // 'Unknown'
// 数组形式的路径
get(data, ['users', '0', 'name']) // 'John'
get(data, ['config', 'features', 'darkMode']) // true
// 实际应用:安全地渲染数据
const renderUserInfo = (response: any) => {
const userName = get(response, 'data.user.profile.name', '匿名用户')
const avatar = get(response, 'data.user.profile.avatar', '/default-avatar.png')
return `
${userName}
`
}
```
--------------------------------
### Semantic Versioning Examples
Source: https://www.ruoyi.plus/practices/standards/git.html
Examples of pre-release and official version tags.
```bash
v1.0.0-alpha.1 # 第一个内测版本
v1.0.0-beta.1 # 第一个公测版本
v1.0.0-rc.1 # 第一个候选版本
v1.0.0 # 正式版本
```
--------------------------------
### Install project dependencies
Source: https://www.ruoyi.plus/frontend/getting-started.html
Initializes the project environment by installing required packages from the registry.
```bash
# 确保在 plus-ui 目录下
pwd
# 应显示: .../ruoyi-plus-uniapp/plus-ui
# 安装依赖
pnpm install
# 安装完成后会显示类似信息:
# Packages: +XXX
# Progress: resolved XXX, reused XXX, downloaded X, added XXX, done
```
--------------------------------
### Start the Mobile Application
Source: https://www.ruoyi.plus/practices
Commands to install dependencies and launch the mobile development environment for H5 or WeChat Mini Program.
```bash
# 进入移动端目录
cd plus-uniapp
# 安装依赖
pnpm install
# H5 开发
pnpm dev:h5
# 微信小程序开发
pnpm dev:mp-weixin
```
--------------------------------
### Field Configuration Examples
Source: https://www.ruoyi.plus/backend/modules/generator/column-config.html
Examples of how specific fields are configured for different operations.
```text
字段: id
插入: ✗ (主键通常自动生成)
编辑: ✗ (主键不允许修改)
列表: ✓ (显示在列表中)
查询: ✓ (支持按ID查询)
```
```text
字段: username
插入: ✓ (新增时必须填写)
编辑: ✓ (支持修改)
列表: ✓ (显示在列表中)
查询: ✓ (支持按用户名查询)
```
```text
字段: create_time
插入: ✗ (系统自动设置)
编辑: ✗ (不允许修改)
列表: ✓ (显示创建时间)
查询: ✓ (支持时间范围查询)
```
--------------------------------
### Example Backend File Path Configuration
Source: https://www.ruoyi.plus/practices/engineering/code-generator.html
Concrete example of file paths generated for a specific package and class name.
```bash
# 配置: packageName=plus.ruoyi.business.base, className=Ad
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/domain/Ad.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/domain/bo/AdBo.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/domain/vo/AdVo.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/controller/AdController.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/service/IAdService.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/service/impl/AdServiceImpl.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/dao/IAdDao.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/dao/impl/AdDaoImpl.java
ruoyi-modules/ruoyi-business/src/main/java/plus/ruoyi/business/base/mapper/AdMapper.java
ruoyi-modules/ruoyi-business/src/main/resources/mapper/base/AdMapper.xml
```
--------------------------------
### Install RocketMQ via Docker
Source: https://www.ruoyi.plus/backend/common/rocketmq/quick-start.html
Commands to pull the RocketMQ image and start the NameServer and Broker containers.
```bash
# 拉取镜像
docker pull apache/rocketmq:5.1.0
# 启动 NameServer
docker run -d \
--name rmqnamesrv \
-p 9876:9876 \
apache/rocketmq:5.1.0 \
sh mqnamesrv
# 启动 Broker
docker run -d \
--name rmqbroker \
-p 10911:10911 \
-p 10909:10909 \
--link rmqnamesrv:namesrv \
-e "NAMESRV_ADDR=namesrv:9876" \
apache/rocketmq:5.1.0 \
sh mqbroker
```
--------------------------------
### Install Project Dependencies
Source: https://www.ruoyi.plus/mobile/getting-started.html
Standard installation command and troubleshooting steps for clearing cache and lock files.
```bash
# 安装项目依赖
pnpm install
# 如果安装失败,尝试以下步骤
# 1. 清除 pnpm 缓存
pnpm store prune
# 2. 删除已有的 node_modules
rm -rf node_modules
# 3. 删除 lock 文件
rm pnpm-lock.yaml
# 4. 重新安装
pnpm install
```
--------------------------------
### Locate MQTT Usage Examples
Source: https://www.ruoyi.plus/backend/common/mqtt.html
Path to the test class containing comprehensive MQTT implementation examples.
```text
ruoyi-common-mqtt/src/test/java/plus/ruoyi/common/mqtt/MqttClientUsageTest.java
```
--------------------------------
### Install and Initialize Husky
Source: https://www.ruoyi.plus/practices/standards/git.html
Install necessary dependencies and initialize Husky for Git hooks.
```bash
# 安装依赖
pnpm install -D husky lint-staged @commitlint/cli @commitlint/config-conventional
# 初始化 Husky
npx husky init
```
--------------------------------
### Install Testing Dependencies
Source: https://www.ruoyi.plus/frontend/dev/testing.html
Install the necessary testing framework and utility packages via pnpm.
```bash
pnpm add -D vitest @vue/test-utils happy-dom @vitest/ui
```
--------------------------------
### Clone and Install Project Dependencies
Source: https://www.ruoyi.plus/mobile/build/wechat-deploy.html
Download the project repository and install required dependencies.
```bash
git clone https://gitee.com/bkywksj/ruoyi-plus-uniapp-workflow.git
cd ruoyi-plus-uniapp-workflow/plus-app
pnpm install
```
--------------------------------
### useDict Usage Examples
Source: https://www.ruoyi.plus/mobile/composables/use-dict.html
Examples demonstrating basic usage, loading multiple dictionaries, and using string literals.
```typescript
// 基本用法
const { sys_user_sex, dictLoading } = useDict(DictTypes.SYS_USER_SEX)
// 加载多个字典
const {
sys_user_sex,
sys_normal_disable,
sys_yes_no,
dictLoading
} = useDict(
DictTypes.SYS_USER_SEX,
DictTypes.SYS_NORMAL_DISABLE,
DictTypes.SYS_YES_NO
)
// 使用字符串(不推荐)
const { my_custom_dict, dictLoading } = useDict('my_custom_dict')
```
--------------------------------
### Example Basic Table Configuration
Source: https://www.ruoyi.plus/backend/modules/generator/table-management.html
Example values for the basic table information configuration.
```text
表名: demo_user
表描述: 演示用户管理
实体类名称: DemoUser
作者: 抓蛙师
```
--------------------------------
### Vue Component Setup Example
Source: https://www.ruoyi.plus/frontend/architecture/directory-structure.html
Basic setup for a Vue component using the script setup syntax.
```typescript
```
--------------------------------
### Install and Configure pnpm
Source: https://www.ruoyi.plus/mobile/getting-started.html
Global installation of pnpm and registry configuration for faster package downloads.
```bash
# 全局安装 pnpm
npm install -g pnpm
# 验证安装
pnpm -v
# 配置 pnpm 镜像源(可选,加速下载)
pnpm config set registry https://registry.npmmirror.com
```
--------------------------------
### Install Apache Web Server
Source: https://www.ruoyi.plus/mobile/build/h5-deploy.html
Installation commands for Apache on common Linux distributions.
```bash
# Ubuntu/Debian
sudo apt install apache2
# CentOS/RHEL
sudo yum install httpd
```
--------------------------------
### Get Task Assignees Response
Source: https://www.ruoyi.plus/backend/modules/workflow/task.html
Example JSON response for the GET /workflow/task/listTaskAssignees/{taskId} endpoint.
```json
{
"code": 200,
"msg": "操作成功",
"data": [
{
"userId": 5,
"userName": "李四",
"nickName": "部门经理",
"deptName": "技术部"
}
]
}
```
--------------------------------
### Icon Generation Output Example
Source: https://www.ruoyi.plus/frontend/icons/type-generation.html
Example console output when icon files are detected and types are generated.
```text
检测到图标文件变化: src/assets/icons/iconify/preset.json
发现 iconify 图标文件: D:\project\plus-ui\src\assets\icons\iconify\preset.json, 图标数量: 173
图标扫描完成 - iconfont: 644, iconify: 173, 总计: 817
图标类型已生成: src/types/icons.d.ts (817 个图标)
```
--------------------------------
### Start Development Server
Source: https://www.ruoyi.plus/frontend/getting-started.html
Commands to navigate to the project directory and launch the development server.
```bash
# 确保在 plus-ui 目录下
cd plus-ui
# 启动开发服务器
pnpm dev
```
--------------------------------
### Get Task Details Response
Source: https://www.ruoyi.plus/backend/modules/workflow/task.html
Example JSON response for the GET /workflow/task/getTask/{taskId} endpoint.
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 101,
"instanceId": 1,
"definitionId": 100,
"flowCode": "leave_apply",
"flowName": "请假申请",
"version": "1",
"businessId": "1001",
"nodeCode": "manager",
"nodeName": "部门经理",
"nodeType": 1,
"flowStatus": "waiting",
"assigneeIds": "5",
"buttonList": ["back", "file", "copy", "transfer"],
"copyList": [
{"userId": 10, "userName": "王五"}
],
"varList": [],
"nodeRatio": 0,
"applyNode": false,
"createTime": "2024-01-01 10:30:00"
}
}
```
--------------------------------
### Install and Verify Modules
Source: https://www.ruoyi.plus/backend/common/bom.html
Commands to install all modules into the local Maven repository and verify the existence of the artifacts.
```bash
# 安装所有模块到本地仓库
mvn clean install -DskipTests
# 检查本地仓库
ls ~/.m2/repository/plus/ruoyi/
```
--------------------------------
### Start Development Server
Source: https://www.ruoyi.plus/mobile/build/wechat-deploy.html
Run the development build command to compile the project.
```bash
cd ruoyi-plus-uniapp-workflow/plus-app
pnpm dev:mp-weixin
```
--------------------------------
### Form Validation Setup
Source: https://www.ruoyi.plus/frontend/components/form/radio.html
Example of a standard form setup using AFormRadio with Element Plus validation rules.
```vue
```
--------------------------------
### Preview Build Results
Source: https://www.ruoyi.plus/frontend/getting-started.html
Starts a local server to preview the generated production build.
```bash
# 预览构建结果
pnpm preview
# 预览服务器会在本地启动:
# ➜ Local: http://localhost:4173/
# ➜ Network: http://192.168.x.x:4173/
```
--------------------------------
### Identify Dependency Fetch Error
Source: https://www.ruoyi.plus/frontend/getting-started.html
Example of a 404 error encountered during dependency installation.
```text
ERR_PNPM_FETCH_404 GET https://registry.npmjs.org/xxx: Not Found - 404
```
--------------------------------
### RocketMQ Initialization Log
Source: https://www.ruoyi.plus/backend/common/rocketmq/quick-start.html
Example of the console output upon successful RocketMQ client startup.
```text
========================================
🚀 RocketMQ 模块开始初始化
- NameServer: 127.0.0.1:9876
- 集群名称: RuoYiCluster
- Broker地址: 127.0.0.1:10911
- 生产者组: ruoyi-producer-group
- 发送超时: 3000ms
- 自动创建Topic: true
- 消费线程: 20-64
========================================
✅ RocketMQ 客户端启动完成!
========================================
```
--------------------------------
### Get Tree Depth Usage
Source: https://www.ruoyi.plus/frontend/utils/tree.html
Example of calculating tree depth and using it for UI logic.
```typescript
const tree = buildTree(departmentList)
const depth = getTreeDepth(tree)
console.log(`组织架构层级深度: ${depth}`)
// 根据深度调整UI显示
if (depth > 5) {
console.warn('层级过深,考虑优化组织结构')
}
```
--------------------------------
### Get Leaf Nodes Usage
Source: https://www.ruoyi.plus/frontend/utils/tree.html
Example of extracting leaf nodes from a tree and performing operations on them.
```typescript
const tree = buildTree(departmentList)
const leaves = getLeafNodes(tree)
// 获取所有末级部门
console.log('末级部门:', leaves.map(leaf => leaf.name))
// 统计叶子节点数量
console.log('叶子节点数量:', leaves.length)
```
--------------------------------
### Initialize Component Directory and Files
Source: https://www.ruoyi.plus/frontend/dev/custom-component.html
Commands to create the necessary directory and files for a new component in the project structure.
```bash
# 在 components 目录下创建组件
cd src/components
# 创建组件目录(如果需要多个文件)
mkdir AMyComponent
# 创建组件文件
touch AMyComponent/AMyComponent.vue
touch AMyComponent/types.ts
touch AMyComponent/index.ts
```
--------------------------------
### Start the Backend Application
Source: https://www.ruoyi.plus/practices
Commands to clone the repository, initialize the database, configure settings, and run the Spring Boot application.
```bash
# 克隆项目
git clone https://github.com/xxx/ruoyi-plus-uniapp-workflow.git
# 进入项目目录
cd ruoyi-plus-uniapp-workflow
# 执行 SQL 脚本
mysql -u root -p < script/sql/ruoyi.sql
# 修改配置文件
vim ruoyi-admin/src/main/resources/application-dev.yml
# 启动项目
mvn spring-boot:run -pl ruoyi-admin
```
--------------------------------
### Get Token API Definition and Usage
Source: https://www.ruoyi.plus/frontend/composables/use-token.html
Definition of the getToken function and an example of how to use it within a component.
```typescript
const getToken = (): string | null
```
```typescript
import { useToken } from '@/composables/useToken'
const { getToken } = useToken()
// 基本使用
const token = getToken()
console.log('当前Token:', token)
// 返回: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." 或 null
```
--------------------------------
### Initialize Project Dependencies
Source: https://www.ruoyi.plus/frontend/getting-started.html
Commands to configure the registry, clear cache, and install dependencies for the project.
```bash
# 切换到国内镜像源
pnpm config set registry https://registry.npmmirror.com
# 清除缓存
pnpm store prune
# 删除现有依赖
rm -rf node_modules pnpm-lock.yaml
# 重新安装
pnpm install
```
--------------------------------
### Get Workflow Variables Response
Source: https://www.ruoyi.plus/backend/modules/workflow/instance.html
Example response structure for retrieving variables associated with a workflow instance.
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"variableList": [
{"key": "initiator", "value": "1"},
{"key": "initiatorDeptId", "value": "100"},
{"key": "businessId", "value": "1001"},
{"key": "days", "value": 3},
{"key": "leaveType", "value": "annual"}
],
"variable": "{\"initiator\":\"1\",\"initiatorDeptId\":\"100\",...}"
}
}
```
--------------------------------
### Configure Environment Variables
Source: https://www.ruoyi.plus/mobile/getting-started.html
Example configuration for the .env file, including various platform App IDs.
```bash
# 应用标识
VITE_APP_ID=ryplus_uni
# 微信小程序 AppID (必须配置才能运行小程序)
VITE_WECHAT_MINI_APP_ID=your_wechat_appid
# 微信公众号 AppID
VITE_WECHAT_OFFICIAL_APP_ID=your_wechat_h5_appid
# 支付宝小程序 AppID
VITE_ALIPAY_MINI_APP_ID=your_alipay_appid
# 百度小程序 App Key
VITE_BAIDU_MINI_APP_KEY=your_baidu_appkey
# 抖音小程序 AppID
VITE_TOUTIAO_MINI_APP_ID=your_toutiao_appid
```
--------------------------------
### HBuilderX Initial Configuration
Source: https://www.ruoyi.plus/mobile/uniapp/hbuilderx.html
Steps for logging in, installing necessary plugins, and configuring network proxy settings.
```text
1. 登录 DCloud 账号
- 菜单:帮助 -> 登录
- 使用手机号或邮箱注册
2. 配置插件
- 菜单:工具 -> 插件安装
- 安装 uni-app 编译插件
- 安装 App 真机运行插件
3. 配置代理(可选)
- 菜单:工具 -> 设置
- 网络设置 -> HTTP 代理
```
--------------------------------
### Get Current Week Range
Source: https://www.ruoyi.plus/frontend/utils/date.html
Returns the start (Monday) and end (Sunday) dates for the current week.
```typescript
getCurrentWeekRange(): [Date, Date]
```
```typescript
export const getCurrentWeekRange = (): [Date, Date] => {
const now = new Date()
const currentDay = now.getDay() || 7 // 周日是0,转为7
const monday = new Date(now)
monday.setDate(now.getDate() - (currentDay - 1))
monday.setHours(0, 0, 0, 0)
const sunday = new Date(now)
sunday.setDate(now.getDate() + (7 - currentDay))
sunday.setHours(23, 59, 59, 999)
return [monday, sunday]
}
```
```typescript
const [monday, sunday] = getCurrentWeekRange()
console.log(formatDay(monday)) // "2023-01-09" (本周一)
console.log(formatDay(sunday)) // "2023-01-15" (本周日)
// 本周数据统计
const weeklyStats = await api.getStats({
startDate: formatDay(monday),
endDate: formatDay(sunday)
})
```
--------------------------------
### Optimize JVM Parameters for Production
Source: https://www.ruoyi.plus/backend/common/job.html
Recommended JVM startup arguments for production environments, including G1GC settings and heap dump configuration.
```bash
# 生产环境JVM参数建议
JAVA_OPTS="-Xms2g -Xmx2g \
-XX:+UseG1GC \
-XX:MaxGCPauseMillis=200 \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=/logs/heapdump.hprof \
-XX:+PrintGCDetails \
-XX:+PrintGCDateStamps \
-Xloggc:/logs/gc.log"
```
--------------------------------
### Start Monitor Admin via Maven
Source: https://www.ruoyi.plus/backend/extend/monitor-admin.html
Navigates to the monitor admin module directory to prepare for service startup.
```bash
# 进入模块目录
cd ruoyi-extend/ruoyi-monitor-admin
```
--------------------------------
### Configure and Use Vue I18n
Source: https://www.ruoyi.plus/frontend/architecture/tech-stack.html
Setup for Vue I18n initialization and a component example for switching languages dynamically.
```typescript
// src/i18n/index.ts
import { createI18n } from 'vue-i18n'
import zhCn from './locales/zh-cn'
import en from './locales/en'
const i18n = createI18n({
legacy: false,
locale: localStorage.getItem('language') || 'zh-cn',
fallbackLocale: 'zh-cn',
messages: {
'zh-cn': zhCn,
'en': en
}
})
export default i18n
```
```vue
{{ t('common.title') }}
```
--------------------------------
### Get Next Node Information
Source: https://www.ruoyi.plus/backend/modules/workflow/task.html
Request and response examples for calculating the next workflow node based on variables.
```json
{
"taskId": 101,
"variables": {
"amount": 15000
}
}
```
```json
{
"code": 200,
"msg": "操作成功",
"data": [
{
"nodeCode": "gm",
"nodeName": "总经理",
"nodeType": 1,
"permissionFlag": "5,6,7"
}
]
}
```
--------------------------------
### Clone and Initialize Project
Source: https://www.ruoyi.plus/frontend/getting-started.html
Commands to clone the repository and navigate to the project directory.
```bash
git clone https://gitee.com/your-org/ruoyi-plus-uniapp.git
cd ruoyi-plus-uniapp/plus-ui
```
--------------------------------
### Configure Basic Settings
Source: https://www.ruoyi.plus/backend/common/langchain4j/quick-start.html
Minimal configuration example for setting up the DeepSeek model.
```yaml
langchain4j:
```
--------------------------------
### Retrieve Rejectable Nodes API Response
Source: https://www.ruoyi.plus/backend/modules/workflow/task.html
Example JSON response for the GET /workflow/task/listRejectableNodes/{taskId}/{nowNodeCode} endpoint.
```json
{
"code": 200,
"msg": "操作成功",
"data": [
{
"nodeCode": "apply",
"nodeName": "申请人",
"nodeType": 1
},
{
"nodeCode": "leader",
"nodeName": "部门主管",
"nodeType": 1
}
]
}
```
--------------------------------
### Initialize Development Environment
Source: https://www.ruoyi.plus/mobile/build/wechat-deploy.html
Verify Node.js version and install the pnpm package manager.
```bash
# 检查 Node.js 版本(需要 ≥18.0.0)
node -v
# 安装 pnpm(需要 ≥7.30)
npm install -g pnpm
```
--------------------------------
### Get Workflow Definition JSON Response
Source: https://www.ruoyi.plus/backend/modules/workflow/definition.html
Example response structure when retrieving a workflow definition as a JSON string.
```json
{
"code": 200,
"msg": "操作成功",
"data": "{\"flowCode\":\"leave_apply\",\"flowName\":\"请假申请\",...}"
}
```
--------------------------------
### Retrieve Workflow Definition Details
Source: https://www.ruoyi.plus/backend/modules/workflow/definition.html
Example response for a GET request to fetch workflow definition details by ID.
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"flowCode": "leave_apply",
"flowName": "请假申请",
"version": "1",
"isPublish": 1,
"category": "100",
"formPath": "/business/leave/apply",
"formCustom": "Y",
"ext": "{\"autoPass\":true}",
"nodeList": [
{
"nodeCode": "start",
"nodeName": "开始",
"nodeType": 0
},
{
"nodeCode": "apply",
"nodeName": "申请人",
"nodeType": 1,
"permissionFlag": "${initiator}"
},
{
"nodeCode": "manager",
"nodeName": "部门经理",
"nodeType": 1,
"permissionFlag": "role:3"
},
{
"nodeCode": "end",
"nodeName": "结束",
"nodeType": 2
}
],
"skipList": [
{
"nowNodeCode": "start",
"nextNodeCode": "apply"
},
{
"nowNodeCode": "apply",
"nextNodeCode": "manager"
},
{
"nowNodeCode": "manager",
"nextNodeCode": "end"
}
]
}
}
```
--------------------------------
### Integrate Performance Monitoring in Vue Components
Source: https://www.ruoyi.plus/mobile/performance/startup.html
Usage example of the startup performance composable within a Vue setup script.
```vue
```
--------------------------------
### Query Login Logs Example
Source: https://www.ruoyi.plus/backend/modules/system/monitor.html
Demonstrates how to build query criteria and execute a paginated search for login logs.
```java
// 构建查询条件
SysLoginLogBo loginLogBo = new SysLoginLogBo();
loginLogBo.setUserName("admin");
loginLogBo.setStatus("0"); // 成功登录
loginLogBo.setIpaddr("192.168.1.1");
// 分页参数
PageQuery pageQuery = new PageQuery();
pageQuery.setPageNum(1);
pageQuery.setPageSize(10);
// 执行查询
R> result = loginLogController.pageLoginLogs(loginLogBo, pageQuery);
```
--------------------------------
### Usage Example
Source: https://www.ruoyi.plus/frontend/utils/tree.html
Demonstrates initializing the manager, building the tree, and performing operations.
```typescript
// 使用示例
const manager = new IndexedTreeManager()
console.time('indexedBuild')
manager.build(hugeList) // 优化后:~200ms
console.timeEnd('indexedBuild')
console.time('indexedFind')
const node = manager.findById(99999) // O(1): <1ms
console.timeEnd('indexedFind')
// 增量更新
manager.updateNode(99999, { name: '新名称' })
```
--------------------------------
### Implement Few-Shot Learning
Source: https://www.ruoyi.plus/backend/common/langchain4j.html
Construct prompts using predefined examples to guide the model's output format and logic.
```java
@Service
public class SentimentAnalysisService {
public String analyzeSentiment(String text) {
// 构建示例
List examples = List.of(
new PromptUtils.Example("这个产品太棒了,强烈推荐!", "正面"),
new PromptUtils.Example("质量很差,完全不值这个价格", "负面"),
new PromptUtils.Example("还可以吧,没什么特别的", "中性")
);
// 构建少样本提示词
String prompt = PromptUtils.buildFewShotPrompt(
"请判断以下文本的情感倾向(正面/负面/中性)",
examples,
text
);
ChatRequest request = new ChatRequest();
request.setMessage(prompt);
request.setMode(ChatMode.SINGLE);
request.setTemperature(0.1);
return chatService.chat(request).getContent();
}
}
```
--------------------------------
### Development Startup Commands
Source: https://www.ruoyi.plus/mobile/build/environment.html
Commands to initiate development servers for H5, WeChat Mini Program, Alipay Mini Program, and App platforms.
```bash
pnpm dev:h5
pnpm dev:mp-weixin
pnpm dev:mp-alipay
pnpm dev:app
```
--------------------------------
### Implement Batch Query API
Source: https://www.ruoyi.plus/practices/standards/api-design.html
Provides examples for batch querying using both GET (with request parameters) and POST (with request body) methods, with a 100-item limit.
```java
@RestController
@RequestMapping("/api/users")
public class UserController {
/**
* 批量查询用户 - GET 方式
*/
@GetMapping("/batch")
public R> getUsersByIds(
@RequestParam @Size(max = 100, message = "一次最多查询100条") List ids) {
return R.ok(userService.selectUsersByIds(ids));
}
/**
* 批量查询用户 - POST 方式(推荐,URL长度无限制)
*/
@PostMapping("/batch/query")
public R> batchQueryUsers(
@RequestBody @Valid BatchQueryRequest request) {
return R.ok(userService.selectUsersByIds(request.getIds()));
}
}
@Data
public class BatchQueryRequest {
@NotEmpty(message = "ID列表不能为空")
@Size(max = 100, message = "一次最多查询100条")
private List ids;
}
```
--------------------------------
### Configuration Key Naming Examples
Source: https://www.ruoyi.plus/backend/modules/system/config.html
Standardized hierarchical naming conventions for system, business, tenant, and module configurations.
```text
system.account.register-enabled # 注册开关
system.captcha.enabled # 验证码开关
business.order.auto-confirm # 订单自动确认
tenant.theme.primary-color # 租户主题色
```
--------------------------------
### get Function Signature
Source: https://www.ruoyi.plus/frontend/utils/object.html
Defines the TypeScript signature for the get utility.
```typescript
function get(object: any, path: string | string[], defaultValue?: any): any
```
--------------------------------
### Install Dependencies
Source: https://www.ruoyi.plus/frontend/getting-started.html
Install required project dependencies using pnpm.
```bash
pnpm install
```
--------------------------------
### Install and Configure Alibaba Cloud ossutil
Source: https://www.ruoyi.plus/mobile/build/h5-deploy.html
Download, install, and configure the ossutil tool for managing Alibaba Cloud OSS.
```bash
# 下载并安装 ossutil
wget https://gosspublic.alicdn.com/ossutil/1.7.15/ossutil64
chmod 755 ossutil64
# 配置
./ossutil64 config
```
--------------------------------
### 使用 setup 组合式 API 入口
Source: https://www.ruoyi.plus/mobile/components/lifecycle.html
setup 在组件实例创建时执行,适合进行响应式数据初始化、计算属性定义和方法定义。注意此时无法访问 DOM 元素。
```vue
```
--------------------------------
### Start Mini-Program Development Environments
Source: https://www.ruoyi.plus/mobile/getting-started.html
Commands to launch development mode for specific mini-program platforms.
```bash
pnpm dev:mp-baidu
```
```bash
pnpm dev:mp-toutiao
```
```bash
pnpm dev:mp-qq
```
```bash
pnpm dev:mp-jd
```
```bash
pnpm dev:mp-kuaishou
```
```bash
pnpm dev:mp-lark
```
```bash
pnpm dev:mp-xhs
```
```bash
pnpm dev:mp-harmony
```
--------------------------------
### Spacing Usage Example
Source: https://www.ruoyi.plus/mobile/uniapp/app-config.html
Examples of applying spacing variables to layout properties.
```scss
.container {
padding: $uni-spacing-row-base; // 左右10px
margin-top: $uni-spacing-col-lg; // 上方12px
}
.item + .item {
margin-top: $uni-spacing-col-base; // 项目间距8px
}
```
--------------------------------
### Startup Initialization Log
Source: https://www.ruoyi.plus/backend/common/langchain4j/quick-start.html
Expected console output upon successful initialization of the LangChain4j module.
```text
========================================
LangChain4j 模块初始化完成
默认提供商: deepseek
默认模型: deepseek-chat
对话记忆功能: 已启用
对话存储类型: redis
RAG功能: 已禁用
========================================
```
--------------------------------
### Border Radius Usage Example
Source: https://www.ruoyi.plus/mobile/uniapp/app-config.html
Examples of applying border radius variables.
```scss
.button {
border-radius: $uni-border-radius-base; // 按钮圆角
}
.card {
border-radius: $uni-border-radius-lg; // 卡片圆角
}
.avatar {
border-radius: $uni-border-radius-circle; // 圆形头像
}
```
--------------------------------
### Directive Usage Example
Source: https://www.ruoyi.plus/frontend/architecture/directory-structure.html
Example of using a custom permission directive in a template.
```vue
新增
```
--------------------------------
### Build and Package Application
Source: https://www.ruoyi.plus/practices/devops/docker-deploy.html
Commands to navigate to the project directory, package the application with Maven, and build the Docker image.
```bash
# 进入项目目录
cd ruoyi-plus-uniapp-workflow
# Maven 打包
mvn clean package -DskipTests
# 构建镜像
cd ruoyi-admin
docker build -t ryplus_uni_workflow:latest .
```
--------------------------------
### Composable Function Example
Source: https://www.ruoyi.plus/frontend/architecture/directory-structure.html
Example of a composable function for managing dialog state.
```typescript
// src/composables/useDialog.ts
import { ref } from 'vue'
export const useDialog = () => {
const dialogVisible = ref(false)
const dialogTitle = ref('')
const dialogData = ref(null)
const openDialog = (title: string, data?: any) => {
dialogVisible.value = true
dialogTitle.value = title
dialogData.value = data
}
const closeDialog = () => {
dialogVisible.value = false
dialogData.value = null
}
return {
dialogVisible,
dialogTitle,
dialogData,
openDialog,
closeDialog
}
}
```
--------------------------------
### Configure Menu Permissions via SQL
Source: https://www.ruoyi.plus/practices/features/permission-control.html
SQL examples for inserting directory, menu, and button-level permissions into the sys_menu table.
```sql
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, menu_type, visible, status, perms, icon)
VALUES ('系统管理', 0, 1, 'system', NULL, 'M', '0', '0', '', 'system');
```
```sql
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, menu_type, visible, status, perms, icon)
VALUES ('用户管理', 1, 1, 'user', 'system/user/index', 'C', '0', '0', 'system:user:query', 'user');
```
```sql
-- 用户新增按钮
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, perms)
VALUES ('用户新增', 100, 1, 'F', 'system:user:add');
-- 用户修改按钮
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, perms)
VALUES ('用户修改', 100, 2, 'F', 'system:user:edit');
-- 用户删除按钮
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, perms)
VALUES ('用户删除', 100, 3, 'F', 'system:user:delete');
```
--------------------------------
### Asset Usage Example
Source: https://www.ruoyi.plus/frontend/architecture/directory-structure.html
Example of referencing an image asset in a Vue template.
```vue
```
--------------------------------
### Example Generation Information Configuration
Source: https://www.ruoyi.plus/backend/modules/generator/table-management.html
Example values for the generation information configuration.
```text
生成包路径: plus.ruoyi.business.demo
生成模块名: demo
生成业务名: demoUser
生成功能名: 演示用户
模板类型: 单表(增删改查)
```
--------------------------------
### Create and Populate Demo Table
Source: https://www.ruoyi.plus/backend/modules/generator/quick-start.html
SQL script to create a demo_user table and insert initial test data.
```sql
-- 创建测试表
CREATE TABLE `demo_user` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
`username` varchar(50) NOT NULL COMMENT '用户名',
`nickname` varchar(100) DEFAULT NULL COMMENT '昵称',
`email` varchar(100) DEFAULT NULL COMMENT '邮箱',
`phone` varchar(20) DEFAULT NULL COMMENT '手机号',
`gender` char(1) DEFAULT '0' COMMENT '性别(0男 1女 2未知)',
`status` char(1) DEFAULT '1' COMMENT '状态(0停用 1正常)',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_dept` bigint DEFAULT NULL COMMENT '创建部门',
`create_by` bigint DEFAULT NULL COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` bigint DEFAULT NULL COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`is_deleted` char(1) DEFAULT '0' COMMENT '删除标识',
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='演示用户表';
-- 插入测试数据
INSERT INTO `demo_user` (`username`, `nickname`, `email`, `phone`, `gender`, `status`, `remark`, `create_time`) VALUES
('admin', '管理员', 'admin@example.com', '13800138000', '1', '1', '系统管理员', NOW()),
('user01', '张三', 'zhangsan@example.com', '13800138001', '0', '1', '普通用户', NOW()),
('user02', '李四', 'lisi@example.com', '13800138002', '1', '1', '普通用户', NOW());
```
--------------------------------
### Configure IDEA Docker Run Configuration
Source: https://www.ruoyi.plus/practices/devops/docker-deploy.html
Example settings for running the container directly from IntelliJ IDEA.
```text
Name: ryplus_uni_workflow Docker
Image tag: ryplus_uni_workflow:dev
Container name: ryplus_workflow_dev
Bind ports: 5500:8080, 5005:5005
Environment variables:
- SPRING_PROFILES_ACTIVE=dev
- DEBUG_ARGS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
Bind mounts:
- /opt/ryplus/logs:/ruoyi/server/logs
```
--------------------------------
### GET /api/users/batch
Source: https://www.ruoyi.plus/practices/standards/api-design.html
Retrieves a list of users by their IDs using a GET request.
```APIDOC
## GET /api/users/batch
### Description
Retrieves a list of users based on the provided list of IDs.
### Method
GET
### Endpoint
/api/users/batch
### Parameters
#### Query Parameters
- **ids** (List) - Required - List of user IDs to query (max 100).
```
--------------------------------
### 在组件 Setup 中调用 Store
Source: https://www.ruoyi.plus/frontend/types/store-types.html
确保在组件 setup 函数内部调用 Store,避免在模块顶层调用导致 Pinia 未初始化的问题。
```typescript
// ✅ 正确:在 setup 函数内部调用
export default defineComponent({
setup() {
const userStore = useUserStore()
onMounted(() => {
userStore.fetchUserInfo()
})
return { userStore }
}
})
// ❌ 错误:在模块顶层调用(Pinia 可能还未注册)
const userStore = useUserStore()
export default defineComponent({
setup() {
onMounted(() => {
userStore.fetchUserInfo()
})
}
})
```
--------------------------------
### Configure Multiple Environments
Source: https://www.ruoyi.plus/mobile/configuration.html
Setup for environment-specific variables and build scripts.
```bash
# 创建测试环境配置
# env/.env.test
VITE_APP_ENV='test'
VITE_APP_BASE_API='https://test-api.example.com'
# package.json 添加命令
{
"scripts": {
"build:h5:test": "uni build --mode test",
"build:mp-weixin:test": "uni build -p mp-weixin --mode test"
}
}
```
--------------------------------
### BaseUnitTest 使用 setUp 和 tearDown
Source: https://www.ruoyi.plus/backend/common/test/base-classes.html
通过重写 setUp 和 tearDown 方法在测试方法执行前后进行资源准备和清理。
```java
@DisplayName("数据处理测试")
class DataProcessorTest extends BaseUnitTest {
private DataProcessor processor;
private List testData;
@Override
protected void setUp() {
// 每个测试方法执行前调用
processor = new DataProcessor();
testData = Arrays.asList("data1", "data2", "data3");
System.out.println("测试数据准备完成");
}
@Override
protected void tearDown() {
// 每个测试方法执行后调用
processor = null;
testData = null;
System.out.println("测试数据清理完成");
}
@Test
void testProcess() {
List result = processor.process(testData);
assertThat(result).hasSize(3);
}
}
```
--------------------------------
### UniApp Article Template Example
Source: https://www.ruoyi.plus/mobile/styles/overview.html
Example usage of article-specific classes in a Vue template.
```vue
文章标题
副标题
文章内容段落文字...
```
--------------------------------
### Cache Key Format Example
Source: https://www.ruoyi.plus/backend/common/sms.html
Illustrates the final structure of cache keys after applying the global prefix.
```text
global:sms:xxx # 短信相关缓存
global:captcha:xxx # 验证码缓存
```
--------------------------------
### API Implementation Example
Source: https://www.ruoyi.plus/frontend/architecture/directory-structure.html
Example of defining API functions and types for a system module.
```typescript
// src/api/system/core/user/userApi.ts
import request from '@/utils/request'
import type { UserVo, UserQuery, UserForm } from './userTypes'
/** 查询用户列表 */
export const listUser = (query: UserQuery): Result> => {
return request({
url: '/system/user/list',
method: 'get',
params: query
})
}
/** 获取用户详情 */
export const getUser = (userId: number): Result => {
return request({
url: `/system/user/${userId}`,
method: 'get'
})
}
/** 新增用户 */
export const addUser = (data: UserForm): Result => {
return request({
url: '/system/user',
method: 'post',
data
})
}
```
--------------------------------
### Configure WeChat Mini-Program and Payment
Source: https://www.ruoyi.plus/backend/modules/business/base.html
Example of creating platform configuration and payment information records.
```java
// 1. 创建平台配置
PlatformBo platformBo = new PlatformBo();
platformBo.setType("mp-weixin");
platformBo.setName("我的小程序");
platformBo.setAppid("wx1234567890");
platformBo.setSecret("your-secret");
platformBo.setStatus("1");
platformService.add(platformBo);
// 2. 配置支付信息
PaymentBo paymentBo = new PaymentBo();
paymentBo.setType("wechat");
paymentBo.setMchName("我的商户");
paymentBo.setMchId("1234567890");
paymentBo.setMchKey("your-mch-key");
paymentBo.setStatus("1");
paymentService.add(paymentBo);
```
--------------------------------
### Usage Example for initFeatures
Source: https://www.ruoyi.plus/mobile/stores/feature.html
Shows how to trigger the initialization and verify the state.
```typescript
const featureStore = useFeatureStore()
// 初始化
await featureStore.initFeatures()
// 检查初始化状态
if (featureStore.initialized) {
console.log('功能配置:', featureStore.features)
}
```
--------------------------------
### Basic manifest.json Configuration
Source: https://www.ruoyi.plus/mobile/uniapp/hbuilderx.html
Example of the base configuration required in the manifest.json file.
```json
{
"name": "RuoYi-Plus",
"appid": "__UNI__XXXXXXX",
"description": "RuoYi-Plus 移动端",
"versionName": "1.0.0",
"versionCode": 100,
"transformPx": false,
"locale": "zh-Hans"
}
```