Skip to content

Commit 35fa3db

Browse files
committed
优化应用管理编辑页面和列表
1 parent bd7911c commit 35fa3db

File tree

3 files changed

+61
-10
lines changed

3 files changed

+61
-10
lines changed

zlt-doc/sql/oauth-center.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CREATE TABLE `oauth_client_details` (
1818
`access_token_validity` int(11) NULL DEFAULT NULL COMMENT 'access_token有效期',
1919
`refresh_token_validity` int(11) NULL DEFAULT NULL COMMENT 'refresh_token有效期',
2020
`additional_information` varchar(4096) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '{}' COMMENT '{}',
21-
`autoapprove` char(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'true' COMMENT '是否自动授权 是-true',
21+
`autoapprove` char(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'true' COMMENT '是否自动授权 是-true',
2222
`create_time` datetime(0) NULL DEFAULT NULL,
2323
`update_time` datetime(0) NULL DEFAULT NULL,
2424
`client_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '应用名称',

zlt-uaa/src/main/resources/mapper/ClientMapper.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
<select id="findList" resultType="com.central.oauth.model.Client">
4848
select id, client_id, client_name, resource_ids
4949
, client_secret, client_secret_str, web_server_redirect_uri
50+
, scope, authorized_grant_types, autoapprove
51+
, access_token_validity accessTokenValiditySeconds
52+
, refresh_token_validity refreshTokenValiditySeconds
5053
from oauth_client_details
5154
<include refid="where"/>
5255
</select>

zlt-web/back-web/src/main/resources/static/pages/attestation/app.html

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h2 class="header-title">应用管理</h2>
2626

2727
<!-- 表单弹窗 -->
2828
<script type="text/html" id="app-model">
29-
<form id="app-form" lay-filter="app-form" class="layui-form model-form">
29+
<form id="app-form" method="POST" lay-filter="app-form" class="layui-form model-form">
3030
<input name="id" type="hidden"/>
3131
<div class="layui-form-item">
3232
<label class="layui-form-label">应用标识</label>
@@ -54,6 +54,35 @@ <h2 class="header-title">应用管理</h2>
5454
<input name="webServerRedirectUri" placeholder="请输入回调地址" type="text" class="layui-input" maxlength="20"/>
5555
</div>
5656
</div>
57+
<div class="layui-form-item">
58+
<label class="layui-form-label">自动审批</label>
59+
<div class="layui-input-block">
60+
<input type="radio" name="autoapprove" value="true" title="是" checked/>
61+
<input type="radio" name="autoapprove" value="false" title="否"/>
62+
</div>
63+
</div>
64+
<div class="layui-form-item">
65+
<label class="layui-form-label">授权模式</label>
66+
<div class="layui-input-block">
67+
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="授权码模式" value="authorization_code" checked>
68+
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="密码模式" value="password" checked>
69+
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="客户端模式" value="client_credentials" checked>
70+
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="简化模式" value="implicit" checked>
71+
<input type="checkbox" name="authorizedGrantTypes" lay-skin="primary" title="刷新Token" value="refresh_token" checked>
72+
</div>
73+
</div>
74+
<div class="layui-form-item">
75+
<label class="layui-form-label">令牌时效(s)</label>
76+
<div class="layui-input-block">
77+
<input name="accessTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="18000"/>
78+
</div>
79+
</div>
80+
<div class="layui-form-item">
81+
<label class="layui-form-label">刷新时效(s)</label>
82+
<div class="layui-input-block">
83+
<input name="refreshTokenValiditySeconds" lay-verify="number" type="text" class="layui-input" maxlength="20" value="28800"/>
84+
</div>
85+
</div>
5786
<div class="layui-form-item model-form-footer">
5887
<button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
5988
<button class="layui-btn" lay-filter="app-form-submit" lay-submit>保存</button>
@@ -81,11 +110,15 @@ <h2 class="header-title">应用管理</h2>
81110
cols: [[
82111
{type: 'numbers'},
83112
{field: 'clientId',width:180, sort: true, title: '应用标识'},
84-
{field: 'clientName',width:200, sort: true, title: '应用名称'},
85-
{field: 'clientSecretStr', width:180, sort: true, title: '应用密钥'},
86-
{field: 'webServerRedirectUri',sort: true, title: '回调地址'},
113+
{field: 'clientName',width:180, sort: true, title: '应用名称'},
114+
{field: 'webServerRedirectUri', width:250,sort: true, title: '回调地址'},
87115
{field: 'authorizedGrantTypes',width:250, sort: true, title: 'oauth授权方式'},
88-
{align: 'center',width:150, toolbar: '#app-table-bar', title: '操作'}
116+
{width:110, sort: true, title: '自动审批', templet:function (d) {
117+
return d.autoapprove=='true'?"是":"否"
118+
}},
119+
{field: 'accessTokenValiditySeconds',width:130, sort: true, title: '令牌时效(s)'},
120+
{field: 'refreshTokenValiditySeconds',width:130, sort: true, title: '刷新时效(s)'},
121+
{fixed: 'right', align: 'center',width:150, toolbar: '#app-table-bar', title: '操作'}
89122
]]
90123
});
91124

@@ -132,29 +165,44 @@ <h2 class="header-title">应用管理</h2>
132165
type: 1,
133166
title: data ? '修改应用' : '添加应用',
134167
area: '450px',
135-
offset: '120px',
168+
offset: '80px',
136169
content: $('#app-model').html(),
137170
success: function () {
138171
$('#app-form')[0].reset();
139-
$('#app-form').attr('method', 'POST');
140172
if (data) {
141173
$("input[name='clientId']").attr('disabled',true);
142174
$("input[name='clientId']").attr('class',"layui-input layui-disabled");
143175
$("input[name='webServerRedirectUri']").attr('disabled',true);
144176
$("input[name='webServerRedirectUri']").attr('class',"layui-input layui-disabled");
145177
form.val('app-form', data);
146-
$('#app-form').attr('method', 'POST');
178+
179+
let authorizedGrantTypesArr = data.authorizedGrantTypes.split(",");
180+
$('input[type=checkbox][name=authorizedGrantTypes]').each(function() {
181+
let typeValue = $(this).val();
182+
let isCheck = false;
183+
for (var i = 0; i < authorizedGrantTypesArr.length; i++) {
184+
if (typeValue === authorizedGrantTypesArr[i]) {
185+
isCheck = true;
186+
break;
187+
}
188+
}
189+
$(this).prop("checked", isCheck);
190+
});
147191
}
148192
}
149193
});
150194
};
151195

152196
// 表单提交事件
153197
form.on('submit(app-form-submit)', function (data) {
198+
let authorizedGrantTypesArr = [];
199+
$('input[type=checkbox][name=authorizedGrantTypes]:checked').each(function() {
200+
authorizedGrantTypesArr.push($(this).val());
201+
});
202+
data.field.authorizedGrantTypes = authorizedGrantTypesArr.join(",");
154203
layer.load(2);
155204
admin.req('api-uaa/clients/saveOrUpdate', JSON.stringify(data.field), function (data) {
156205
layer.closeAll('loading');
157-
console.log(data);
158206
if (data.resp_code == 0) {
159207
layer.msg(data.resp_msg, {icon: 1, time: 500});
160208
table.reload('app-table');

0 commit comments

Comments
 (0)