### Clone and Run RuoYi-Vue3 Frontend Source: https://github.com/yangzongzhuan/ruoyi-vue3/blob/master/README.md Instructions to clone the RuoYi-Vue3 project from GitHub, install dependencies using yarn, and start the development server. It also includes commands for building for staging and production environments. ```bash # 克隆项目 git clone https://github.com/yangzongzhuan/RuoYi-Vue3.git # 进入项目目录 cd RuoYi-Vue3 # 安装依赖 yarn --registry=https://registry.npmmirror.com # 启动服务 yarn dev # 构建测试环境 yarn build:stage # 构建生产环境 yarn build:prod # 前端访问地址 http://localhost:80 ``` -------------------------------- ### Pinia Global State Management with User Store in Vue.js Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Demonstrates how to use Pinia for global state management in a Vue.js application, specifically managing user information, permissions, and login status. It includes examples for handling user login, fetching user details, and logging out. This snippet relies on the `@/store/modules/user` module. ```javascript import useUserStore from '@/store/modules/user' // 在组件中使用 const userStore = useUserStore() // 用户登录 const handleLogin = async () => { await userStore.login({ username: 'admin', password: 'admin123', code: '1234', uuid: 'captcha-uuid' }) // 登录成功后自动设置 token } // 获取用户信息 const getUserInfo = async () => { await userStore.getInfo() console.log('用户ID:', userStore.id) console.log('用户名:', userStore.name) console.log('昵称:', userStore.nickName) console.log('头像:', userStore.avatar) console.log('角色:', userStore.roles) console.log('权限:', userStore.permissions) } // 退出登录 const handleLogout = async () => { await userStore.logOut() // 自动清除 token 和用户信息 } ``` -------------------------------- ### Manage System Parameters (JavaScript) Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Handles dynamic system parameter configuration. Allows fetching, adding, updating, and deleting parameters using their keys or IDs. Includes a function to refresh the parameter cache. Dependencies are from '@/api/system/config'. ```javascript import { listConfig, getConfig, getConfigKey, addConfig, updateConfig, delConfig, refreshCache } from '@/api/system/config' // 查询参数列表 const fetchConfigs = async () => { const res = await listConfig({ pageNum: 1, pageSize: 10, configName: '', configKey: '', configType: '' }) console.log('参数列表:', res.rows) // 响应: { rows: [{ configId, configName, configKey, configValue, configType, remark }], total: 5 } } // 获取参数详情 const config = await getConfig(1) // 根据参数键名获取参数值(常用) const sideTheme = await getConfigKey('sys.index.sideTheme') // 响应: { msg: "theme-dark" } // 新增参数 await addConfig({ configName: '系统主题', configKey: 'sys.index.sideTheme', configValue: 'theme-dark', configType: 'Y', // Y系统内置 N非内置 remark: '侧边栏主题配置' }) // 修改参数 await updateConfig({ configId: 1, configValue: 'theme-light' }) // 删除参数 await delConfig('1,2') // 刷新参数缓存 await refreshCache() ``` -------------------------------- ### Parameter Configuration API Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Manages system dynamic parameter configurations, allowing retrieval of configuration values by parameter key name. ```APIDOC ## Parameter Configuration API ### Description Management interface for system dynamic parameter configuration, supporting retrieval of configuration values by parameter key name. ### Method GET, POST, PUT, DELETE ### Endpoint /system/config ### Parameters #### Query Parameters - **pageNum** (integer) - Required - Current page number - **pageSize** (integer) - Required - Number of items per page - **configName** (string) - Optional - Parameter name - **configKey** (string) - Optional - Parameter key - **configType** (string) - Optional - Parameter type (Y: system, N: custom) - **configId** (integer) - Required for update/delete - Parameter ID #### Request Body - **configName** (string) - Required for add/update - Parameter name - **configKey** (string) - Required for add/update - Parameter key - **configValue** (string) - Required for add/update - Parameter value - **configType** (string) - Optional for add/update - Parameter type (Y: system, N: custom) - **remark** (string) - Optional for add/update - Remarks ### Request Example ```json // Add parameter { "configName": "System Theme", "configKey": "sys.index.sideTheme", "configValue": "theme-dark", "configType": "Y", "remark": "Sidebar theme configuration" } ``` ### Response #### Success Response (200) - **rows** (array) - List of parameters - **total** (integer) - Total number of items - **configId** (integer) - Parameter ID - **configName** (string) - Parameter name - **configKey** (string) - Parameter key - **configValue** (string) - Parameter value - **configType** (string) - Parameter type - **remark** (string) - Remarks #### Response Example ```json // Parameter list { "rows": [ { "configId": 1, "configName": "System Theme", "configKey": "sys.index.sideTheme", "configValue": "theme-dark", "configType": "Y", "remark": "Sidebar theme configuration" } ], "total": 1 } // Get parameter by key { "msg": "theme-dark" } ``` ``` -------------------------------- ### Login and Authentication API (JavaScript) Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Handles user login, registration, logout, and fetching user information. It supports CAPTCHA verification and JWT token authentication. Dependencies include the API client functions like `login`, `getInfo`, etc. ```javascript import { login, register, logout, getInfo, getCodeImg } from '@/api/login' // 用户登录 const loginUser = async () => { try { // 获取验证码 const captcha = await getCodeImg() console.log('验证码UUID:', captcha.uuid) console.log('验证码图片:', captcha.img) // Base64格式 // 执行登录 const res = await login('admin', 'admin123', 'captchaCode', captcha.uuid) console.log('登录成功,Token:', res.token) // 响应: { code: 200, token: "eyJhbGciOiJIUzUxMiJ9..." } } catch (error) { console.error('登录失败:', error) } } // 获取用户信息 const fetchUserInfo = async () => { const res = await getInfo() console.log('用户信息:', res.user) console.log('角色列表:', res.roles) // ["admin", "common"] console.log('权限列表:', res.permissions) // ["*:*:*"] 或 ["system:user:list"] } // 用户注册 const registerUser = async () => { const data = { username: 'newuser', password: '123456', confirmPassword: '123456' } await register(data) } // 退出登录 const logoutUser = async () => { await logout() } ``` ```bash # 获取验证码 curl -X GET "http://localhost:8080/captchaImage" # 用户登录 curl -X POST "http://localhost:8080/login" \ -H "Content-Type: application/json" \ -d '{"username":"admin","password":"admin123","code":"1234","uuid":"xxx-xxx"}' # 获取用户信息 (需要Token) curl -X GET "http://localhost:8080/getInfo" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9..." ``` -------------------------------- ### Manage System Notifications (JavaScript) Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt API for managing system notifications and announcements. Supports listing, retrieving, creating, updating, and deleting notices. Each notice has a title, type, content, and status. Dependencies are from '@/api/system/notice'. ```javascript import { listNotice, getNotice, addNotice, updateNotice, delNotice } from '@/api/system/notice' // 查询公告列表 const fetchNotices = async () => { const res = await listNotice({ pageNum: 1, pageSize: 10, noticeTitle: '', noticeType: '', createBy: '' }) console.log('公告列表:', res.rows) // 响应: { rows: [{ noticeId, noticeTitle, noticeType, noticeContent, status, createBy, createTime }], total: 10 } } // 获取公告详情 const notice = await getNotice(1) // 新增公告 await addNotice({ noticeTitle: '系统升级通知', noticeType: '1', // 1通知 2公告 noticeContent: '

