# walnut
**Repository Path**: huangdecong/walnut
## Basic Information
- **Project Name**: walnut
- **Description**: 六个核桃
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 3
- **Forks**: 1
- **Created**: 2020-12-23
- **Last Updated**: 2021-03-23
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# **一、使用前配置**
* 确保依赖导入成功
* 修改application.yml中数据库配置
* 确保`9999`端口不被占用
# **二、须知&DEMO**
>**1. 须知**
>
>* **code: 在walnut.json中可以看到**
```json
[{
"[code]": {
"tabName": "[tabName]",
"titles": "[titles]"
}
}]
```
>**2. 使用**
>
>* **网址访问**
e.g.
查:localhost:9900/get/STU001000
删:localhost:9900/del/CAR001011?id=1
ps:慎用,只可用于后三位数非0的code,否则数据全删没了
>* **结合[$.ajax](https://blog.csdn.net/lyhkmm/article/details/78259780?ops_request_misc=%25257B%252522request%25255Fid%252522%25253A%252522160940068716780281288450%252522%25252C%252522scm%252522%25253A%25252220140713.130102334..%252522%25257D&request_id=160940068716780281288450&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-2-78259780.first_rank_v2_pc_rank_v29&utm_term=$.ajax)使用**
>* **结合[layui框架](https://www.layui.com/demo/)使用**
>
>` 查操作`
>
>
前端html
```html
```
js
```javascript
table.render({
elem: '#formTest'
,url:'http://localhost:9999/get/QUE001121'
,toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
,title: '用户数据表'
,cols: [[
{field:'id', title:'id', width:80, fixed: 'left', unresize: true, sort: true}
,{field:'car_id', title:'car_id', width:80, fixed: 'left', unresize: true, sort: true}
,{field:'phone', title:'phone', width:120, edit: 'text'}
,{field:'start_time', title:'start_time', width:200, edit: 'text'}
,{field:'end_time', title:'end_time', width:200, edit: 'text'}
,{field:'practice_notes', title:'practice_notes', sort: true}
,{fixed: 'right', width: 165, align:'center', toolbar: '#barDemo'}
]]
,page: true
,response: {
statusCode: 200 //重新规定成功的状态码为 200,table 组件默认为 0
}
,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
// console.log(res)
return {
"code": 200, //解析接口状态
"msg": res.message, //解析提示文本
"count": res.total, //解析数据长度
"data": res //解析数据列表
};
}
});
```
>` 增操作`
```javascript
/* 增:需结合前端`$.ajax`或`$.post`传值 */
$.ajax({
type: "GET",
url: "http://localhost:9999/saveForm/QUE001000",
async: false,
dataType: 'json',
contentType: 'application/json;charset=UTF-8',
data: {dataSet: dataSet},
success: function (res) {
if (res.code == '200') {
layer.msg("添加成功!");
} else if (res.code == '300') {
alert("添加失败!" + res.msg);
}
},
error: function (err) {
alert("网络连接失败,稍后重试!" + err);
}
});
```
# **三、DEMO使用**
访问地址:localhost:9999/test
页面为测试页面
· 页面初始渲染即为`查`操作
· 单击 “+” 按钮可进行`增`操作
# **四、walnut.json的编辑**
该文件中code、tabName、titles均可自定义,按自己业务需求来定义即可。
```json
[{
"STU001000": {
"tabName": "easypai_login",
"titles": ""
},
"STU001021": {
"tabName": "easypai_login",
"titles": " where phone='' and password='' and identity_status=0"
},
"INS001021": {
"tabName": "easypai_login",
"titles": " where phone='' and password='' and identity_status=1"
},
"POJ001000": {
"tabName": "easypai_poj",
"titles": ""
},
"CAR001011": {
"tabName": "easypai_cars",
"titles": " where id=''"
},
"QUE001000": {
"tabName": "easypai_trainee",
"titles": ""
},
"QUE002011": {
"tabName": "queue_info",
"titles": " where end_time is null and id=''"
},
"[Newcode]": {
"tabName": "[NewtabName]",
"titles": "[Newtitles]"
}
}]
```