### Install lv-framework using Go Get
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/pkg/lv_framework/README.MD
Command to install the lv-framework dependency into your Go project.
```bash
go get github.com/lostvip-com/lv-framework
```
--------------------------------
### Start HTTP Server
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Initializes configuration and logging, sets the Gin mode, and starts the HTTP server. Listens for exit signals.
```go
package main
import (
"github.com/gin-gonic/gin"
"github.com/lostvip-com/lv_framework/lv_global"
"github.com/lostvip-com/lv_framework/lv_log"
"github.com/lostvip-com/lv_framework/web/server"
"common/myconf"
)
func main() {
// 初始化配置和日志
cfg := myconf.GetConfigInstance()
log := lv_log_impl.InitLog(cfg.GetAppName() + ".log")
lv_log.Log = log
// 设置运行模式
if lv_global.IsDebug {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
// 启动 HTTP 服务
go server.NewHttpServer().ListenAndServe()
// 监听退出信号
// ... 信号处理逻辑
}
// 启动后访问地址: http://127.0.0.1:8080
// 默认账号密码: admin / admin123
```
--------------------------------
### Install gRPC compilation tools
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/pkg/lv_grpc_driver_proto/README.md
Install the required protoc-gen-go and protoc-gen-go-grpc plugins using the go install command.
```bash
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
```
--------------------------------
### Get Configuration List API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves a paginated list of system configuration parameters.
```bash
curl -X POST http://localhost:8080/system/config/list \
-H "Cookie: token=your_token_here" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "pageNum=1&pageSize=10&configName=&configKey=&configType=Y"
```
--------------------------------
### Environment Variable Configuration in YAML
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/README.MD
Demonstrates how to use expressions in YAML to fetch values from environment variables, facilitating environment-specific parameter switching. Example shows default value fallback.
```yaml
host: ${REDIS_HOST:lostvip.com}
如: 环境变量添加 REDIS_HOST=192.168.88.114;REDIS_PORT=6379;REDIS_PWD=dpctest
```
--------------------------------
### Hot Reloading with Fresh
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/README.MD
Utilizes the `fresh` tool for live reloading during development. Requires installation of the `fresh` framework.
```bash
go get github.com/pilu/fresh
go install github.com/pilu/fresh
fresh
```
--------------------------------
### GET /monitor/server/
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves server monitoring information including CPU, memory, and disk usage.
```APIDOC
## GET /monitor/server/
### Description
Retrieves server status information including CPU, memory, JVM, and disk usage.
### Method
GET
### Endpoint
/monitor/server/
### Response
#### Success Response (200)
- Returns a page or JSON object containing server metrics (CPU, Memory, JVM, Disk, System Info).
```
--------------------------------
### GET /tool/gen/execSqlFile
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Executes the generated SQL file to create menus and buttons.
```APIDOC
## GET /tool/gen/execSqlFile
### Description
Executes the generated SQL file to create menus and buttons.
### Method
GET
### Endpoint
/tool/gen/execSqlFile
### Parameters
#### Query Parameters
- **tableId** (int) - Required - Table ID
### Response
#### Success Response (200)
- **code** (int) - Status code
```
--------------------------------
### Get Menu List API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Fetches the list of system menus based on optional filters.
```bash
curl -X POST http://localhost:8080/system/menu/list \
-H "Cookie: token=your_token_here" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "menuName=&status=0"
```
--------------------------------
### Peity Line Chart Example
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/report/peity.html
Implement line charts by using a span with the class 'line' and providing numerical data. Customization options for fill and stroke colors are available.
```html
5,3,9,6,5,9,7,3,5,2
```
```html
5,3,9,6,5,9,7,3,5,2
```
```html
5,3,2,-1,-3,-2,2,3,5,2
```
```html
0,-3,-6,-4,-5,-4,-7,-3,-5,-2
```
--------------------------------
### Standard Go Application Startup
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/README.MD
This command initiates the Go application using the standard `go run` command. Ensure GO_PROXY environment variable is set.
```bash
go run main.go
```
--------------------------------
### Open Prompt Layer with Nested Prompts
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/modal/layer.html
Demonstrates using layer.prompt() to get user input. This example shows a nested prompt, where the second prompt appears only after the first is answered. It handles different form types for input.
```javascript
$("#button-open-9").click(function(){
layer.prompt({
title: '输入任何口令,并确认',
formType: 1
}, function(pass, index){
layer.close(index);
layer.prompt({
title: '随便写点啥,并确认',
formType: 2
}, function(text, index){
layer.close(index);
layer.msg('演示完毕!您的口令:'+ pass +'
您最后写下了:'+text);
});
});
})
```
--------------------------------
### Bootstrap-datetimepicker: Start Date with End Date Constraint
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/form/datetime.html
Configures a start date picker. It defaults to the current date and sets the start date for the end date picker to prevent selecting dates before the start date.
```javascript
$("#datetimepicker-startTime").datetimepicker({
format: 'yyyy-mm-dd',
minView: "month",
todayBtn: true,
autoclose: true,
endDate : new Date(),
}).on('changeDate', function(event) {
event.preventDefault();
event.stopPropagation();
var startTime = event.date;
$('#datetimepicker-endTime').datetimepicker('setStartDate', startTime);
});
```
--------------------------------
### YAML Configuration with Environment Variables
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/pkg/lv_framework/README.MD
Demonstrates how to use expressions in YAML to fetch values from environment variables, useful for managing different environment configurations.
```yaml
host: ${REDIS_HOST:lostvip.com}
如: 环境变量添加 REDIS_HOST=192.168.88.114;REDIS_PORT=6379;REDIS_PWD=dpctest
```
--------------------------------
### Laydate: End Date with Start Date Constraint
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/form/datetime.html
Configures a Laydate end date picker. It sets the minimum selectable date based on the value of the start date input and applies a 'molv' theme. The 'done' callback ensures the start date picker's maximum date is updated when the end date changes.
```javascript
var endDate = laydate.render({
elem: '#laydate-endTime',
min: $('#laydate-startTime').val(),
theme: 'molv',
trigger: 'click',
done: function(value, date) {
// 开始时间小于结束时间
if (value !== '') {
startDate.config.max.year = date.year;
startDate.config.max.month = date.month - 1;
startDate.config.max.date = date.date;
} else {
startDate.config.max.year = '';
startDate.config.max.month = '';
startDate.config.max.date = '';
}
}
});
});
```
--------------------------------
### Laydate: Start Date with End Date Constraint
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/form/datetime.html
Configures a Laydate start date picker. It sets the maximum selectable date based on the value of the end date input and applies a 'molv' theme. The 'done' callback ensures the end date picker's minimum date is updated when the start date changes.
```javascript
var startDate = laydate.render({
elem: '#laydate-startTime',
max: $('#laydate-endTime').val(),
theme: 'molv',
trigger: 'click',
done: function(value, date) {
// 结束时间大于开始时间
if (value !== '') {
endDate.config.min.year = date.year;
endDate.config.min.month = date.month - 1;
endDate.config.min.date = date.date;
} else {
endDate.config.min.year = '';
endDate.config.min.month = '';
endDate.config.min.date = '';
}
}
});
```
--------------------------------
### Initialize Multiple Bootstrap Tables
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/table/multi.html
Configures two distinct tables with unique IDs and toolbars, utilizing the RuoYi-Go table initialization pattern.
```javascript
var prefix = ctx + "/demo/operate"; var datas = {{DictType "sys_common_status"}}; $(function() { var options = { id: "bootstrap-table1", toolbar: "toolbar1", url: prefix + "/list", createUrl: prefix + "/add", removeUrl: prefix + "/remove", updateUrl: prefix + "/edit/{id}", modalName: "用户", columns: [{ checkbox: true }, { field : 'userId', title : '用户ID' }, { field : 'userCode', title : '用户编号' }, { field : 'userName', title : '用户姓名' }, { field : 'userPhone', title : '用户手机' }, { field : 'userEmail', title : '用户邮箱' }, { field : 'userBalance', title : '用户余额' }, { field: 'status', title: '用户状态', align: 'center', formatter: function(value, row, index) { return $.table.selectDictLabel(datas, value); } }, { title: '操作', align: 'center', formatter: function(value, row, index) { var actions = []; actions.push('编辑 '); actions.push('删除'); return actions.join(''); } }] }; $.table.init(options); }); $(function() { var options = { id: "bootstrap-table2", toolbar: "toolbar2", url: prefix + "/list", createUrl: prefix + "/add", removeUrl: prefix + "/remove", updateUrl: prefix + "/edit/{id}", modalName: "用户", columns: [{ checkbox: true }, { field : 'userId', title : '用户ID' }, { field : 'userCode', title : '用户编号' }, { field : 'userName', title : '用户姓名' }, { field : 'userPhone', title : '用户手机' }, { field : 'userEmail', title : '用户邮箱' }, { field : 'userBalance', title : '用户余额' }, { field: 'status', title: '用户状态', align: 'center', formatter: function(value, row, index) { return $.table.selectDictLabel(datas, value); } }, { title: '操作', align: 'center', formatter: function(value, row, index) { var actions = []; actions.push('编辑 '); actions.push('删除'); return actions.join(''); } }] }; $.table.init(options); });
```
--------------------------------
### Get Selected Rows Callback
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/modal/table/parent.html
Retrieves the first column of selected rows from a table. This function is typically called from a parent window to get data from a child selection window.
```javascript
function getSelections() {
return $.table.selectFirstColumns();
}
```
--------------------------------
### Initialize Table with Options
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/modal/table/parent.html
Initializes a Bootstrap table with specified options, including URL, columns, and custom formatters. Use this for setting up data grids.
```javascript
var prefix = ctx + "/demo/table";
var datas = {{DictType "sys_common_status"}};
$(function() {
var options = {
url: prefix + "/list",
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
columns: [{
checkbox: true
}, {
field: 'userId',
title: '用户ID'
}, {
field: 'userCode',
title: '用户编号'
}, {
field: 'userName',
title: '用户姓名'
}, {
field: 'userPhone',
title: '用户手机'
}, {
field: 'userEmail',
title: '用户邮箱'
}, {
field: 'userBalance',
title: '用户余额'
}, {
field: 'status',
title: '用户状态',
align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(datas, value);
}
}, {
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = []
actions.push('编辑 ')
actions.push('删除')
return actions.join('')
}
}]
};
$.table.init(options);
});
```
--------------------------------
### Bootstrap-datetimepicker: End Date with Start Date Constraint
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/form/datetime.html
Configures an end date picker. It defaults to the current date and sets the end date for the start date picker to prevent selecting dates after the end date.
```javascript
$("#datetimepicker-endTime").datetimepicker({
format: 'yyyy-mm-dd',
minView: "month",
todayBtn: true,
autoclose: true,
endDate : new Date(),
}).on('changeDate', function(event) {
event.preventDefault();
event.stopPropagation();
var endTime = event.date;
$("#datetimepicker-startTime").datetimepicker('setEndDate', endTime);
});
```
--------------------------------
### Initialize Layui Date and Month Pickers
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/mywork/his_data_wizard.html
Configures date pickers for start/end dates and a month picker using the Layui library.
```javascript
layui.use('laydate', function () { layui.laydate.render({ elem: '#startDate' //指定元素 ,format: 'yyyy-MM-dd' //可任意组合 ,done: function(value, date, endDate){ $("#dpc_start").val(value) } }); layui.laydate.render({ elem: '#endDate' //指定元素 ,format: 'yyyy-MM-dd' //可任意组合 ,done: function(value, date, endDate){ $("#dpc_end").val(value) } }); layui.laydate.render({ elem: '#month' //指定元素 ,type:'month' ,done: function(value, date, endDate){ } }); });
```
--------------------------------
### GET /tool/gen/genCode
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Generates code files for a specific table.
```APIDOC
## GET /tool/gen/genCode
### Description
Generates code files for a specific table.
### Method
GET
### Endpoint
/tool/gen/genCode
### Parameters
#### Query Parameters
- **tableId** (int) - Required - Table ID
### Response
#### Success Response (200)
- **code** (int) - Status code
- **msg** (string) - Success message
```
--------------------------------
### Three.js Background Particle System Initialization
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/lock.html
Sets up a 3D scene using Three.js to render a particle system as a dynamic background for the lock screen. Includes camera, scene, and renderer configuration.
```javascript
var container; var camera, scene, projector, renderer; var PI2 = Math.PI * 2; var programFill = function(context) { context.beginPath(); context.arc(0, 0, 1, 0, PI2, true); context.closePath(); context.fill(); }; var programStroke = function(context) { context.lineWidth = 0.05; context.beginPath(); context.arc(0, 0, 1, 0, PI2, true); context.closePath(); context.stroke(); }; var mouse = { x: 0, y: 0 }, INTERSECTED; function init() { container = document.createElement('div'); container.id = 'bgc'; container.style.position = 'absolute'; container.style.zIndex = '0'; container.style.top = '0px'; $(".lockscreen-wrapper").before(container); camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 10000); camera.position.set(0, 300, 500); scene = new THREE.Scene(); for (var i = 0; i < 100; i++) { var particle = new THREE.Particle(new THREE.ParticleCanvasMaterial({ color: Math.random() * 0x808080 + 0x808080, program: programStroke })); particle.position.x = Math.random() * 800 - 400; particle.position.y = Math.random() * 800 - 400; particle.position.z = Math.random() * 800 - 400; particle.scale.x = particle.scale.y = Math.random() * 10 + 10; scene.add(particle); } projector = new THREE.Projector(); renderer = new THREE.CanvasRenderer(); renderer.setSize(window.innerWidth, window.innerHeight - 10); container.appendChild(renderer.domElement); document.addEventListener('mousemove', onDocumentMouseMove, false); window.addEventListener('resize', onWindowResize, false); };
```
--------------------------------
### GET /tool/gen/preview
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Previews the generated code for a specific table.
```APIDOC
## GET /tool/gen/preview
### Description
Previews the generated code for a specific table.
### Method
GET
### Endpoint
/tool/gen/preview
### Parameters
#### Query Parameters
- **tableId** (int) - Required - Table ID
### Response
#### Success Response (200)
- **code** (int) - Status code
- **data** (object) - Map of file names to generated content
```
--------------------------------
### GET /logout
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Logs the user out by clearing the session state.
```APIDOC
## GET /logout
### Description
Clears the user's login session.
### Method
GET
### Endpoint
/logout
```
--------------------------------
### POST /system/user/add
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Creates a new system user.
```APIDOC
## POST /system/user/add
### Description
Registers a new user in the system.
### Method
POST
### Endpoint
/system/user/add
### Request Body
- **loginName** (string) - Required
- **userName** (string) - Required
- **password** (string) - Required
- **deptId** (int) - Required
- **roleIds** (string) - Optional - Comma separated IDs
### Response
#### Success Response (200)
- **code** (int) - Status code
- **data** (int) - New user ID
```
--------------------------------
### Cross-Compilation with xgo (All Platforms)
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/README.MD
Compiles the project for all supported platforms using the `xgo` cross-compilation tool. Includes linker flags for optimization.
```bash
xgo -ldflags "-w -s"
```
--------------------------------
### GET /tool/gen
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves the list of imported tables for code generation.
```APIDOC
## GET /tool/gen
### Description
Retrieves the list of imported tables for code generation.
### Method
GET
### Endpoint
/tool/gen
```
--------------------------------
### GET /system/user/profile/
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves the profile page for the currently logged-in user.
```APIDOC
## GET /system/user/profile/
### Description
获取当前登录用户的资料页面。
### Method
GET
### Endpoint
/system/user/profile/
### Response
#### Success Response (200)
- Returns user profile data
```
--------------------------------
### Initialize Icon Picker and Menu Type Handling
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/system/menu/add.html
Sets up an icon picker that shows a dropdown when the icon input is focused. It also handles the visibility of form fields based on the selected menu type (Directory, Menu, or Button).
```javascript
$(function () { $("input\[name='icon'\s*]\s*").focus(function () { $(".icon-drop").show(); }); $("#form-menu-add").click(function (event) { var obj = event.srcElement || event.target; if (!$(obj).is("input\[name='icon'\s*]\s*")) { $(".icon-drop").hide(); } }); $(".icon-drop").find(".ico-list i").on("click", function () { $("#icon").val($(this).attr('class')); }); $('input').on('ifChecked', function (event) { var menuType = $(event.target).val(); if (menuType == "M") { $("#url").parents(".form-group").hide(); $("#perms").parents(".form-group").hide(); $("#icon").parents(".form-group").show(); $("#target").parents(".form-group").hide(); $("input\[name='visible'\s*]\s*").parents(".form-group").show(); } else if (menuType == "C") { $("#url").parents(".form-group").show(); $("#perms").parents(".form-group").show(); $("#icon").parents(".form-group").show(); $("#target").parents(".form-group").show(); $("input\[name='visible'\s*]\s*").parents(".form-group").show(); } else if (menuType == "F") { $("#url").parents(".form-group").show(); $("#perms").parents(".form-group").show(); $("#icon").parents(".form-group").hide(); $("#target").parents(".form-group").hide(); $("input\[name='visible'\s*]\s*").parents(".form-group").hide(); } }); });
```
--------------------------------
### Initialize Department Tree
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/system/user/list.html
Sets up a department tree for navigation and selection. It fetches data from the server and allows clicking on nodes to trigger a table search. Use this for hierarchical data display.
```javascript
var url = ctx + "/system/dept/treeData";
var options = {
url: url,
expandLevel: 2,
onClick: zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#deptId").val(treeNode.id);
$("#parentId").val(treeNode.pId);
$.table.search();
}
```
--------------------------------
### Initialize Table Options
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/tool/gen_edit_table.html
Sets up the options for a Bootstrap table, including URL, sorting, height, and column definitions. It also defines custom formatters for serial numbers, column comments, Go types, and Go fields.
```javascript
var prefix = ctx + "/tool/gen";
$(function () {
var options = {
url: prefix + "/column/list",
sortName: "sort",
sortOrder: "desc",
height: $(window).height() - 166,
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
onLoadSuccess: onLoadSuccess,
onReorderRow: onReorderRow,
columns: [{
title: "序号",
width: "5%",
formatter: function (value, row, index) {
// 编号隐藏域
var columnIdHtml = $.common.sprintf("", index, row.columnId);
// 排序隐藏域
var sortHtml = $.common.sprintf("", index, row.sort, row.columnId);
return columnIdHtml + sortHtml + $.table.serialNumber(index);
},
cellStyle: function (value, row, index) {
return {css: {"cursor": "move"}};
}
}, {
field: 'columnName',
title: '字段列名',
width: "10%",
class: "nodrag",
cellStyle: function (value, row, index) {
return {css: {"cursor": "default"}};
}
}, {
field: 'columnComment',
title: '字段描述',
width: "10%",
formatter: function (value, row, index) {
var html = $.common.sprintf("", index, value);
return html;
}
}, {
field: 'columnType',
title: '物理类型',
width: "10%",
class: "nodrag",
cellStyle: function (value, row, index) {
return {css: {"cursor": "default"}};
}
}, {
field: 'goType',
title: 'Go类型',
width: "10%",
formatter: function (value, row, index) {
var data = [{index: index, goType: value}];
return $("#goTypeTpl").tmpl(data).html();
}
}, {
field: 'goField',
title: 'Go属性',
width: "10%",
formatter: function (value, row, index) {
```
--------------------------------
### GET /system/dept/treeData
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves department tree structure data for dropdown selection.
```APIDOC
## GET /system/dept/treeData
### Description
Retrieves department tree structure data for dropdown selection.
### Method
GET
### Endpoint
/system/dept/treeData
### Response
#### Success Response (200)
- **id** (int) - Department ID
- **pId** (int) - Parent ID
- **name** (string) - Department name
- **title** (string) - Display title
- **checked** (boolean) - Selection state
- **open** (boolean) - Expanded state
### Response Example
[
{
"id": 100,
"pId": 0,
"name": "若依科技",
"title": "若依科技",
"checked": false,
"open": true
}
]
```
--------------------------------
### Get User Profile
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves the profile page for the currently logged-in user.
```bash
curl -X GET http://localhost:8080/system/user/profile/ \
-H "Cookie: token=your_token_here"
```
--------------------------------
### Initialize User List Table
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/system/user/list.html
Configures and initializes the user data table with specified columns, URLs for operations, and sorting options. Use this when displaying a list of users.
```javascript
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit?id={id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
importUrl: prefix + "/importData",
importTemplateUrl: prefix + "/importTemplate",
sortName: "create_time",
sortOrder: "desc",
modalName: "用户",
columns: [
{ checkbox: true },
{ field: 'userId', title: '用户ID' },
{ field: 'loginName', title: '登录名称', sortable: true },
{ field: 'userName', title: '用户名称' },
{ field: 'deptName', title: '部门' },
{ field: 'email', title: '邮箱', visible: false },
{ field: 'phonenumber', title: '手机' },
{
visible: editFlag == 'hidden' ? false : true,
title: '用户状态',
align: 'center',
formatter: function (value, row, index) {
return statusTools(row);
}
},
{ field: 'createTime', title: '创建时间', sortable: true, formatter:function (value,row,index) {
return value;
}
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = []
actions.push('编辑 ')
actions.push('删除 ')
actions.push('重置')
return actions.join('')
}
}
]
};
$.table.init(options);
```
--------------------------------
### POST /system/menu/add
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Creates a new menu or button entry.
```APIDOC
## POST /system/menu/add
### Description
Creates a new menu or button.
### Method
POST
### Endpoint
/system/menu/add
### Request Body
- **parentId** (int) - Required - Parent menu ID
- **menuName** (string) - Required - Menu name
- **orderNum** (int) - Optional - Display order
- **url** (string) - Optional - Menu URL
- **menuType** (string) - Required - M=Directory, C=Menu, F=Button
- **visible** (string) - Optional - Visibility status
- **perms** (string) - Optional - Permission string
- **icon** (string) - Optional - Icon class
### Response
#### Success Response (200)
- **code** (int) - Status code
- **msg** (string) - Success message
- **data** (int) - New menu ID
### Response Example
{
"code": 200,
"msg": "操作成功",
"data": 2001
}
```
--------------------------------
### POST /system/role/add
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Creates a new role and assigns menu permissions.
```APIDOC
## POST /system/role/add
### Description
创建新角色并分配菜单权限。
### Method
POST
### Endpoint
/system/role/add
### Request Body
- **roleName** (string) - Required - Role name
- **roleKey** (string) - Required - Role key
- **menuIds** (string) - Required - Comma separated menu IDs
```
--------------------------------
### Get Dictionary Type List API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves a paginated list of dictionary types.
```bash
curl -X POST http://localhost:8080/system/dict/list \
-H "Cookie: token=your_token_here" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "pageNum=1&pageSize=10&dictName=&dictType=&status=0"
```
--------------------------------
### Generate code using make
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/pkg/lv_grpc_driver_proto/README.md
Execute the make command to trigger the project's code generation process.
```bash
make
```
--------------------------------
### Initialize Datepicker for Start Date
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/mywork/table/add.html
Configures a jQuery datetimepicker for the 'startDate' input, formatted as 'yyyy-mm-dd'.
```javascript
$("input[name='startDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
```
--------------------------------
### System Configuration List Template
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/system/config/list.html
This Go template defines the HTML structure for the system configuration list page. It includes placeholders for dynamic content, buttons for actions like add, edit, remove, and export, and integrates with a dictionary type for filtering.
```gohtml
{{define "system/config/list"}} {{template "header" (OssUrl)}}
* 参数名称:
* 参数键名:
* 系统内置:{{getDictTypeSelect "sys\_yes\_no" "configType" "configType" "" "" "所有" ""}}
* 创建时间: \-
* 搜索 重置
{{PermButton .uid "system:config:add" "$.operate.add()" "新增" "btn btn-success" "fa fa-plus"}} {{PermButton .uid "system:config:edit" "$.operate.edit()" "修改" "btn btn-primary single disabled" "fa fa-edit"}} {{PermButton .uid "system:config:remove" "$.operate.removeAll()" "删除" "btn btn-danger multiple disabled" "fa fa-remove"}} {{PermButton .uid "system:config:export" "$.table.exportExcel()" "导出" "btn btn-warning" "fa fa-download"}}
{{template "footer" (OssUrl)}}
```
--------------------------------
### Add Configuration API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Adds a new system configuration parameter.
```bash
curl -X POST http://localhost:8080/system/config/add \
-H "Cookie: token=your_token_here" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "configName=测试配置&configKey=test.config.key&configValue=test_value&configType=Y&remark=测试配置项"
```
--------------------------------
### Add New Role
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Creates a new role and assigns menu permissions.
```bash
curl -X POST http://localhost:8080/system/role/add \
-H "Cookie: token=your_token_here" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "roleName=测试角色&roleKey=test&roleSort=3&status=0&menuIds=1,2,3,100,101"
# 响应示例
{
"code": 200,
"msg": "操作成功",
"data": 5
}
```
--------------------------------
### Get Department Tree API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves the department hierarchy in zTree format for UI components.
```bash
curl -X GET http://localhost:8080/system/dept/treeData \
-H "Cookie: token=your_token_here"
```
--------------------------------
### Initialize RuoYi-Go Table
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/table/other.html
Configures the table options including data source, column definitions, and custom formatters for status and action buttons.
```javascript
var prefix = ctx + "/demo/table"; var datas = {{DictType "sys_common_status"}}; $(function() { var options = { url: prefix + "/list", showSearch: false, showRefresh: false, showToggle: false, showColumns: false, columns: [{ checkbox: true }, { field : 'userId', title : '用户ID' }, { field : 'userCode', title : '用户编号' }, { field : 'userName', title : '用户姓名' }, { field : 'userPhone', title : '用户手机' }, { field : 'userEmail', title : '用户邮箱' }, { field : 'userBalance', title : '用户余额' }, { field: 'status', title: '用户状态', align: 'center', formatter: function(value, row, index) { return $.table.selectDictLabel(datas, value); } }, { title: '操作', align: 'center', formatter: function(value, row, index) { var actions = []; actions.push('编辑 '); actions.push('删除'); return actions.join(''); } }] }; $.table.init(options); });
```
--------------------------------
### Get Online User List
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves a list of currently online users. Requires authentication token.
```bash
curl -X POST http://localhost:8080/monitor/online/list \
-H "Cookie: token=your_token_here" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "pageNum=1&pageSize=10&loginName=&ipaddr="
```
--------------------------------
### Initialize Task Table
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/mywork/task/list.html
Configures the Bootstrap Table with columns and action buttons for the task management module.
```JavaScript
var editFlag = '{{HasPerm .uid "mywork:task:edit"}}'; var removeFlag = '{{HasPerm .uid "mywork:task:remove"}}'; var statusDatas = {{DictType "sys_normal_disable"}}; var prefix = ctx + "/mywork/task"; $(function () { var options = { url: prefix + "/list", createUrl: prefix + "/add", updateUrl: prefix + "/edit?id={id}", removeUrl: prefix + "/remove", exportUrl: prefix + "/export", modalName: "task", columns: [ { checkbox: true }, { field: 'id', title: '', visible: false }, { field: 'username', title: '工号' }, { field: 'password', title: '密码' }, { field: 'prjCode', title: '项 目 号' }, { field: 'taskContent', title: '任务内容' }, { field: 'startDate', title: '开始日期' }, { field: 'endDate', title: '结束日期' }, { field: 'workDays', title: '本月工时' }, { field: 'autoSubmit', title: '自动提交' }, { field: 'status', title: '任务状态', formatter: function (value, row, index) { return $.table.selectDictLabel(statusDatas, value); } }, { field: 'sort', title: '排序,大的优先' }, { title: '操作', align: 'center', formatter: function (value, row, index) { var actions = []; actions.push('编辑 '); actions.push('删除'); return actions.join(''); } } ] }; $.table.init(options); });
```
--------------------------------
### Get Dictionary Data List API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves all data entries associated with a specific dictionary type.
```bash
curl -X POST http://localhost:8080/system/dict/data/list \
-H "Cookie: token=your_token_here" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "dictType=sys_user_sex"
```
--------------------------------
### Get Role Menu Tree API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves the menu permission tree assigned to a specific role.
```bash
curl -X GET "http://localhost:8080/system/menu/roleMenuTreeData?roleId=2" \
-H "Cookie: token=your_token_here"
```
--------------------------------
### Initialize Bootstrap Dual Listbox
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/form/duallistbox.html
Configures the dual listbox with custom labels and behavior settings. Ensure the plugin is loaded before calling this initialization.
```javascript
$('.dual_select').bootstrapDualListbox({ nonSelectedListLabel: '未有用户', selectedListLabel: '已有用户', preserveSelectionOnMove: 'moved', moveOnSelect: false, // 出现一个剪头,表示可以一次选择一个 filterTextClear: '展示所有', moveSelectedLabel: "添加", moveAllLabel: '添加所有', removeSelectedLabel: "移除", removeAllLabel: '移除所有', infoText: '共{0}个', showFilterInputs: false, // 是否带搜索 selectorMinimalHeight: 160 });
```
--------------------------------
### Get All Table Data
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/table/curd.html
Retrieves all data currently present in the table and displays it as a JSON string in an alert box.
```javascript
function getData(){
var data = $("#" + table.options.id).bootstrapTable('getData');
alert(JSON.stringify(data))
}
```
--------------------------------
### Initialize Table Component
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/tool/gen_import_table.html
Configures the table view for database table selection using the RuoYi table plugin.
```javascript
var prefix = ctx + "/tool/gen"; $(function () { var options = { url: prefix + "/db/list", sortName: "create_time", sortOrder: "desc", showSearch: false, showRefresh: false, showToggle: false, showColumns: false, clickToSelect: true, rememberSelected: true, uniqueId: "tableName", columns: [{ field: 'state', checkbox: true }, { title: "序号", width: 5, formatter: function (value, row, index) { return $.table.serialNumber(index); } }, { field: 'tableName', title: '表名称', width: 20, sortable: true }, { field: 'tableComment', title: '表描述', width: 40, sortable: true }, { field: 'createTime', title: '创建时间', width: 20, sortable: true }, { field: 'updateTime', title: '更新时间', width: 20, sortable: true }] }; $.table.init(options); });
```
--------------------------------
### Initialize Sparkline and Peity Charts
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/report/metrics.html
Initializes sparkline charts for trends and pie charts for usage rates, alongside peity charts for visual data representation. Requires jQuery and the respective chart plugins to be loaded.
```javascript
$(document).ready(function () { $("#sparkline1").sparkline([34, 43, 43, 35, 44, 32, 44, 52], { type: 'line', width: '100%', height: '60', lineColor: '#1ab394', fillColor: "#ffffff" }); $("#sparkline2").sparkline([24, 43, 43, 55, 44, 62, 44, 72], { type: 'line', width: '100%', height: '60', lineColor: '#1ab394', fillColor: "#ffffff" }); $("#sparkline3").sparkline([74, 43, 23, 55, 54, 32, 24, 12], { type: 'line', width: '100%', height: '60', lineColor: '#ed5565', fillColor: "#ffffff" }); $("#sparkline4").sparkline([24, 43, 33, 55, 64, 72, 44, 22], { type: 'line', width: '100%', height: '60', lineColor: '#ed5565', fillColor: "#ffffff" }); $("#sparkline5").sparkline([1, 4], { type: 'pie', height: '140', sliceColors: ['#1ab394', '#F5F5F5'] }); $("#sparkline6").sparkline([5, 3], { type: 'pie', height: '140', sliceColors: ['#1ab394', '#F5F5F5'] }); $("#sparkline7").sparkline([2, 2], { type: 'pie', height: '140', sliceColors: ['#ed5565', '#F5F5F5'] }); $("#sparkline8").sparkline([2, 3], { type: 'pie', height: '140', sliceColors: ['#ed5565', '#F5F5F5'] }); }); $(function() { $("span.pie").peity("pie", { fill: ['#1ab394', '#d7d7d7', '#ffffff'] }) $(".line").peity("line",{ fill: '#1ab394', stroke:'#169c81', }) $(".bar").peity("bar", { fill: ["#1ab394", "#d7d7d7"] }) $(".bar_dashboard").peity("bar", { fill: ["#1ab394", "#d7d7d7"], width:100 }) var updatingChart = $(".updating-chart").peity("line", { fill: '#1ab394',stroke:'#169c81', width: 64 }) setInterval(function() { var random = Math.round(Math.random() * 10) var values = updatingChart.text().split(",") values.shift() values.push(random) updatingChart .text(values.join(",")) .change() }, 1000); });
```
--------------------------------
### Get Code Generator Table List
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves a list of imported tables for code generation. Requires authentication token.
```bash
curl -X GET http://localhost:8080/tool/gen \
-H "Cookie: token=your_token_here"
```
--------------------------------
### Get Server Monitor API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves real-time server health metrics including CPU, memory, and disk usage.
```bash
curl -X GET http://localhost:8080/monitor/server/ \
-H "Cookie: token=your_token_here"
```
--------------------------------
### POST /monitor/logininfor/list
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Queries system login logs.
```APIDOC
## POST /monitor/logininfor/list
### Description
Queries system login logs.
### Method
POST
### Endpoint
/monitor/logininfor/list
### Parameters
#### Request Body
- **pageNum** (int) - Required - Page number
- **pageSize** (int) - Required - Page size
- **loginName** (string) - Optional - Login name filter
- **ipaddr** (string) - Optional - IP address filter
- **status** (string) - Optional - Status filter
### Response
#### Success Response (200)
- **code** (int) - Status code
- **total** (int) - Total count
- **rows** (array) - List of login logs
```
--------------------------------
### Get User List Page API
Source: https://context7.com/lostvip-com/ruoyi-go/llms.txt
Retrieves the user management list page. Requires a token in the Cookie header.
```bash
curl -X GET http://localhost:8080/system/user/ \
-H "Cookie: token=your_token_here"
```
--------------------------------
### Cross-Compilation with xgo (ARM7 Platform)
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/README.MD
Compiles the project specifically for the Linux ARM7 platform using `xgo`. Generates a timestamped executable and includes linker flags.
```bash
xgo -ldflags "-w -s" -out svc-$(date '+%Y%m%d_%H%M%S') --targets=linux/arm-7 .
```
--------------------------------
### Remove Row by Unique ID
Source: https://github.com/lostvip-com/ruoyi-go/blob/main/resources/template/demo/table/curd.html
Removes a specific row from the table using its unique identifier. This example removes the row with userId 1.
```javascript
function removeRowByUniqueId(){
$("#" + table.options.id).bootstrapTable('removeByUniqueId', 1)
}
```