系统将于今晚进行升级维护...

', status: '0' // 0正常 1关闭 }) // 修改公告 await updateNotice({ noticeId: 1, noticeTitle: '紧急:系统升级通知' }) // 删除公告 await delNotice('1,2') ``` -------------------------------- ### Login and Authentication API Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Provides endpoints for user login, registration, logout, and retrieving user information. Supports captcha verification and JWT token authentication. ```APIDOC ## Login and Authentication API ### Description Provides endpoints for user login, registration, logout, and retrieving user information. Supports captcha verification and JWT token authentication. ### Method POST, GET ### Endpoints - `/captchaImage` (GET) - `/login` (POST) - `/getInfo` (GET) - `/logout` (POST) ### Parameters #### Query Parameters (for GET requests) - **uuid** (string) - Required - The unique identifier for the captcha image. #### Request Body (for POST requests) - **username** (string) - Required - The user's username. - **password** (string) - Required - The user's password. - **code** (string) - Required - The captcha code entered by the user. - **uuid** (string) - Required - The unique identifier for the captcha image. ### Request Example ```json { "username": "admin", "password": "admin123", "code": "1234", "uuid": "xxx-xxx" } ``` ### Response #### Success Response (200) - **code** (integer) - The status code, 200 for success. - **token** (string) - The JWT token for authenticated requests (on login). - **user** (object) - User details (on getInfo). - **roles** (array) - List of user roles (on getInfo). - **permissions** (array) - List of user permissions (on getInfo). #### Response Example ```json { "code": 200, "token": "eyJhbGciOiJIUzUxMiJ9..." } ``` #### Error Response (400, 401, etc.) - **code** (integer) - The status code for the error. - **msg** (string) - A message describing the error. ``` -------------------------------- ### Role Management API Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt APIs for creating, reading, updating, deleting, setting data permissions, and managing user authorization for roles. ```APIDOC ## Role Management API ### Description APIs for creating, reading, updating, deleting, setting data permissions, and managing user authorization for roles. ### Method GET, POST, PUT, DELETE ### Endpoints - `/system/role` (List Roles) - `/system/role/{roleId}` (Get Role Details, Update Role, Delete Role) - `/system/role/changeStatus` (Change Role Status) - `/system/role/dataScope` (Set Data Scope) - `/system/role/authUser/allocatedList` (List Allocated Users) - `/system/role/authUser/unallocatedList` (List Unallocated Users) - `/system/role/authUser/cancel` (Cancel User Authorization) - `/system/role/authUser/cancelAll` (Batch Cancel User Authorization) - `/system/role/authUser/selectAll` (Batch Authorize Users) - `/system/role/deptTreeSelect/{roleId}` (Get Department Tree for Role) ### Parameters #### Query Parameters (for listRole) - **pageNum** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. - **roleName** (string) - Optional - Filter by role name. - **roleKey** (string) - Optional - Filter by role key. - **status** (string) - Optional - Filter by role status ('0' for enabled, '1' for disabled). #### Path Parameters - **roleId** (integer) - Required - The ID of the role. - **userId** (integer) - Required - The ID of the user. #### Request Body (for addRole) - **roleName** (string) - Required - The name of the role. - **roleKey** (string) - Required - The key identifier for the role. - **roleSort** (integer) - Required - The sort order of the role. - **status** (string) - Required - The status of the role ('0' for enabled, '1' for disabled). - **menuIds** (array of integers) - Optional - List of menu IDs to assign to the role. - **menuCheckStrictly** (boolean) - Optional - Whether menu permissions are strictly checked. - **deptCheckStrictly** (boolean) - Optional - Whether department permissions are strictly checked. - **remark** (string) - Optional - A description for the role. #### Request Body (for updateRole) - **roleId** (integer) - Required - The ID of the role to update. - **roleName** (string) - Optional - The new name for the role. - **roleKey** (string) - Optional - The new key identifier for the role. - **roleSort** (integer) - Optional - The new sort order for the role. - **status** (string) - Optional - The new status for the role. - **menuIds** (array of integers) - Optional - List of menu IDs to assign to the role. - **menuCheckStrictly** (boolean) - Optional - Whether menu permissions are strictly checked. - **deptCheckStrictly** (boolean) - Optional - Whether department permissions are strictly checked. - **remark** (string) - Optional - A description for the role. #### Request Body (for changeRoleStatus) - **roleId** (integer) - Required - The ID of the role. - **status** (string) - Required - The new status ('0' for enabled, '1' for disabled). #### Request Body (for dataScope) - **roleId** (integer) - Required - The ID of the role. - **dataScope** (string) - Required - The data scope ('1' all, '2' custom, '3' this department, '4' this department and below, '5' only self). - **deptIds** (array of integers) - Optional - List of department IDs for custom data scope. #### Request Body (for authUserCancelAll, authUserSelectAll) - **roleId** (integer) - Required - The ID of the role. - **userIds** (string) - Required - Comma-separated string of user IDs. ### Request Example (Create Role) ```json { "roleName": "Common Role", "roleKey": "common", "roleSort": 2, "status": "0", "menuIds": [1, 100, 101, 102], "menuCheckStrictly": true, "deptCheckStrictly": true, "remark": "Common role permissions" } ``` ### Response #### Success Response (200) - **rows** (array) - List of roles (for listRole). - **total** (integer) - Total number of roles (for listRole). - **roleId** (integer) - Role ID (for getRole). - **roleName** (string) - Role name. - **roleKey** (string) - Role key. - **roleSort** (integer) - Role sort order. - **dataScope** (string) - Data scope. - **status** (string) - Role status. - **deptTree** (array) - Department tree structure (for deptTreeSelect). #### Response Example (List Roles) ```json { "rows": [ { "roleId": 1, "roleName": "Administrator", "roleKey": "admin", "roleSort": 1, "dataScope": "1", "status": "0", "remark": "Administrator role" } ], "total": 1 } ``` ``` -------------------------------- ### Manage System Dictionaries (JavaScript) Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Provides API endpoints for managing system dictionary types and data. Supports CRUD operations for dictionary types and data, fetching dictionary options, and refreshing cache. Dependencies include '@/api/system/dict/type' and '@/api/system/dict/data'. ```javascript import { listType, getType, addType, updateType, delType, refreshCache, optionselect } from '@/api/system/dict/type' import { listData, getData, getDicts, addData, updateData, delData } from '@/api/system/dict/data' // 查询字典类型列表 const fetchDictTypes = async () => { const res = await listType({ pageNum: 1, pageSize: 10, dictName: '', dictType: '', status: '' }) console.log('字典类型:', res.rows) // 响应: { rows: [{ dictId, dictName, dictType, status, remark }], total: 10 } } // 新增字典类型 await addType({ dictName: '用户性别', dictType: 'sys_user_sex', status: '0', remark: '用户性别列表' }) // 修改字典类型 await updateType({ dictId: 1, dictName: '系统用户性别' }) // 删除字典类型 await delType('1,2') // 刷新字典缓存 await refreshCache() // 获取字典选择框列表 const dictOptions = await optionselect() // 查询字典数据列表 const fetchDictData = async () => { const res = await listData({ pageNum: 1, pageSize: 10, dictType: 'sys_user_sex' }) console.log('字典数据:', res.rows) } // 根据字典类型获取字典数据(常用) const sexOptions = await getDicts('sys_user_sex') // 响应: [{ dictCode: 1, dictValue: '0', dictLabel: '男' }, { dictCode: 2, dictValue: '1', dictLabel: '女' }] // 新增字典数据 await addData({ dictType: 'sys_user_sex', dictLabel: '未知', dictValue: '2', dictSort: 3, status: '0' }) // 修改字典数据 await updateData({ dictCode: 1, dictLabel: '男性' }) // 删除字典数据 await delData('1,2') ``` -------------------------------- ### Notice Announcement API Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Handles the publishing and management of system notices and announcements. ```APIDOC ## Notice Announcement API ### Description Interfaces for publishing and managing system notices and announcements. ### Method GET, POST, PUT, DELETE ### Endpoint /system/notice ### Parameters #### Query Parameters - **pageNum** (integer) - Required - Current page number - **pageSize** (integer) - Required - Number of items per page - **noticeTitle** (string) - Optional - Notice title - **noticeType** (string) - Optional - Notice type (1: Notice, 2: Announcement) - **createBy** (string) - Optional - Creator - **noticeId** (integer) - Required for update/delete - Notice ID #### Request Body - **noticeTitle** (string) - Required for add/update - Notice title - **noticeType** (string) - Required for add/update - Notice type (1: Notice, 2: Announcement) - **noticeContent** (string) - Required for add/update - Notice content - **status** (string) - Optional for add/update - Status (0: normal, 1: disabled) ### Request Example ```json // Add notice { "noticeTitle": "System Upgrade Notice", "noticeType": "1", "noticeContent": "

