Skip to content

Commit ec3c9f0

Browse files
committed
upgrade
1 parent 8fbcb5d commit ec3c9f0

File tree

83 files changed

+3963
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3963
-276
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
1. 支持 [gorm](https://gorm.io/gorm) 数据库组件
2222
1. 支持 [go-redis](https://github.com/go-redis/redis/v7) 组件
2323
1. 支持 RESTful API 返回值规范
24-
1. 支持 gormgen、handlergen 代码生成工具
24+
1. 支持 生成数据表 CURD、控制器方法 等代码生成器
2525
1. 支持 web 界面,使用的 [Light Year Admin 模板](https://gitee.com/yinqi/Light-Year-Admin-Using-Iframe)
2626

2727

assets/bootstrap/images/qr-code.png

4.07 MB
Loading

assets/bootstrap/js/httpclient/httpclient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ document.write('<script type="text/javascript" src="../../bootstrap/js/authoriza
33
document.write('<script type="text/javascript" src="../../bootstrap/js/authorization/hmac-sha256.js"></script>');
44
document.write('<script type="text/javascript" src="../../bootstrap/js/authorization/enc-base64.min.js"></script>');
55
document.write('<script type="text/javascript" src="../../bootstrap/js/jquery.cookie.min.js"></script>');
6-
6+
document.write('<div style="display:none"><script type="text/javascript">document.write(unescape("%3Cspan id=\'cnzz_stat_icon_1279911342\'%3E%3C/span%3E%3Cscript src=\'https://v1.cnzz.com/z_stat.php%3Fid%3D1279911342%26\' type=\'text/javascript\'%3E%3C/script%3E"));</script></div>');
77

88
function GenerateAuthorization(path, method, params) {
99
let key = "admin";

assets/templates/admin/admin_list.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
' <a class="btn btn-xs btn-default btn-resetPassword" href="#!" title=""\n' +
132132
' data-id="' + value.hashid + '"' +
133133
' data-toggle="tooltip" data-original-title="重置密码">重置密码</a>\n' +
134+
' <a class="btn btn-xs btn-default btn-menu" href="#!" title=""\n' +
135+
' data-id="' + value.hashid + '"' +
136+
' data-toggle="tooltip" data-original-title="菜单授权">菜单授权</a>\n' +
134137
' <a class="btn btn-xs btn-default btn-confirm" href="#!" title=""\n' +
135138
' data-id="' + value.hashid + '"' +
136139
' data-toggle="tooltip" data-original-title="删除">删除</a>\n' +
@@ -272,6 +275,11 @@
272275
});
273276
});
274277

278+
// 菜单授权
279+
$(document).on('click', '.btn-menu', function () {
280+
location.href = "/admin/action/" + $(this).attr('data-id');
281+
});
282+
275283
// 删除
276284
$(document).on('click', '.btn-confirm', function () {
277285
const id = $(this).attr('data-id');

assets/templates/admin/admin_login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115

116116
AjaxForm(
117117
"POST",
118-
"/login/web",
118+
"/api/login",
119119
postData,
120120
function () {
121121
},
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
<!DOCTYPE html>
2+
<html lang="zh">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
6+
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
7+
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
8+
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
9+
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
10+
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
11+
</head>
12+
13+
<body>
14+
<div class="container-fluid p-t-15">
15+
<div class="row">
16+
<div class="col-lg-12">
17+
<div class="card">
18+
<div class="card-header">
19+
<div class="card-title">配置菜单
20+
<small id="adminName"></small>
21+
</div>
22+
</div>
23+
<div class="card-body">
24+
25+
<form action="#!" method="post" id="form">
26+
<div class="table-responsive">
27+
<table class="table table-striped">
28+
<thead>
29+
<tr>
30+
<th>
31+
<div class="custom-control custom-checkbox">
32+
<input type="checkbox" class="custom-control-input" id="check-all">
33+
<label class="custom-control-label" for="check-all">全选/取消全选</label>
34+
</div>
35+
</th>
36+
</tr>
37+
</thead>
38+
39+
<tbody class="tbody">
40+
41+
</tbody>
42+
</table>
43+
</div>
44+
45+
<button type="button" id="btnOk" class="btn btn-primary">确认</button>
46+
<button type="button" id="btnLoading" class="btn btn-primary" disabled style="display: none">
47+
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
48+
执行中...
49+
</button>
50+
</form>
51+
</div>
52+
</div>
53+
</div>
54+
</div>
55+
</div>
56+
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
57+
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
58+
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
59+
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
60+
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
61+
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
62+
<script type="text/javascript">
63+
$(document).ready(function () {
64+
const hash_id = {{ .HashID }}
65+
66+
AjaxForm(
67+
"GET",
68+
"/api/admin/menu/" + hash_id,
69+
'',
70+
function () {
71+
},
72+
function (data) {
73+
$("#adminName").html("(管理员:" + data.username + ")");
74+
75+
if (data.list.length > 0) {
76+
let newArr = [];
77+
data.list.forEach(function (v) {
78+
if (v.pid === 0) {
79+
v.children = [];
80+
newArr.push(v)
81+
}
82+
});
83+
84+
data.list.forEach(function (v) {
85+
newArr.forEach(function (item) {
86+
if (v.pid === item.id) {
87+
item.children.push(v)
88+
}
89+
})
90+
});
91+
92+
93+
$.each(newArr, function (index, value) {
94+
let checked = "";
95+
if (value.is_have == 1) {
96+
checked = "checked";
97+
}
98+
99+
let tr = '<tr><td><div class="custom-control custom-checkbox custom-parent">';
100+
tr += '<input type="checkbox" ' + checked + ' class="custom-control-input checkbox-parent" id="' + value.id + '" value="' + value.id + '">';
101+
tr += '<label class="custom-control-label" for="' + value.id + '">' + value.name + '</label>';
102+
tr += '</div></td></tr>';
103+
104+
tr += '<tr><td class="p-l-40">';
105+
106+
value.children.forEach(function (item) {
107+
let itemChecked = "";
108+
if (item.is_have == 1) {
109+
itemChecked = "checked";
110+
}
111+
112+
tr += '<div class="custom-control custom-checkbox custom-control-inline">';
113+
tr += '<input type="checkbox" ' + itemChecked + ' class="custom-control-input checkbox-child c-' + item.pid + '" id="' + item.id + '" value="' + item.id + '">';
114+
tr += '<label class="custom-control-label" for="' + item.id + '">' + item.name + '</label>';
115+
tr += '</div>';
116+
});
117+
118+
tr += '</td></tr>';
119+
120+
$(".tbody").append(tr);
121+
122+
});
123+
}
124+
},
125+
function (response) {
126+
AjaxError(response);
127+
}
128+
);
129+
130+
$(document).on('click', '.checkbox-parent', function () {
131+
const id = $(this).attr('id');
132+
if ($(this).prop('checked') === true) {
133+
$(this).prop('checked', true);
134+
$('.c-' + id).prop('checked', true);
135+
} else {
136+
$(this).prop('checked', false);
137+
$('.c-' + id).prop('checked', false);
138+
}
139+
});
140+
141+
$(document).on('click', '.checkbox-child', function () {
142+
if ($(this).prop('checked') === true) {
143+
$(this).prop('checked', true);
144+
} else {
145+
$(this).prop('checked', false);
146+
}
147+
});
148+
149+
$(document).on('click', '#check-all', function () {
150+
if ($(this).prop('checked') === true) {
151+
$('.checkbox-parent').prop('checked', true);
152+
$('.checkbox-child').prop('checked', true);
153+
} else {
154+
$('.checkbox-parent').prop('checked', false);
155+
$('.checkbox-child').prop('checked', false);
156+
}
157+
});
158+
159+
$('#btnOk').on('click', function () {
160+
let vals = [];
161+
$.each($('.tbody').find('input:checkbox:checked'), function () {
162+
vals.push($(this).val());
163+
});
164+
165+
if (vals.length === 0) {
166+
$.alert({
167+
title: '温馨提示',
168+
icon: 'mdi mdi-alert',
169+
type: 'orange',
170+
content: '请至少选择 1 个功能权限。',
171+
});
172+
return false;
173+
}
174+
175+
AjaxForm(
176+
"POST",
177+
"/api/admin/menu",
178+
{id: hash_id, actions: vals.join(',')},
179+
function () {
180+
$(this).hide();
181+
$("#btnLoading").show();
182+
},
183+
function () {
184+
$("#btnLoading").hide();
185+
$("#btnOk").show();
186+
187+
$.alert({
188+
title: '操作成功',
189+
icon: 'mdi mdi-check-decagram',
190+
type: 'green',
191+
content: $("#adminName").html() + ' 菜单授权完成。',
192+
buttons: {
193+
okay: {
194+
text: '关闭',
195+
action: function () {
196+
location.href = "/admin/list";
197+
}
198+
}
199+
}
200+
});
201+
},
202+
function (response) {
203+
$("#btnLoading").hide();
204+
$("#btnOk").show();
205+
206+
AjaxError(response);
207+
}
208+
);
209+
});
210+
})
211+
</script>
212+
</body>
213+
</html>

assets/templates/authorized/authorized_api.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<div class="col-lg-6">
5959
<div class="card">
6060
<header class="card-header">
61-
<div class="card-title">已授权接口</div>
61+
<div class="card-title">已授权接口<small id="businessKey"></small></div>
6262
</header>
6363
<div class="card-body apis">
6464

@@ -96,6 +96,7 @@
9696

9797
},
9898
function (data) {
99+
$("#businessKey").html("(授权方:" + data.business_key + ")");
99100
if (data.list.length > 0) {
100101
var badgeMethodClass = "";
101102

assets/templates/authorized/authorized_demo.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,6 @@
210210
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
211211
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
212212
<script type="text/javascript" src="../../bootstrap/js/main.min.js"></script>
213+
<script type="text/javascript">document.write(unescape("%3Cspan id='cnzz_stat_icon_1279911342'%3E%3C/span%3E%3Cscript src='https://v1.cnzz.com/z_stat.php%3Fid%3D1279911342%26' type='text/javascript'%3E%3C/script%3E"));</script>
213214
</body>
214215
</html>

assets/templates/configinfo/config_code.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
</div>
4444
</div>
45-
45+
<div style="display:none">
46+
<script type="text/javascript">document.write(unescape("%3Cspan id='cnzz_stat_icon_1279911342'%3E%3C/span%3E%3Cscript src='https://v1.cnzz.com/z_stat.php%3Fid%3D1279911342%26' type='text/javascript'%3E%3C/script%3E"));</script>
47+
</div>
4648
</body>
4749
</html>

assets/templates/configinfo/config_email.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="col-lg-12">
1515
<div class="card">
1616
<header class="card-header">
17-
<div class="card-title"> 邮箱告警配置</div>
17+
<div class="card-title">邮箱告警配置</div>
1818
</header>
1919
<div class="card-body">
2020
<form class="site-form">
@@ -119,7 +119,7 @@
119119
return false;
120120
}
121121

122-
const postData = {
122+
const patchData = {
123123
host: host,
124124
port: port,
125125
user: user,
@@ -131,7 +131,7 @@
131131
AjaxForm(
132132
"PATCH",
133133
"/api/config/email",
134-
postData,
134+
patchData,
135135
function () {
136136
$(this).hide();
137137
$("#btnLoading").show();

0 commit comments

Comments
 (0)