-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmybatisBind.html
More file actions
83 lines (71 loc) · 2.33 KB
/
mybatisBind.html
File metadata and controls
83 lines (71 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>MyBatis bind</title>
<link rel="stylesheet" href="less.css">
<style type="text/css">
textarea {
width: 100%;
height: 400px;
}
</style>
<script type="text/javascript" src="https://cdn.jsdelivr.net/json2/0.2/json2.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="polyfill.js"></script>
<script type="text/javascript">
function generate(p, sql) {
const param = JSON.parse(p);
console.log(param, sql);
let result = sql;
for (const key in param) {
console.log('key', key);
console.log('param[key]', param[key], typeof param[key]);
const reg = new RegExp(`#\{${key}[^}]*\}`, 'ig');
if (typeof param[key] === 'number') {
result = result.replace(reg, `${param[key]}`);
} else {
result = result.replace(reg, `'${param[key]}'`);
}
}
return result;
}
$(function () {
const $param = $('.param');
const $src = $('.src');
$('.param').keyup(function () {
$('.dst').val('');
$('.dst').val(generate($param.val(), $src.val()));
}).scroll(function () {
$('.src').scrollTop
}).keyup();
$('.src').keyup(function () {
$('.dst').val('');
$('.dst').val(generate($param.val(), $src.val()));
}).scroll(function () {
$('.src').scrollTop
}).keyup();
});
</script>
</head>
<body class="mybatisBind">
<div class="wrap">
<h1>nativebinary - mybatis</h1>
<h4>
<a href="https://nativebinary.github.io/json-util/">jsonPrettier</a> |
<a href="https://nativebinary.github.io/json-util/jsonToJava.html">jsonToJava</a> |
<a href="https://nativebinary.github.io/json-util/ddlToJava.html">ddlToJava</a> |
<a href="https://nativebinary.github.io/json-util/generatePassword.html">generatePassword</a> |
<a href="https://nativebinary.github.io/json-util/mybatisBind.html">mybatisBind</a> |
</h4>
<textarea class="param">
{ "aaa": "111", "bbb": 222}
</textarea>
<textarea class="src">
SELECT * FROM AAA WHERE #{aaa} = #{bbb}
</textarea>
<textarea class="dst"></textarea>
</div>
</body>
</html>