diff --git a/docs/src/main/resources/doc/wgink/code/backend/service/user-expand.md b/docs/src/main/resources/doc/wgink/code/backend/service/user-expand.md index b279c8ce..00314dc4 100644 --- a/docs/src/main/resources/doc/wgink/code/backend/service/user-expand.md +++ b/docs/src/main/resources/doc/wgink/code/backend/service/user-expand.md @@ -35,6 +35,34 @@ public class UserExpandDTO extends UserDTO { 示例 ```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 params) throws SaveException; + + /** + * 修改 + * + * @param params + * @throws UpdateException + */ + void update(Map params) throws UpdateException; + +} ``` @@ -43,7 +71,61 @@ public class UserExpandDTO extends UserDTO { 示例 ```xml + + + + + + + + + + + + + + + + + + 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} + } + + + + + UPDATE + sys_user_expand + SET + + gateway_access_key = #{gatewayAccessKey}, + + + gateway_access_secret = #{gatewayAccessSecret}, + + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + user_id = #{userId} + + + ``` ### 4. 创建接口 @@ -85,7 +167,7 @@ public interface IUserExpandService extends IUserExpandBaseService `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 + + + + + + + + + + + + + +
+
+
+
+
网关访问属性(保存刷新)
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+ + + +``` + +```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({}); +}); ``` \ No newline at end of file