The system will undergo upgrade maintenance tonight...

", "status": "0" } ``` ### Response #### Success Response (200) - **rows** (array) - List of notices - **total** (integer) - Total number of items - **noticeId** (integer) - Notice ID - **noticeTitle** (string) - Notice title - **noticeType** (string) - Notice type - **noticeContent** (string) - Notice content - **status** (string) - Status - **createBy** (string) - Creator - **createTime** (string) - Creation time #### Response Example ```json // Notice list { "rows": [ { "noticeId": 1, "noticeTitle": "System Upgrade Notice", "noticeType": "1", "noticeContent": "

The system will undergo upgrade maintenance tonight...

", "status": "0", "createBy": "admin", "createTime": "2023-10-27T10:00:00Z" } ], "total": 1 } ``` ``` -------------------------------- ### Post Management API Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt APIs for managing job positions within the system, including creating, reading, updating, and deleting posts. ```APIDOC ## Post Management API ### Description APIs for managing job positions within the system, including creating, reading, updating, and deleting posts. ### Method GET, POST, PUT, DELETE ### Endpoints - `/system/post` (List Posts) - `/system/post/{postId}` (Get Post Details, Update Post, Delete Post) ### Parameters #### Query Parameters (for listPost) - **pageNum** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. - **postCode** (string) - Optional - Filter by post code. - **postName** (string) - Optional - Filter by post name. - **status** (string) - Optional - Filter by post status ('0' for enabled, '1' for disabled). #### Path Parameters - **postId** (integer) - Required - The ID of the post. #### Request Body (for addPost, updatePost) - **postId** (integer) - Optional (for addPost) / Required (for updatePost) - The ID of the post. - **postCode** (string) - Required - The code for the post. - **postName** (string) - Required - The name of the post. - **postSort** (integer) - Required - The sort order of the post. - **status** (string) - Optional - Post status ('0' for enabled, '1' for disabled). - **remark** (string) - Optional - A description for the post. ### Request Example (Add Post) ```json { "postCode": "ceo", "postName": "CEO", "postSort": 1, "status": "0", "remark": "Chief Executive Officer" } ``` ### Response #### Success Response (200) - **rows** (array) - List of posts. - **total** (integer) - Total number of posts. - **postId** (integer) - Post ID. - **postCode** (string) - Post code. - **postName** (string) - Post name. - **postSort** (integer) - Post sort order. - **status** (string) - Post status. - **remark** (string) - Post remark. #### Response Example (List Posts) ```json { "rows": [ { "postId": 1, "postCode": "ceo", "postName": "CEO", "postSort": 1, "status": "0", "remark": "Chief Executive Officer" } ], "total": 1 } ``` ``` -------------------------------- ### Menu Management API Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt APIs for managing system menus, including creating, reading, updating, deleting, and retrieving menu tree structures. Supports directory, menu, and button types. ```APIDOC ## Menu Management API ### Description APIs for managing system menus, including creating, reading, updating, deleting, and retrieving menu tree structures. Supports directory, menu, and button types. ### Method GET, POST, PUT, DELETE ### Endpoints - `/system/menu` (List Menus) - `/system/menu/{menuId}` (Get Menu Details, Update Menu, Delete Menu) - `/system/menu/treeselect` (Get Menu Tree Select) - `/system/menu/roleMenuTreeselect/{roleId}` (Get Role Menu Tree Select) ### Parameters #### Query Parameters (for listMenu) - **menuName** (string) - Optional - Filter by menu name. - **status** (string) - Optional - Filter by menu status ('0' for enabled, '1' for disabled). #### Path Parameters - **menuId** (integer) - Required - The ID of the menu. - **roleId** (integer) - Required - The ID of the role. #### Request Body (for addMenu, updateMenu) - **menuId** (integer) - Optional (for addMenu) / Required (for updateMenu) - The ID of the menu. - **parentId** (integer) - Required - The parent menu ID (0 for root). - **menuName** (string) - Required - The name of the menu. - **orderNum** (integer) - Required - The order number of the menu. - **path** (string) - Optional - The route path for the menu. - **component** (string) - Optional - The component path for the menu. - **menuType** (string) - Required - Type of menu ('M' for directory, 'C' for menu, 'F' for button). - **visible** (string) - Optional - Visibility status ('0' for visible, '1' for hidden). - **status** (string) - Optional - Menu status ('0' for enabled, '1' for disabled). - **perms** (string) - Optional - Permissions string for the menu. - **icon** (string) - Optional - Icon for the menu. ### Request Example (Add Menu) ```json { "menuName": "User Management", "parentId": 1, "orderNum": 1, "path": "user", "component": "system/user/index", "menuType": "C", "visible": "0", "status": "0", "perms": "system:user:list", "icon": "user" } ``` ### Response #### Success Response (200) - **data** (array) - List of menus (for listMenu). - **menuId** (integer) - Menu ID. - **menuName** (string) - Menu name. - **parentId** (integer) - Parent menu ID. - **orderNum** (integer) - Order number. - **path** (string) - Route path. - **component** (string) - Component path. - **menuType** (string) - Menu type. - **visible** (string) - Visibility status. - **status** (string) - Menu status. - **perms** (string) - Permissions string. - **icon** (string) - Icon. - **children** (array) - Nested children menus (for treeselect and roleMenuTreeselect). - **id** (integer) - ID for tree select components. - **label** (string) - Label for tree select components. - **checkedKeys** (array) - Checked keys for role menu tree select. #### Response Example (Menu Tree Select) ```json [ { "id": 1, "label": "System Management", "children": [ { "id": 100, "label": "User Management", "children": [] } ] } ] ``` ``` -------------------------------- ### Manage Menus API (JavaScript) Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Handles system menu management, including CRUD operations and retrieving menu tree structures. Supports directory, menu, and button types. Interacts with the '@/api/system/menu' module. ```javascript import { listMenu, getMenu, addMenu, updateMenu, delMenu, treeselect, roleMenuTreeselect } from '@/api/system/menu' // 查询菜单列表 const fetchMenus = async () => { const query = { menuName: '', status: '' } const res = await listMenu(query) console.log('菜单列表:', res.data) // 响应: [{ menuId, menuName, parentId, orderNum, path, component, menuType, visible, status, perms, icon, ... }] } // 获取菜单详情 const menu = await getMenu(100) // 新增菜单 const createMenu = async () => { // 新增目录 await addMenu({ menuName: '系统管理', parentId: 0, orderNum: 1, path: 'system', menuType: 'M', // M目录 C菜单 F按钮 visible: '0', // 0显示 1隐藏 status: '0', icon: 'system' }) // 新增菜单 await addMenu({ menuName: '用户管理', parentId: 1, orderNum: 1, path: 'user', component: 'system/user/index', menuType: 'C', visible: '0', status: '0', perms: 'system:user:list', icon: 'user' }) // 新增按钮 await addMenu({ menuName: '用户新增', parentId: 100, orderNum: 2, menuType: 'F', perms: 'system:user:add' }) } // 修改菜单 await updateMenu({ menuId: 100, menuName: '用户管理(修改)' }) // 删除菜单 await delMenu(100) // 获取菜单下拉树 const menuTree = await treeselect() // 响应: [{ id: 1, label: '系统管理', children: [...] }] // 获取角色对应的菜单树 const roleMenuTree = await roleMenuTreeselect(2) // 响应: { menus: [...], checkedKeys: [100, 101, 102] } ``` -------------------------------- ### Cache Monitoring API - JavaScript Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Provides interfaces for querying and managing system cache information, with support for viewing and clearing Redis caches. It includes functions to fetch cache statistics, list cache names and keys, retrieve specific cache values, and clear caches by name, key, or entirely. ```javascript import { getCache, listCacheName, listCacheKey, getCacheValue, clearCacheName, clearCacheKey, clearCacheAll } from '@/api/monitor/cache' // 获取缓存监控信息 const fetchCacheInfo = async () => { const res = await getCache() console.log('Redis信息:', res.data.info) console.log('命令统计:', res.data.commandStats) console.log('内存使用:', res.data.dbSize) } // 获取缓存名称列表 const cacheNames = await listCacheName() // 响应: [{ cacheName: 'sys_config', remark: '配置缓存' }, ...] // 获取指定缓存的键名列表 const cacheKeys = await listCacheKey('sys_config') // 响应: ['sys.index.sideTheme', 'sys.user.initPassword', ...] // 获取缓存内容 const cacheValue = await getCacheValue('sys_config', 'sys.index.sideTheme') // 响应: { cacheName: 'sys_config', cacheKey: 'sys.index.sideTheme', cacheValue: 'theme-dark' } // 清理指定名称的缓存 await clearCacheName('sys_config') // 清理指定键名的缓存 await clearCacheKey('sys_config:sys.index.sideTheme') // 清理全部缓存 await clearCacheAll() ``` -------------------------------- ### Server Monitoring API - JavaScript Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Fetches real-time operational status information for the server, including CPU, memory, disk, and JVM details. This API is essential for monitoring the health and performance of the underlying infrastructure. ```javascript import { getServer } from '@/api/monitor/server' // 获取服务器信息 const fetchServerInfo = async () => { const res = await getServer() console.log('CPU信息:', res.data.cpu) // { cpuNum: 8, used: 15.5, sys: 5.2, free: 79.3 } console.log('内存信息:', res.data.mem) // { total: 16.0, used: 8.5, free: 7.5, usage: 53.1 } console.log('JVM信息:', res.data.jvm) // { total: 512, max: 1024, free: 256, used: 256, usage: 50.0, name: 'Java HotSpot(TM)', version: '1.8.0', home: '/usr/lib/jvm/java-8' } console.log('磁盘信息:', res.data.sysFiles) // [{ dirName: '/', sysTypeName: 'Linux', typeName: 'ext4', total: '500GB', free: '300GB', used: '200GB', usage: 40.0 }] console.log('系统信息:', res.data.sys) // { computerName: 'server01', computerIp: '192.168.1.1', osName: 'Linux', osArch: 'amd64' } } ``` -------------------------------- ### Manage Posts API (JavaScript) Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Offers API functions for managing user posts (job positions) within the system, including CRUD operations. It utilizes the '@/api/system/post' module. ```javascript import { listPost, getPost, addPost, updatePost, delPost } from '@/api/system/post' // 查询岗位列表 const fetchPosts = async () => { const res = await listPost({ pageNum: 1, pageSize: 10, postCode: '', postName: '', status: '' }) console.log('岗位列表:', res.rows) // 响应: { rows: [{ postId, postCode, postName, postSort, status, remark }], total: 5 } } // 获取岗位详情 const post = await getPost(1) // 新增岗位 await addPost({ postCode: 'ceo', postName: '董事长', postSort: 1, status: '0', remark: '公司最高领导' }) // 修改岗位 await updatePost({ postId: 1, postName: '首席执行官' }) // 删除岗位 await delPost('1,2') ``` -------------------------------- ### Code Generation API - JavaScript Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt A tool interface for automatically generating front-end and back-end CRUD code based on database table structures. It supports listing tables, importing tables, creating tables from SQL, previewing generated code, updating generation configurations, and synchronizing database schema changes. ```javascript import { listTable, listDbTable, getGenTable, updateGenTable, importTable, createTable, previewTable, delTable, genCode, synchDb } from '@/api/tool/gen' // 查询已导入的表列表 const fetchTables = async () => { const res = await listTable({ pageNum: 1, pageSize: 10, tableName: '', tableComment: '' }) console.log('代码生成表:', res.rows) } // 查询数据库表列表(未导入的) const fetchDbTables = async () => { const res = await listDbTable({ pageNum: 1, pageSize: 10, tableName: '' }) console.log('数据库表:', res.rows) } // 获取表详细信息(包含列信息) const tableInfo = await getGenTable(1) // 响应: { info: { tableId, tableName, ... }, rows: [{ columnId, columnName, ... }] } // 导入表 await importTable({ tables: 'sys_user,sys_role' }) // 创建表(通过SQL语句) await createTable({ sql: 'CREATE TABLE test_table (id INT PRIMARY KEY, name VARCHAR(50))' }) // 预览生成代码 const preview = await previewTable(1) // 响应: { "domain/User.java": "...", "mapper/UserMapper.xml": "...", "vue/index.vue": "..." } // 修改代码生成配置 await updateGenTable({ tableId: 1, tableName: 'sys_user', tableComment: '用户表', className: 'SysUser', packageName: 'com.ruoyi.system', moduleName: 'system', businessName: 'user', functionName: '用户管理', tplCategory: 'crud', genType: '0', genPath: '/' }) // 生成代码(自定义路径) await genCode('sys_user') // 同步数据库(更新表结构变更) await synchDb('sys_user') // 删除表 await delTable('1,2') ``` -------------------------------- ### User Management API Source: https://context7.com/yangzongzhuan/ruoyi-vue3/llms.txt Manages system users, including creating, reading, updating, deleting, resetting passwords, changing status, and uploading avatars. ```APIDOC ## User Management API ### Description Manages system users, including creating, reading, updating, deleting, resetting passwords, changing status, and uploading avatars. Also includes profile management and department tree retrieval. ### Method GET, POST, PUT, DELETE ### Endpoints - `/system/user/list` (GET) - `/system/user/{userId}` (GET) - `/system/user` (POST) - `/system/user` (PUT) - `/system/user/{userId}` (DELETE) - `/system/user/resetPwd` (PUT) - `/system/user/changeStatus` (PUT) - `/system/user/profile` (GET) - `/system/user/profile` (PUT) - `/system/user/updatePwd` (PUT) - `/system/user/avatar` (POST) - `/system/dept/tree` (GET) ### Parameters #### Path Parameters - **userId** (integer) - Required - The ID of the user. #### Query Parameters - **pageNum** (integer) - Optional - The current page number for pagination. - **pageSize** (integer) - Optional - The number of items per page. - **userName** (string) - Optional - Filter by username. - **phonenumber** (string) - Optional - Filter by phone number. - **status** (string) - Optional - Filter by user status ('0' for normal, '1' for disabled). - **deptId** (integer) - Optional - Filter by department ID. - **beginTime** (string) - Optional - Start date for time-based filtering (YYYY-MM-DD). - **endTime** (string) - Optional - End date for time-based filtering (YYYY-MM-DD). #### Request Body - **User Object (POST/PUT)**: - **userId** (integer) - Required (for PUT) - The ID of the user. - **userName** (string) - Required - The user's username. - **nickName** (string) - Required - The user's nickname. - **password** (string) - Required (for POST) - The user's password. - **phonenumber** (string) - Optional - The user's phone number. - **email** (string) - Optional - The user's email address. - **sex** (string) - Optional - User's sex ('0' for male, '1' for female, '2' for unknown). - **status** (string) - Optional - User status ('0' for normal, '1' for disabled). - **deptId** (integer) - Optional - The ID of the department the user belongs to. - **postIds** (array of integers) - Optional - Array of post IDs. - **roleIds** (array of integers) - Optional - Array of role IDs. - **remark** (string) - Optional - Remarks for the user. - **Reset Password Object (PUT `/system/user/resetPwd`)**: - **userId** (integer) - Required - The ID of the user. - **password** (string) - Required - The new password. - **Change Status Object (PUT `/system/user/changeStatus`)**: - **userId** (integer) - Required - The ID of the user. - **status** (string) - Required - The new status ('0' or '1'). - **Profile Update Object (PUT `/system/user/profile`)**: - **nickName** (string) - Required - The updated nickname. - **phonenumber** (string) - Optional - The updated phone number. - **email** (string) - Optional - The updated email address. - **Update Password Object (PUT `/system/user/updatePwd`)**: - **oldPassword** (string) - Required - The user's current password. - **newPassword** (string) - Required - The new password. - **Avatar Upload (POST `/system/user/avatar`)**: - **avatarfile** (file) - Required - The avatar file to upload. ### Request Example ```json { "userName": "test", "nickName": "测试", "password": "123456", "deptId": 100 } ``` ### Response #### Success Response (200) - **rows** (array) - List of user objects (on list). - **total** (integer) - Total number of records (on list). - **data** (object) - User details (on get). - **roles** (array) - List of roles associated with the user (on get). - **posts** (array) - List of posts associated with the user (on get). - **user** (object) - User profile details (on getProfile). - **deptTree** (array) - Department tree structure (on deptTreeSelect). #### Response Example ```json { "rows": [ { "userId": 1, "userName": "admin", "nickName": "管理员", "email": "admin@ruoyi.vip", "phonenumber": "15888888888", "status": "0", "deptId": 100, "createTime": "2023-01-01T10:00:00Z" } ], "total": 10 } ``` #### Error Response (400, 401, 404, etc.) - **code** (integer) - The status code for the error. - **msg** (string) - A message describing the error. ```