完善用户拓展文档
This commit is contained in:
parent
6719277a05
commit
88342a08ae
@ -35,6 +35,34 @@ public class UserExpandDTO extends UserDTO {
|
|||||||
示例
|
示例
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
package ink.wgink.gateway.manage.dao.user.expand;
|
||||||
|
|
||||||
|
import ink.wgink.exceptions.SaveException;
|
||||||
|
import ink.wgink.exceptions.UpdateException;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface IUserExpandDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws SaveException
|
||||||
|
*/
|
||||||
|
void save(Map<String, Object> params) throws SaveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws UpdateException
|
||||||
|
*/
|
||||||
|
void update(Map<String, Object> params) throws UpdateException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -43,7 +71,61 @@ public class UserExpandDTO extends UserDTO {
|
|||||||
示例
|
示例
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="ink.wgink.gateway.manage.dao.user.expand.IUserExpandDao">
|
||||||
|
|
||||||
|
<resultMap id="userExpandDTO" type="ink.wgink.gateway.manage.pojo.dtos.user.expand.UserExpandDTO">
|
||||||
|
<result column="gateway_access_key" property="gatewayAccessKey"/>
|
||||||
|
<result column="gateway_access_secret" property="gatewayAccessSecret"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="userExpandPO" type="ink.wgink.gateway.manage.pojo.pos.user.expand.UserExpandPO">
|
||||||
|
<result column="gateway_access_key" property="gatewayAccessKey"/>
|
||||||
|
<result column="gateway_access_secret" property="gatewayAccessSecret"/>
|
||||||
|
<result column="modifier" property="modifier"/>
|
||||||
|
<result column="gmt_modified" property="gmtModified"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 新增 -->
|
||||||
|
<insert id="save" parameterType="map">
|
||||||
|
INSERT INTO sys_user_expand(
|
||||||
|
user_id,
|
||||||
|
gateway_access_key,
|
||||||
|
gateway_access_secret,
|
||||||
|
creator,
|
||||||
|
gmt_create,
|
||||||
|
modifier,
|
||||||
|
gmt_modified
|
||||||
|
) VALUES(
|
||||||
|
#{userId},
|
||||||
|
#{gatewayAccessKey},
|
||||||
|
#{gatewayAccessSecret},
|
||||||
|
#{creator},
|
||||||
|
#{gmtCreate},
|
||||||
|
#{modifier},
|
||||||
|
#{gmtModified}
|
||||||
|
}
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改 -->
|
||||||
|
<update id="update" parameterType="map">
|
||||||
|
UPDATE
|
||||||
|
sys_user_expand
|
||||||
|
SET
|
||||||
|
<if test="gatewayAccessKey != null and gatewayAccessKey != ''">
|
||||||
|
gateway_access_key = #{gatewayAccessKey},
|
||||||
|
</if>
|
||||||
|
<if test="gatewayAccessSecret != null">
|
||||||
|
gateway_access_secret = #{gatewayAccessSecret},
|
||||||
|
</if>
|
||||||
|
modifier = #{modifier},
|
||||||
|
gmt_modified = #{gmtModified}
|
||||||
|
WHERE
|
||||||
|
user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. 创建接口
|
### 4. 创建接口
|
||||||
@ -85,7 +167,7 @@ public interface IUserExpandService extends IUserExpandBaseService<UserExpandDTO
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 实现接口
|
### 5.实现接口
|
||||||
|
|
||||||
根据需要实现对应的方法
|
根据需要实现对应的方法
|
||||||
|
|
||||||
@ -100,4 +182,159 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6.编辑界面
|
||||||
|
|
||||||
|
通过实现接口中的方法,在用户列表的操作列中,会多出一个按钮,用于完成拓展属性的编辑。
|
||||||
|
|
||||||
|
步骤如下:
|
||||||
|
|
||||||
|
1. 增加拓展属性页面与接口的 `Controller`
|
||||||
|
2. 实现`public String getRoute()`
|
||||||
|
|
||||||
|
> `getRoute`的返回值为拓展属性编辑页面的url。
|
||||||
|
> 当`getRoute`返回`null`或者**空字符串**时,用户列表中的按钮不显示。
|
||||||
|
|
||||||
|
示例
|
||||||
|
|
||||||
|
```java
|
||||||
|
@Service
|
||||||
|
public class UserExpandServiceImpl extends DefaultBaseService implements IUserExpandService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoute() {
|
||||||
|
return "route/user/expand/update";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
当属性按钮出现后,点击按钮时,会弹窗打开编辑页面,同时在url后携带userId参数。
|
||||||
|
携带的userId就是点击行的用户ID,页面自行接收处理。
|
||||||
|
|
||||||
|
如:`/route/user/expand/update?uesrId=123123123`
|
||||||
|
|
||||||
|
页面示例
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!doctype html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'}">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<blockquote class="layui-elem-quote">网关访问属性(保存刷新)</blockquote>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<label class="layui-form-label">网关访问Key</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="gatewayAccessKey" name="gatewayAccessKey" class="layui-input" value="" placeholder="网关访问Key" maxlength="255" disabled>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<label class="layui-form-label">网关访问Secret</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="gatewayAccessSecret" name="gatewayAccessSecret" class="layui-input" value="" placeholder="网关访问Secret" maxlength="255" disabled>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate'], function () {
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var userId = top.restAjax.params(window.location.href).userId;
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/user/expand/get/{userId}', [userId]), {}, null, function (code, data) {
|
||||||
|
var dataFormData = {};
|
||||||
|
for (var i in data) {
|
||||||
|
dataFormData[i] = data[i] + '';
|
||||||
|
}
|
||||||
|
form.val('dataForm', dataFormData);
|
||||||
|
form.render(null, 'dataForm');
|
||||||
|
}, function (code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function () {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function () {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function (formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function (index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.put(top.restAjax.path('api/user/expand/update/{userId}', [userId]), formData.field, null, function (code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function (index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function () {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function (code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function () {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function () {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function () {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({});
|
||||||
|
});
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user