and others
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/README.md:
--------------------------------------------------------------------------------
1 | # CodeMirror
2 | [](https://travis-ci.org/codemirror/CodeMirror)
3 | [](https://www.npmjs.org/package/codemirror)
4 | [Funding status: ](https://marijnhaverbeke.nl/fund/)
5 |
6 | CodeMirror is a JavaScript component that provides a code editor in
7 | the browser. When a mode is available for the language you are coding
8 | in, it will color your code, and optionally help with indentation.
9 |
10 | The project page is http://codemirror.net
11 | The manual is at http://codemirror.net/doc/manual.html
12 | The contributing guidelines are in [CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
13 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/dialog/dialog.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-dialog {
2 | position: absolute;
3 | left: 0; right: 0;
4 | background: white;
5 | z-index: 15;
6 | padding: .1em .8em;
7 | overflow: hidden;
8 | color: #333;
9 | }
10 |
11 | .CodeMirror-dialog-top {
12 | border-bottom: 1px solid #eee;
13 | top: 0;
14 | }
15 |
16 | .CodeMirror-dialog-bottom {
17 | border-top: 1px solid #eee;
18 | bottom: 0;
19 | }
20 |
21 | .CodeMirror-dialog input {
22 | border: none;
23 | outline: none;
24 | background: transparent;
25 | width: 20em;
26 | color: inherit;
27 | font-family: monospace;
28 | }
29 |
30 | .CodeMirror-dialog button {
31 | font-size: 70%;
32 | }
33 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/display/fullscreen.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-fullscreen {
2 | position: fixed;
3 | top: 0; left: 0; right: 0; bottom: 0;
4 | height: auto;
5 | z-index: 9;
6 | }
7 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/display/fullscreen.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
15 | if (old == CodeMirror.Init) old = false;
16 | if (!old == !val) return;
17 | if (val) setFullscreen(cm);
18 | else setNormal(cm);
19 | });
20 |
21 | function setFullscreen(cm) {
22 | var wrap = cm.getWrapperElement();
23 | cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
24 | width: wrap.style.width, height: wrap.style.height};
25 | wrap.style.width = "";
26 | wrap.style.height = "auto";
27 | wrap.className += " CodeMirror-fullscreen";
28 | document.documentElement.style.overflow = "hidden";
29 | cm.refresh();
30 | }
31 |
32 | function setNormal(cm) {
33 | var wrap = cm.getWrapperElement();
34 | wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
35 | document.documentElement.style.overflow = "";
36 | var info = cm.state.fullScreenRestore;
37 | wrap.style.width = info.width; wrap.style.height = info.height;
38 | window.scrollTo(info.scrollLeft, info.scrollTop);
39 | cm.refresh();
40 | }
41 | });
42 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/edit/trailingspace.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
13 | if (prev == CodeMirror.Init) prev = false;
14 | if (prev && !val)
15 | cm.removeOverlay("trailingspace");
16 | else if (!prev && val)
17 | cm.addOverlay({
18 | token: function(stream) {
19 | for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
20 | if (i > stream.pos) { stream.pos = i; return null; }
21 | stream.pos = l;
22 | return "trailingspace";
23 | },
24 | name: "trailingspace"
25 | });
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/fold/foldgutter.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-foldmarker {
2 | color: blue;
3 | text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
4 | font-family: arial;
5 | line-height: .3;
6 | cursor: pointer;
7 | }
8 | .CodeMirror-foldgutter {
9 | width: .7em;
10 | }
11 | .CodeMirror-foldgutter-open,
12 | .CodeMirror-foldgutter-folded {
13 | cursor: pointer;
14 | }
15 | .CodeMirror-foldgutter-open:after {
16 | content: "\25BE";
17 | }
18 | .CodeMirror-foldgutter-folded:after {
19 | content: "\25B8";
20 | }
21 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/hint/show-hint.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-hints {
2 | position: absolute;
3 | z-index: 10;
4 | overflow: hidden;
5 | list-style: none;
6 |
7 | margin: 0;
8 | padding: 2px;
9 |
10 | -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
11 | -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
12 | box-shadow: 2px 3px 5px rgba(0,0,0,.2);
13 | border-radius: 3px;
14 | border: 1px solid silver;
15 |
16 | background: white;
17 | font-size: 90%;
18 | font-family: monospace;
19 |
20 | max-height: 20em;
21 | overflow-y: auto;
22 | }
23 |
24 | .CodeMirror-hint {
25 | margin: 0;
26 | padding: 0 4px;
27 | border-radius: 2px;
28 | max-width: 19em;
29 | overflow: hidden;
30 | white-space: pre;
31 | color: black;
32 | cursor: pointer;
33 | }
34 |
35 | li.CodeMirror-hint-active {
36 | background: #08f;
37 | color: white;
38 | }
39 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/lint/coffeescript-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
5 |
6 | // declare global: coffeelint
7 |
8 | (function(mod) {
9 | if (typeof exports == "object" && typeof module == "object") // CommonJS
10 | mod(require("../../lib/codemirror"));
11 | else if (typeof define == "function" && define.amd) // AMD
12 | define(["../../lib/codemirror"], mod);
13 | else // Plain browser env
14 | mod(CodeMirror);
15 | })(function(CodeMirror) {
16 | "use strict";
17 |
18 | CodeMirror.registerHelper("lint", "coffeescript", function(text) {
19 | var found = [];
20 | var parseError = function(err) {
21 | var loc = err.lineNumber;
22 | found.push({from: CodeMirror.Pos(loc-1, 0),
23 | to: CodeMirror.Pos(loc, 0),
24 | severity: err.level,
25 | message: err.message});
26 | };
27 | try {
28 | var res = coffeelint.lint(text);
29 | for(var i = 0; i < res.length; i++) {
30 | parseError(res[i]);
31 | }
32 | } catch(e) {
33 | found.push({from: CodeMirror.Pos(e.location.first_line, 0),
34 | to: CodeMirror.Pos(e.location.last_line, e.location.last_column),
35 | severity: 'error',
36 | message: e.message});
37 | }
38 | return found;
39 | });
40 |
41 | });
42 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/lint/css-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // Depends on csslint.js from https://github.com/stubbornella/csslint
5 |
6 | // declare global: CSSLint
7 |
8 | (function(mod) {
9 | if (typeof exports == "object" && typeof module == "object") // CommonJS
10 | mod(require("../../lib/codemirror"));
11 | else if (typeof define == "function" && define.amd) // AMD
12 | define(["../../lib/codemirror"], mod);
13 | else // Plain browser env
14 | mod(CodeMirror);
15 | })(function(CodeMirror) {
16 | "use strict";
17 |
18 | CodeMirror.registerHelper("lint", "css", function(text) {
19 | var found = [];
20 | if (!window.CSSLint) return found;
21 | var results = CSSLint.verify(text), messages = results.messages, message = null;
22 | for ( var i = 0; i < messages.length; i++) {
23 | message = messages[i];
24 | var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
25 | found.push({
26 | from: CodeMirror.Pos(startLine, startCol),
27 | to: CodeMirror.Pos(endLine, endCol),
28 | message: message.message,
29 | severity : message.type
30 | });
31 | }
32 | return found;
33 | });
34 |
35 | });
36 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/lint/json-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // Depends on jsonlint.js from https://github.com/zaach/jsonlint
5 |
6 | // declare global: jsonlint
7 |
8 | (function(mod) {
9 | if (typeof exports == "object" && typeof module == "object") // CommonJS
10 | mod(require("../../lib/codemirror"));
11 | else if (typeof define == "function" && define.amd) // AMD
12 | define(["../../lib/codemirror"], mod);
13 | else // Plain browser env
14 | mod(CodeMirror);
15 | })(function(CodeMirror) {
16 | "use strict";
17 |
18 | CodeMirror.registerHelper("lint", "json", function(text) {
19 | var found = [];
20 | jsonlint.parseError = function(str, hash) {
21 | var loc = hash.loc;
22 | found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
23 | to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
24 | message: str});
25 | };
26 | try { jsonlint.parse(text); }
27 | catch(e) {}
28 | return found;
29 | });
30 |
31 | });
32 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/lint/yaml-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | // Depends on js-yaml.js from https://github.com/nodeca/js-yaml
15 |
16 | // declare global: jsyaml
17 |
18 | CodeMirror.registerHelper("lint", "yaml", function(text) {
19 | var found = [];
20 | try { jsyaml.load(text); }
21 | catch(e) {
22 | var loc = e.mark;
23 | found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
24 | }
25 | return found;
26 | });
27 |
28 | });
29 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/mode/multiplex_test.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function() {
5 | CodeMirror.defineMode("markdown_with_stex", function(){
6 | var inner = CodeMirror.getMode({}, "stex");
7 | var outer = CodeMirror.getMode({}, "markdown");
8 |
9 | var innerOptions = {
10 | open: '$',
11 | close: '$',
12 | mode: inner,
13 | delimStyle: 'delim',
14 | innerStyle: 'inner'
15 | };
16 |
17 | return CodeMirror.multiplexingMode(outer, innerOptions);
18 | });
19 |
20 | var mode = CodeMirror.getMode({}, "markdown_with_stex");
21 |
22 | function MT(name) {
23 | test.mode(
24 | name,
25 | mode,
26 | Array.prototype.slice.call(arguments, 1),
27 | 'multiplexing');
28 | }
29 |
30 | MT(
31 | "stexInsideMarkdown",
32 | "[strong **Equation:**] [delim $][inner&tag \\pi][delim $]");
33 | })();
34 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/runmode/colorize.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"), require("./runmode"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror", "./runmode"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/;
15 |
16 | function textContent(node, out) {
17 | if (node.nodeType == 3) return out.push(node.nodeValue);
18 | for (var ch = node.firstChild; ch; ch = ch.nextSibling) {
19 | textContent(ch, out);
20 | if (isBlock.test(node.nodeType)) out.push("\n");
21 | }
22 | }
23 |
24 | CodeMirror.colorize = function(collection, defaultMode) {
25 | if (!collection) collection = document.body.getElementsByTagName("pre");
26 |
27 | for (var i = 0; i < collection.length; ++i) {
28 | var node = collection[i];
29 | var mode = node.getAttribute("data-lang") || defaultMode;
30 | if (!mode) continue;
31 |
32 | var text = [];
33 | textContent(node, text);
34 | node.innerHTML = "";
35 | CodeMirror.runMode(text.join(""), mode, node);
36 |
37 | node.className += " cm-s-default";
38 | }
39 | };
40 | });
41 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/scroll/simplescrollbars.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
2 | position: absolute;
3 | background: #ccc;
4 | -moz-box-sizing: border-box;
5 | box-sizing: border-box;
6 | border: 1px solid #bbb;
7 | border-radius: 2px;
8 | }
9 |
10 | .CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
11 | position: absolute;
12 | z-index: 6;
13 | background: #eee;
14 | }
15 |
16 | .CodeMirror-simplescroll-horizontal {
17 | bottom: 0; left: 0;
18 | height: 8px;
19 | }
20 | .CodeMirror-simplescroll-horizontal div {
21 | bottom: 0;
22 | height: 100%;
23 | }
24 |
25 | .CodeMirror-simplescroll-vertical {
26 | right: 0; top: 0;
27 | width: 8px;
28 | }
29 | .CodeMirror-simplescroll-vertical div {
30 | right: 0;
31 | width: 100%;
32 | }
33 |
34 |
35 | .CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
36 | display: none;
37 | }
38 |
39 | .CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
40 | position: absolute;
41 | background: #bcd;
42 | border-radius: 3px;
43 | }
44 |
45 | .CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
46 | position: absolute;
47 | z-index: 6;
48 | }
49 |
50 | .CodeMirror-overlayscroll-horizontal {
51 | bottom: 0; left: 0;
52 | height: 6px;
53 | }
54 | .CodeMirror-overlayscroll-horizontal div {
55 | bottom: 0;
56 | height: 100%;
57 | }
58 |
59 | .CodeMirror-overlayscroll-vertical {
60 | right: 0; top: 0;
61 | width: 6px;
62 | }
63 | .CodeMirror-overlayscroll-vertical div {
64 | right: 0;
65 | width: 100%;
66 | }
67 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/search/matchesonscrollbar.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-search-match {
2 | background: gold;
3 | border-top: 1px solid orange;
4 | border-bottom: 1px solid orange;
5 | -moz-box-sizing: border-box;
6 | box-sizing: border-box;
7 | opacity: .5;
8 | }
9 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/addon/tern/worker.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // declare global: tern, server
5 |
6 | var server;
7 |
8 | this.onmessage = function(e) {
9 | var data = e.data;
10 | switch (data.type) {
11 | case "init": return startServer(data.defs, data.plugins, data.scripts);
12 | case "add": return server.addFile(data.name, data.text);
13 | case "del": return server.delFile(data.name);
14 | case "req": return server.request(data.body, function(err, reqData) {
15 | postMessage({id: data.id, body: reqData, err: err && String(err)});
16 | });
17 | case "getFile":
18 | var c = pending[data.id];
19 | delete pending[data.id];
20 | return c(data.err, data.text);
21 | default: throw new Error("Unknown message type: " + data.type);
22 | }
23 | };
24 |
25 | var nextId = 0, pending = {};
26 | function getFile(file, c) {
27 | postMessage({type: "getFile", name: file, id: ++nextId});
28 | pending[nextId] = c;
29 | }
30 |
31 | function startServer(defs, plugins, scripts) {
32 | if (scripts) importScripts.apply(null, scripts);
33 |
34 | server = new tern.Server({
35 | getFile: getFile,
36 | async: true,
37 | defs: defs,
38 | plugins: plugins
39 | });
40 | }
41 |
42 | var console = {
43 | log: function(v) { postMessage({type: "debug", message: v}); }
44 | };
45 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "codemirror",
3 | "version":"5.0.0",
4 | "main": ["lib/codemirror.js", "lib/codemirror.css"],
5 | "ignore": [
6 | "**/.*",
7 | "node_modules",
8 | "components",
9 | "bin",
10 | "demo",
11 | "doc",
12 | "test",
13 | "index.html",
14 | "package.json"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/diff/diff.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineMode("diff", function() {
15 |
16 | var TOKEN_NAMES = {
17 | '+': 'positive',
18 | '-': 'negative',
19 | '@': 'meta'
20 | };
21 |
22 | return {
23 | token: function(stream) {
24 | var tw_pos = stream.string.search(/[\t ]+?$/);
25 |
26 | if (!stream.sol() || tw_pos === 0) {
27 | stream.skipToEnd();
28 | return ("error " + (
29 | TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
30 | }
31 |
32 | var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
33 |
34 | if (tw_pos === -1) {
35 | stream.skipToEnd();
36 | } else {
37 | stream.pos = tw_pos;
38 | }
39 |
40 | return token_name;
41 | }
42 | };
43 | });
44 |
45 | CodeMirror.defineMIME("text/x-diff", "diff");
46 |
47 | });
48 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/ecl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: ECL mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | ECL mode
27 |
45 |
48 |
49 | Based on CodeMirror's clike mode. For more information see HPCC Systems web site.
50 | MIME types defined: text/x-ecl
.
51 |
52 |
53 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/http/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: HTTP mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | HTTP mode
27 |
28 |
29 |
39 |
40 |
43 |
44 | MIME types defined: message/http
.
45 |
46 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/ntriples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: NTriples mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
28 |
29 |
30 | NTriples mode
31 |
40 |
41 |
44 | MIME types defined: text/n-triples
.
45 |
46 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/ruby/test.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function() {
5 | var mode = CodeMirror.getMode({indentUnit: 2}, "ruby");
6 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
7 |
8 | MT("divide_equal_operator",
9 | "[variable bar] [operator /=] [variable foo]");
10 |
11 | MT("divide_equal_operator_no_spacing",
12 | "[variable foo][operator /=][number 42]");
13 |
14 | })();
15 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/rust/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Rust mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Rust mode
27 |
28 |
29 |
52 |
53 |
58 |
59 | MIME types defined: text/x-rustsrc
.
60 |
61 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/solr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Solr mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
33 |
34 |
35 | Solr mode
36 |
37 |
38 |
47 |
48 |
49 |
55 |
56 | MIME types defined: text/x-solr
.
57 |
58 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/spreadsheet/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Spreadsheet mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
25 |
26 |
27 | Spreadsheet mode
28 |
29 |
30 |
37 |
38 | MIME types defined: text/x-spreadsheet
.
39 |
40 | The Spreadsheet Mode
41 | Created by Robert Plummer
42 |
43 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/tiddlywiki/tiddlywiki.css:
--------------------------------------------------------------------------------
1 | span.cm-underlined {
2 | text-decoration: underline;
3 | }
4 | span.cm-strikethrough {
5 | text-decoration: line-through;
6 | }
7 | span.cm-brace {
8 | color: #170;
9 | font-weight: bold;
10 | }
11 | span.cm-table {
12 | color: blue;
13 | font-weight: bold;
14 | }
15 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/tiki/tiki.css:
--------------------------------------------------------------------------------
1 | .cm-tw-syntaxerror {
2 | color: #FFF;
3 | background-color: #900;
4 | }
5 |
6 | .cm-tw-deleted {
7 | text-decoration: line-through;
8 | }
9 |
10 | .cm-tw-header5 {
11 | font-weight: bold;
12 | }
13 | .cm-tw-listitem:first-child { /*Added first child to fix duplicate padding when highlighting*/
14 | padding-left: 10px;
15 | }
16 |
17 | .cm-tw-box {
18 | border-top-width: 0px ! important;
19 | border-style: solid;
20 | border-width: 1px;
21 | border-color: inherit;
22 | }
23 |
24 | .cm-tw-underline {
25 | text-decoration: underline;
26 | }
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/mode/z80/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Z80 assembly mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Z80 assembly mode
27 |
28 |
29 |
44 |
45 |
50 |
51 | MIME type defined: text/x-z80
.
52 |
53 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "codemirror",
3 | "version":"5.0.0",
4 | "main": "lib/codemirror.js",
5 | "description": "In-browser code editing made bearable",
6 | "licenses": [{"type": "MIT",
7 | "url": "http://codemirror.net/LICENSE"}],
8 | "directories": {"lib": "./lib"},
9 | "scripts": {"test": "node ./test/run.js"},
10 | "devDependencies": {"node-static": "0.6.0",
11 | "phantomjs": "1.9.2-5",
12 | "blint": ">=0.1.1"},
13 | "bugs": "http://github.com/codemirror/CodeMirror/issues",
14 | "keywords": ["JavaScript", "CodeMirror", "Editor"],
15 | "homepage": "http://codemirror.net",
16 | "maintainers":[{"name": "Marijn Haverbeke",
17 | "email": "marijnh@gmail.com",
18 | "web": "http://marijnhaverbeke.nl"}],
19 | "repository": {"type": "git",
20 | "url": "https://github.com/codemirror/CodeMirror.git"}
21 | }
22 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/ambiance-mobile.css:
--------------------------------------------------------------------------------
1 | .cm-s-ambiance.CodeMirror {
2 | -webkit-box-shadow: none;
3 | -moz-box-shadow: none;
4 | box-shadow: none;
5 | }
6 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/cobalt.css:
--------------------------------------------------------------------------------
1 | .cm-s-cobalt.CodeMirror { background: #002240; color: white; }
2 | .cm-s-cobalt div.CodeMirror-selected { background: #b36539 !important; }
3 | .cm-s-cobalt.CodeMirror ::selection { background: rgba(179, 101, 57, .99); }
4 | .cm-s-cobalt.CodeMirror ::-moz-selection { background: rgba(179, 101, 57, .99); }
5 | .cm-s-cobalt .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
6 | .cm-s-cobalt .CodeMirror-guttermarker { color: #ffee80; }
7 | .cm-s-cobalt .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
8 | .cm-s-cobalt .CodeMirror-linenumber { color: #d0d0d0; }
9 | .cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
10 |
11 | .cm-s-cobalt span.cm-comment { color: #08f; }
12 | .cm-s-cobalt span.cm-atom { color: #845dc4; }
13 | .cm-s-cobalt span.cm-number, .cm-s-cobalt span.cm-attribute { color: #ff80e1; }
14 | .cm-s-cobalt span.cm-keyword { color: #ffee80; }
15 | .cm-s-cobalt span.cm-string { color: #3ad900; }
16 | .cm-s-cobalt span.cm-meta { color: #ff9d00; }
17 | .cm-s-cobalt span.cm-variable-2, .cm-s-cobalt span.cm-tag { color: #9effff; }
18 | .cm-s-cobalt span.cm-variable-3, .cm-s-cobalt span.cm-def { color: white; }
19 | .cm-s-cobalt span.cm-bracket { color: #d8d8d8; }
20 | .cm-s-cobalt span.cm-builtin, .cm-s-cobalt span.cm-special { color: #ff9e59; }
21 | .cm-s-cobalt span.cm-link { color: #845dc4; }
22 | .cm-s-cobalt span.cm-error { color: #9d1e15; }
23 |
24 | .cm-s-cobalt .CodeMirror-activeline-background {background: #002D57 !important;}
25 | .cm-s-cobalt .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
26 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/eclipse.css:
--------------------------------------------------------------------------------
1 | .cm-s-eclipse span.cm-meta {color: #FF1717;}
2 | .cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
3 | .cm-s-eclipse span.cm-atom {color: #219;}
4 | .cm-s-eclipse span.cm-number {color: #164;}
5 | .cm-s-eclipse span.cm-def {color: #00f;}
6 | .cm-s-eclipse span.cm-variable {color: black;}
7 | .cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
8 | .cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
9 | .cm-s-eclipse span.cm-property {color: black;}
10 | .cm-s-eclipse span.cm-operator {color: black;}
11 | .cm-s-eclipse span.cm-comment {color: #3F7F5F;}
12 | .cm-s-eclipse span.cm-string {color: #2A00FF;}
13 | .cm-s-eclipse span.cm-string-2 {color: #f50;}
14 | .cm-s-eclipse span.cm-qualifier {color: #555;}
15 | .cm-s-eclipse span.cm-builtin {color: #30a;}
16 | .cm-s-eclipse span.cm-bracket {color: #cc7;}
17 | .cm-s-eclipse span.cm-tag {color: #170;}
18 | .cm-s-eclipse span.cm-attribute {color: #00c;}
19 | .cm-s-eclipse span.cm-link {color: #219;}
20 | .cm-s-eclipse span.cm-error {color: #f00;}
21 |
22 | .cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
23 | .cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
24 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/elegant.css:
--------------------------------------------------------------------------------
1 | .cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
2 | .cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
3 | .cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
4 | .cm-s-elegant span.cm-variable {color: black;}
5 | .cm-s-elegant span.cm-variable-2 {color: #b11;}
6 | .cm-s-elegant span.cm-qualifier {color: #555;}
7 | .cm-s-elegant span.cm-keyword {color: #730;}
8 | .cm-s-elegant span.cm-builtin {color: #30a;}
9 | .cm-s-elegant span.cm-link {color: #762;}
10 | .cm-s-elegant span.cm-error {background-color: #fdd;}
11 |
12 | .cm-s-elegant .CodeMirror-activeline-background {background: #e8f2ff !important;}
13 | .cm-s-elegant .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
14 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/monokai.css:
--------------------------------------------------------------------------------
1 | /* Based on Sublime Text's Monokai theme */
2 |
3 | .cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;}
4 | .cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
5 | .cm-s-monokai.CodeMirror ::selection { background: rgba(73, 72, 62, .99); }
6 | .cm-s-monokai.CodeMirror ::-moz-selection { background: rgba(73, 72, 62, .99); }
7 | .cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
8 | .cm-s-monokai .CodeMirror-guttermarker { color: white; }
9 | .cm-s-monokai .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
10 | .cm-s-monokai .CodeMirror-linenumber {color: #d0d0d0;}
11 | .cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
12 |
13 | .cm-s-monokai span.cm-comment {color: #75715e;}
14 | .cm-s-monokai span.cm-atom {color: #ae81ff;}
15 | .cm-s-monokai span.cm-number {color: #ae81ff;}
16 |
17 | .cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute {color: #a6e22e;}
18 | .cm-s-monokai span.cm-keyword {color: #f92672;}
19 | .cm-s-monokai span.cm-string {color: #e6db74;}
20 |
21 | .cm-s-monokai span.cm-variable {color: #a6e22e;}
22 | .cm-s-monokai span.cm-variable-2 {color: #9effff;}
23 | .cm-s-monokai span.cm-def {color: #fd971f;}
24 | .cm-s-monokai span.cm-bracket {color: #f8f8f2;}
25 | .cm-s-monokai span.cm-tag {color: #f92672;}
26 | .cm-s-monokai span.cm-link {color: #ae81ff;}
27 | .cm-s-monokai span.cm-error {background: #f92672; color: #f8f8f0;}
28 |
29 | .cm-s-monokai .CodeMirror-activeline-background {background: #373831 !important;}
30 | .cm-s-monokai .CodeMirror-matchingbracket {
31 | text-decoration: underline;
32 | color: white !important;
33 | }
34 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/neat.css:
--------------------------------------------------------------------------------
1 | .cm-s-neat span.cm-comment { color: #a86; }
2 | .cm-s-neat span.cm-keyword { line-height: 1em; font-weight: bold; color: blue; }
3 | .cm-s-neat span.cm-string { color: #a22; }
4 | .cm-s-neat span.cm-builtin { line-height: 1em; font-weight: bold; color: #077; }
5 | .cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
6 | .cm-s-neat span.cm-variable { color: black; }
7 | .cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
8 | .cm-s-neat span.cm-meta {color: #555;}
9 | .cm-s-neat span.cm-link { color: #3a3; }
10 |
11 | .cm-s-neat .CodeMirror-activeline-background {background: #e8f2ff !important;}
12 | .cm-s-neat .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
13 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/neo.css:
--------------------------------------------------------------------------------
1 | /* neo theme for codemirror */
2 |
3 | /* Color scheme */
4 |
5 | .cm-s-neo.CodeMirror {
6 | background-color:#ffffff;
7 | color:#2e383c;
8 | line-height:1.4375;
9 | }
10 | .cm-s-neo .cm-comment {color:#75787b}
11 | .cm-s-neo .cm-keyword, .cm-s-neo .cm-property {color:#1d75b3}
12 | .cm-s-neo .cm-atom,.cm-s-neo .cm-number {color:#75438a}
13 | .cm-s-neo .cm-node,.cm-s-neo .cm-tag {color:#9c3328}
14 | .cm-s-neo .cm-string {color:#b35e14}
15 | .cm-s-neo .cm-variable,.cm-s-neo .cm-qualifier {color:#047d65}
16 |
17 |
18 | /* Editor styling */
19 |
20 | .cm-s-neo pre {
21 | padding:0;
22 | }
23 |
24 | .cm-s-neo .CodeMirror-gutters {
25 | border:none;
26 | border-right:10px solid transparent;
27 | background-color:transparent;
28 | }
29 |
30 | .cm-s-neo .CodeMirror-linenumber {
31 | padding:0;
32 | color:#e0e2e5;
33 | }
34 |
35 | .cm-s-neo .CodeMirror-guttermarker { color: #1d75b3; }
36 | .cm-s-neo .CodeMirror-guttermarker-subtle { color: #e0e2e5; }
37 |
38 | .cm-s-neo div.CodeMirror-cursor {
39 | width: auto;
40 | border: 0;
41 | background: rgba(155,157,162,0.37);
42 | z-index: 1;
43 | }
44 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/codemirror/theme/rubyblue.css:
--------------------------------------------------------------------------------
1 | .cm-s-rubyblue.CodeMirror { background: #112435; color: white; }
2 | .cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
3 | .cm-s-rubyblue.CodeMirror ::selection { background: rgba(56, 86, 111, 0.99); }
4 | .cm-s-rubyblue.CodeMirror ::-moz-selection { background: rgba(56, 86, 111, 0.99); }
5 | .cm-s-rubyblue .CodeMirror-gutters { background: #1F4661; border-right: 7px solid #3E7087; }
6 | .cm-s-rubyblue .CodeMirror-guttermarker { color: white; }
7 | .cm-s-rubyblue .CodeMirror-guttermarker-subtle { color: #3E7087; }
8 | .cm-s-rubyblue .CodeMirror-linenumber { color: white; }
9 | .cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
10 |
11 | .cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
12 | .cm-s-rubyblue span.cm-atom { color: #F4C20B; }
13 | .cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
14 | .cm-s-rubyblue span.cm-keyword { color: #F0F; }
15 | .cm-s-rubyblue span.cm-string { color: #F08047; }
16 | .cm-s-rubyblue span.cm-meta { color: #F0F; }
17 | .cm-s-rubyblue span.cm-variable-2, .cm-s-rubyblue span.cm-tag { color: #7BD827; }
18 | .cm-s-rubyblue span.cm-variable-3, .cm-s-rubyblue span.cm-def { color: white; }
19 | .cm-s-rubyblue span.cm-bracket { color: #F0F; }
20 | .cm-s-rubyblue span.cm-link { color: #F4C20B; }
21 | .cm-s-rubyblue span.CodeMirror-matchingbracket { color:#F0F !important; }
22 | .cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
23 | .cm-s-rubyblue span.cm-error { color: #AF2018; }
24 |
25 | .cm-s-rubyblue .CodeMirror-activeline-background {background: #173047 !important;}
26 |
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/static/editormd/lib/jquery.flowchart.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery.flowchart.js v1.1.0 | jquery.flowchart.min.js | jQuery plugin for flowchart.js. | MIT License | By: Pandao | https://github.com/pandao/jquery.flowchart.js | 2015-03-09 */
2 | (function(factory){if(typeof require==="function"&&typeof exports==="object"&&typeof module==="object"){module.exports=factory}else{if(typeof define==="function"){factory(jQuery,flowchart)}else{factory($,flowchart)}}}(function(jQuery,flowchart){(function($){$.fn.flowChart=function(options){options=options||{};var defaults={"x":0,"y":0,"line-width":2,"line-length":50,"text-margin":10,"font-size":14,"font-color":"black","line-color":"black","element-color":"black","fill":"white","yes-text":"yes","no-text":"no","arrow-end":"block","symbols":{"start":{"font-color":"black","element-color":"black","fill":"white"},"end":{"class":"end-element"}},"flowstate":{"past":{"fill":"#CCCCCC","font-size":12},"current":{"fill":"black","font-color":"white","font-weight":"bold"},"future":{"fill":"white"},"request":{"fill":"blue"},"invalid":{"fill":"#444444"},"approved":{"fill":"#58C4A3","font-size":12,"yes-text":"APPROVED","no-text":"n/a"},"rejected":{"fill":"#C45879","font-size":12,"yes-text":"n/a","no-text":"REJECTED"}}};return this.each(function(){var $this=$(this);var diagram=flowchart.parse($this.text());var settings=$.extend(true,defaults,options);$this.html("");diagram.drawSVG(this,settings)})}})(jQuery)}));
--------------------------------------------------------------------------------
/springboot-markdown/src/main/resources/templates/view.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 查看
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/springboot-markdown/src/test/java/com/haiyu/SpringbootMarkdownApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMarkdownApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-memcached/src/main/java/com/haiyu/SpringbootMemcachedApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMemcachedApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMemcachedApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-memcached/src/main/java/com/haiyu/config/MemcacheConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import com.whalin.MemCached.MemCachedClient;
4 | import com.whalin.MemCached.SockIOPool;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.stereotype.Component;
8 |
9 | /**
10 | * @Title: MemcacheConfig
11 | * @Description:
12 | * @author: youqing
13 | * @version: 1.0
14 | * @date: 2018/8/15 14:55
15 | */
16 | @Component
17 | public class MemcacheConfig {
18 | @Autowired
19 | SockIOPoolConfig sockIOPoolConfig;
20 |
21 | @Bean
22 | public SockIOPool sockIOPool(){
23 | //获取连接池的实例
24 | SockIOPool pool = SockIOPool.getInstance();
25 | //服务器列表及其权重
26 | String[] servers = sockIOPoolConfig.getServers();
27 | Integer[] weights = sockIOPoolConfig.getWeights();
28 | //设置服务器信息
29 | pool.setServers(servers);
30 | pool.setWeights(weights);
31 | //设置初始连接数、最小连接数、最大连接数、最大处理时间
32 | pool.setInitConn(sockIOPoolConfig.getInitConn());
33 | pool.setMinConn(sockIOPoolConfig.getMinConn());
34 | pool.setMaxConn(sockIOPoolConfig.getMaxConn());
35 | //设置连接池守护线程的睡眠时间
36 | pool.setMaintSleep(sockIOPoolConfig.getMaintSleep());
37 | //设置TCP参数,连接超时
38 | pool.setNagle(sockIOPoolConfig.isNagle());
39 | pool.setSocketConnectTO(sockIOPoolConfig.getSocketTO());
40 | //初始化并启动连接池
41 | pool.initialize();
42 | return pool;
43 | }
44 |
45 | @Bean
46 | public MemCachedClient memCachedClient(){
47 | return new MemCachedClient();
48 | }
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/springboot-memcached/src/main/java/com/haiyu/config/SockIOPoolConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.stereotype.Component;
6 |
7 |
8 | /**
9 | * @Title: SockIOPoolConfig
10 | * @Description:
11 | * @author: youqing
12 | * @version: 1.0
13 | * @date: 2018/8/15 14:57
14 | */
15 | @Data
16 | @Component
17 | @ConfigurationProperties(prefix = "memcache")
18 | public class SockIOPoolConfig {
19 | private String[] servers;
20 |
21 | private Integer[] weights;
22 |
23 | private int initConn;
24 |
25 | private int minConn;
26 |
27 | private int maxConn;
28 |
29 | private long maintSleep;
30 |
31 | private boolean nagle;
32 |
33 | private int socketTO;
34 | }
35 |
--------------------------------------------------------------------------------
/springboot-memcached/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Radom7/springboot/5c12b4e516c02cd38d2b24dddd3920f7f2e56ffd/springboot-memcached/src/main/resources/application.properties
--------------------------------------------------------------------------------
/springboot-memcached/src/test/java/com/haiyu/SpringbootMemcachedApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import com.whalin.MemCached.MemCachedClient;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | @RunWith(SpringRunner.class)
11 | @SpringBootTest
12 | public class SpringbootMemcachedApplicationTests {
13 |
14 | @Autowired
15 | MemCachedClient memCachedClient;
16 |
17 | @Test
18 | public void contextLoads() {
19 | boolean i = memCachedClient.set("id", "123456", 1000);
20 | System.out.println(String.valueOf(i));
21 | System.out.println(memCachedClient.get("id"));
22 | memCachedClient.replace("id","123");
23 | memCachedClient.replace("ok","123");
24 | System.out.println(memCachedClient.get("id"));
25 | memCachedClient.delete("id");
26 | System.out.println(memCachedClient.get("id"));
27 | System.out.println(memCachedClient.get("ok"));
28 | }
29 |
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/main/java/com/haiyu/SpringbootMybatisGeneratorApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMybatisGeneratorApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMybatisGeneratorApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/main/java/com/haiyu/lin/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.lin.controller;
2 |
3 | import com.haiyu.lin.entity.User;
4 | import com.haiyu.lin.service.UserService;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * Created by Administrator on 2018/5/20.
14 | */
15 | @RestController
16 | public class UserController {
17 | @Autowired
18 | private UserService userService;
19 |
20 | @GetMapping("/batchTest")
21 | public String batchTest() {
22 | List userList = new ArrayList<>();
23 | User user = new User();
24 | for(int i = 0;i < 10;i++){
25 | user.setId(i+1);
26 | user.setName("alice"+i);
27 | user.setAge(16+1);
28 | userList.add(user);
29 | }
30 | int ok = userService.insertByBatch(userList);
31 | if(ok != 0){
32 | System.out.println("成功插入");
33 | return "成功插入";
34 | }else{
35 | System.out.println("失败!!!");
36 | return "失败!!";
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/main/java/com/haiyu/lin/dao/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.lin.dao;
2 |
3 | import com.haiyu.lin.entity.User;
4 | import org.apache.ibatis.annotations.Mapper;
5 |
6 | import java.util.List;
7 |
8 | @Mapper
9 | public interface UserMapper {
10 | int deleteByPrimaryKey(Integer id);
11 |
12 | int insert(User record);
13 |
14 | int insertSelective(User record);
15 |
16 | User selectByPrimaryKey(Integer id);
17 |
18 | int updateByPrimaryKeySelective(User record);
19 |
20 | int updateByPrimaryKey(User record);
21 |
22 | int insertByBatch(List userList);
23 | }
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/main/java/com/haiyu/lin/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.lin.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | public class User implements Serializable {
6 | private Integer id;
7 |
8 | private String name;
9 |
10 | private Integer age;
11 |
12 | private static final long serialVersionUID = 1L;
13 |
14 | public Integer getId() {
15 | return id;
16 | }
17 |
18 | public void setId(Integer id) {
19 | this.id = id;
20 | }
21 |
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | public void setName(String name) {
27 | this.name = name == null ? null : name.trim();
28 | }
29 |
30 | public Integer getAge() {
31 | return age;
32 | }
33 |
34 | public void setAge(Integer age) {
35 | this.age = age;
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return "User{" +
41 | "id=" + id +
42 | ", name='" + name + '\'' +
43 | ", age=" + age +
44 | '}';
45 | }
46 | }
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/main/java/com/haiyu/lin/service/Impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.lin.service.Impl;
2 |
3 | import com.haiyu.lin.dao.UserMapper;
4 | import com.haiyu.lin.entity.User;
5 | import com.haiyu.lin.service.UserService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Created by Administrator on 2018/5/20.
14 | */
15 | @Service
16 | public class UserServiceImpl implements UserService {
17 |
18 | @Autowired
19 | private UserMapper userMapper;
20 |
21 | @Override
22 | public int deleteByPrimaryKey(Integer id) {
23 | return 0;
24 | }
25 |
26 | @Override
27 | public int insert(User record) {
28 | return userMapper.insert(record);
29 | }
30 |
31 | @Override
32 | public int insertSelective(User record) {
33 | return 0;
34 | }
35 |
36 | @Override
37 | public User selectByPrimaryKey(Integer id) {
38 | return null;
39 | }
40 |
41 | @Override
42 | public int updateByPrimaryKeySelective(User record) {
43 | return 0;
44 | }
45 |
46 | @Override
47 | public int updateByPrimaryKey(User record) {
48 | return 0;
49 | }
50 |
51 | @Override
52 | public int insertByBatch(List userList) {
53 | return userMapper.insertByBatch(userList);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/main/java/com/haiyu/lin/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.lin.service;
2 |
3 | import com.haiyu.lin.entity.User;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by Administrator on 2018/5/20.
9 | */
10 |
11 | public interface UserService {
12 | int deleteByPrimaryKey(Integer id);
13 |
14 | int insert(User record);
15 |
16 | int insertSelective(User record);
17 |
18 | User selectByPrimaryKey(Integer id);
19 |
20 | int updateByPrimaryKeySelective(User record);
21 |
22 | int updateByPrimaryKey(User record);
23 |
24 | int insertByBatch(List userList);
25 | }
26 |
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost:3306/test
2 | spring.datasource.username=root
3 | spring.datasource.password=root
4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
5 |
6 |
7 | mybatis.mapper-locations=classpath*:/mapper/**Mapper.xml
8 |
9 | logging.level.com.example.demo.lin.dao=DEBUG
--------------------------------------------------------------------------------
/springboot-mybatis-generator/src/test/java/com/haiyu/SpringbootMybatisGeneratorApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMybatisGeneratorApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-mybatis-mulidatasource/src/main/java/com/haiyu/SpringbootMybatisMulidatasourceApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMybatisMulidatasourceApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMybatisMulidatasourceApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-mybatis-mulidatasource/src/main/java/com/haiyu/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * @Title: User
9 | * @Description:
10 | * @author: youqing
11 | * @version: 1.0
12 | * @date: 2018/8/12 12:12
13 | */
14 | @Data
15 | public class User implements Serializable{
16 | private long id;
17 | private String name;
18 | private String sex;
19 | private Integer age;
20 | }
21 |
--------------------------------------------------------------------------------
/springboot-mybatis-mulidatasource/src/main/java/com/haiyu/mapper/test1/User1Mapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.mapper.test1;
2 |
3 |
4 | import com.haiyu.entity.User;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @Title: UserMapper
11 | * @Description:
12 | * @author: youqing
13 | * @version: 1.0
14 | * @date: 2018/8/12 12:18
15 | */
16 | @Repository
17 | public interface User1Mapper {
18 | List getAll();
19 |
20 | User getOne(Long id);
21 |
22 | void insert(User user);
23 |
24 | void update(User user);
25 |
26 | void delete(Long id);
27 | }
28 |
--------------------------------------------------------------------------------
/springboot-mybatis-mulidatasource/src/main/java/com/haiyu/mapper/test2/User2Mapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.mapper.test2;
2 |
3 |
4 | import com.haiyu.entity.User;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @Title: UserMapper
11 | * @Description:
12 | * @author: youqing
13 | * @version: 1.0
14 | * @date: 2018/8/12 12:18
15 | */
16 | @Repository
17 | public interface User2Mapper {
18 | List getAll();
19 |
20 | User getOne(Long id);
21 |
22 | void insert(User user);
23 |
24 | void update(User user);
25 |
26 | void delete(Long id);
27 | }
28 |
--------------------------------------------------------------------------------
/springboot-mybatis-mulidatasource/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | mybatis.config-locations=classpath:mybatis/mybatis-config.xml
2 |
3 | spring.datasource.test1.driverClassName = com.mysql.jdbc.Driver
4 | spring.datasource.test1.jdbc-url = jdbc:mysql://localhost:3306/shiro?useUnicode=true&characterEncoding=utf-8
5 | spring.datasource.test1.username = root
6 | spring.datasource.test1.password = root
7 |
8 | spring.datasource.test2.driverClassName = com.mysql.jdbc.Driver
9 | spring.datasource.test2.jdbc-url = jdbc:mysql://192.168.0.184:3306/test?useUnicode=true&characterEncoding=utf-8
10 | spring.datasource.test2.username = root
11 | spring.datasource.test2.password = 123456
--------------------------------------------------------------------------------
/springboot-mybatis-mulidatasource/src/main/resources/mybatis/mybatis-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/springboot-mybatis-mulidatasource/src/test/java/com/haiyu/SpringbootMybatisMulidatasourceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMybatisMulidatasourceApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/java/com/haiyu/MyMetaObjectHandler.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
4 | import org.apache.ibatis.reflection.MetaObject;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.stereotype.Component;
8 |
9 | /**
10 | * Created by Administrator on 2018/5/17.
11 | */
12 | //@Component
13 | public class MyMetaObjectHandler extends MetaObjectHandler {
14 |
15 | protected final static Logger logger = LoggerFactory.getLogger(SpringbootMybatisPlusApplication.class);
16 |
17 | @Override
18 | public void insertFill(MetaObject metaObject) {
19 | logger.info("新增的时候干点不可描述的事情");
20 | }
21 |
22 | @Override
23 | public void updateFill(MetaObject metaObject) {
24 | logger.info("更新的时候干点不可描述的事情");
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/java/com/haiyu/SpringbootMybatisPlusApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.transaction.annotation.EnableTransactionManagement;
6 |
7 | @SpringBootApplication
8 | @EnableTransactionManagement
9 | public class SpringbootMybatisPlusApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootMybatisPlusApplication.class, args);
13 | }
14 |
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/java/com/haiyu/config/MybatisPlusConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import com.baomidou.mybatisplus.mapper.ISqlInjector;
4 | import com.baomidou.mybatisplus.mapper.LogicSqlInjector;
5 | import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
6 | import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
7 | import com.baomidou.mybatisplus.plugins.PerformanceInterceptor;
8 | import com.haiyu.MyMetaObjectHandler;
9 | import org.mybatis.spring.annotation.MapperScan;
10 | import org.springframework.context.annotation.Bean;
11 | import org.springframework.context.annotation.Configuration;
12 |
13 |
14 | /**
15 | * Created by Administrator on 2018/5/16.
16 | */
17 | @Configuration
18 | @MapperScan("com.lin.mapper*")
19 | public class MybatisPlusConfig {
20 | /**
21 | * mybatis-plus SQL执行效率插件【生产环境可以关闭】
22 | */
23 | @Bean
24 | public PerformanceInterceptor performanceInterceptor() {
25 | return new PerformanceInterceptor();
26 | }
27 |
28 |
29 | @Bean
30 | public MetaObjectHandler metaObjectHandler(){
31 | return new MyMetaObjectHandler();
32 | }
33 |
34 | /**
35 | * 分页插件
36 | */
37 | @Bean
38 | public PaginationInterceptor paginationInterceptor() {
39 | return new PaginationInterceptor();
40 | }
41 |
42 | /**
43 | * 注入sql注入器
44 | */
45 | @Bean
46 | public ISqlInjector sqlInjector(){
47 | return new LogicSqlInjector();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/java/com/haiyu/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | import com.baomidou.mybatisplus.annotations.TableName;
4 |
5 | /**
6 | * Created by Administrator on 2018/5/16.
7 | */
8 | @TableName("user")
9 | public class User {
10 | private int id;
11 | private String name;
12 | private int age;
13 |
14 | public User() {
15 | }
16 |
17 | public User(String name, int age) {
18 | this.name = name;
19 | this.age = age;
20 | }
21 |
22 | public User(int id, String name, int age) {
23 | this.id = id;
24 | this.name = name;
25 | this.age = age;
26 | }
27 |
28 | public int getId() {
29 | return id;
30 | }
31 |
32 | public void setId(int id) {
33 | this.id = id;
34 | }
35 |
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 |
44 | public int getAge() {
45 | return age;
46 | }
47 |
48 | public void setAge(int age) {
49 | this.age = age;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return "User{" +
55 | "id=" + this.getId() +
56 | ", name='" + name + '\'' +
57 | ", age=" + age +
58 | '}';
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/java/com/haiyu/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.mapper;
2 |
3 |
4 | import com.baomidou.mybatisplus.annotations.SqlParser;
5 | import com.baomidou.mybatisplus.mapper.BaseMapper;
6 | import com.baomidou.mybatisplus.plugins.pagination.Pagination;
7 |
8 | import com.haiyu.entity.User;
9 | import org.apache.ibatis.annotations.Select;
10 |
11 | import java.util.List;
12 |
13 |
14 | /**
15 | * Created by Administrator on 2018/5/16.
16 | */
17 | public interface UserMapper extends BaseMapper {
18 | int deleteAll();
19 |
20 | @SqlParser(filter = true)
21 | @Select("select id , name, age from user")
22 | List selectListBySQL();
23 |
24 | List selectUserList(Pagination page);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/java/com/haiyu/service/Impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service.Impl;
2 |
3 | import com.baomidou.mybatisplus.plugins.Page;
4 | import com.baomidou.mybatisplus.service.impl.ServiceImpl;
5 |
6 | import com.haiyu.entity.User;
7 | import com.haiyu.mapper.UserMapper;
8 | import com.haiyu.service.UserService;
9 | import org.springframework.stereotype.Service;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * Created by Administrator on 2018/5/16.
15 | */
16 | @Service
17 | public class UserServiceImpl extends ServiceImpl implements UserService {
18 |
19 |
20 | @Override
21 | public boolean deleteAll() {
22 | return retBool(baseMapper.deleteAll());
23 | }
24 |
25 | @Override
26 | public List selectListBySQL() {
27 | return baseMapper.selectListBySQL();
28 | }
29 |
30 | public Page selectUserPage(Page page) {
31 | // 不进行 count sql 优化,解决 MP 无法自动优化 SQL 问题
32 | // page.setOptimizeCountSql(false);
33 | // 不查询总记录数
34 | // page.setSearchCount(false);
35 |
36 | return page.setRecords(baseMapper.selectUserList(page));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/java/com/haiyu/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service;
2 |
3 | import com.baomidou.mybatisplus.plugins.Page;
4 | import com.baomidou.mybatisplus.service.IService;
5 | import com.haiyu.entity.User;
6 |
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Created by Administrator on 2018/5/16.
12 | */
13 | public interface UserService extends IService{
14 |
15 | boolean deleteAll();
16 |
17 | List selectListBySQL();
18 |
19 | Page selectUserPage(Page page);
20 | }
21 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | url: jdbc:mysql://127.0.0.1:3306/test
4 | data-username: root
5 | data-password: root
6 | driver-class-name: com.mysql.jdbc.Driver
7 |
8 |
9 | #mybatis
10 | mybatis-plus:
11 | # 如果是放在src/main/java目录下 classpath:/com/yourpackage/*/mapper/*Mapper.xml
12 | # 如果是放在resource目录 classpath:/mapper/*Mapper.xml
13 | mapper-locations: classpath:/mapper/*Mapper.xml
14 | global-config:
15 | #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
16 | id-type: 2
17 | #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
18 | field-strategy: 2
19 | #刷新mapper 调试神器
20 | refresh-mapper: true
21 | #逻辑删除配置(下面3个配置)
22 | logic-delete-value: 0
23 | logic-not-delete-value: 1
24 | sql-parser-cache: true
25 | configuration:
26 | #配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId)
27 | map-underscore-to-camel-case: true
28 | cache-enabled: false
29 |
30 |
31 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/main/resources/mapper/userMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | id , name, age
8 |
9 |
10 |
11 | DELETE FROM USER
12 |
13 |
16 |
17 |
--------------------------------------------------------------------------------
/springboot-mybatis-plus/src/test/java/com/haiyu/SpringbootMybatisPlusApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMybatisPlusApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/main/java/com/haiyu/SpringbootMycatMybatisPlusApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMycatMybatisPlusApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMycatMybatisPlusApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/main/java/com/haiyu/mapper/TravelrecordDao.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.mapper;
2 |
3 | import com.haiyu.entity.Travelrecord;
4 | import com.baomidou.mybatisplus.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author liuxing
12 | * @since 2018-09-01
13 | */
14 | public interface TravelrecordDao extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/main/java/com/haiyu/mapper/xml/TravelrecordMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/main/java/com/haiyu/service/TravelrecordService.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service;
2 |
3 | import com.haiyu.entity.Travelrecord;
4 | import com.baomidou.mybatisplus.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author liuxing
12 | * @since 2018-09-01
13 | */
14 | public interface TravelrecordService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/main/java/com/haiyu/service/impl/TravelrecordServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service.impl;
2 |
3 | import com.haiyu.entity.Travelrecord;
4 | import com.haiyu.mapper.TravelrecordDao;
5 | import com.haiyu.service.TravelrecordService;
6 | import com.baomidou.mybatisplus.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 服务实现类
12 | *
13 | *
14 | * @author liuxing
15 | * @since 2018-09-01
16 | */
17 | @Service
18 | public class TravelrecordServiceImpl extends ServiceImpl implements TravelrecordService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | druid:
4 | url: jdbc:mysql://192.168.0.184:8066/TESTDB?useUnicode=true&characterEncoding=utf-8&useSSL=false
5 | username: root
6 | password: 123456
7 | initial-size: 1
8 | min-idle: 1
9 | max-active: 20
10 | test-on-borrow: true
11 | driver-class-name: com.mysql.jdbc.Driver
12 |
13 | #mybatis
14 | mybatis-plus:
15 | mapper-locations: classpath:/mapper/*Mapper.xml
16 | global-config:
17 | id-type: 2
18 | field-strategy: 2
19 | refresh-mapper: true
20 | logic-delete-value: 0
21 | logic-not-delete-value: 1
22 | sql-parser-cache: true
23 | configuration:
24 | map-underscore-to-camel-case: true
25 | cache-enabled: false
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/main/resources/mapper/TravelrecordMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/springboot-mycat-mybatis-plus/src/test/java/com/haiyu/SpringbootMycatMybatisPlusApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMycatMybatisPlusApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-mycat/src/main/java/com/haiyu/SpringbootMycatApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @SpringBootApplication
8 | @MapperScan("com.haiyu.mapper")
9 | public class SpringbootMycatApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootMycatApplication.class, args);
13 | }
14 |
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/springboot-mycat/src/main/java/com/haiyu/mapper/TravelrecordMapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.mapper;
2 |
3 | import com.haiyu.entity.Travelrecord;
4 | import com.haiyu.utils.MyMapper;
5 | import org.apache.ibatis.annotations.Mapper;
6 | import org.springframework.stereotype.Repository;
7 |
8 | @Repository
9 | public interface TravelrecordMapper extends MyMapper {
10 | }
--------------------------------------------------------------------------------
/springboot-mycat/src/main/java/com/haiyu/service/TravelrecordService.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service;
2 |
3 | import com.haiyu.entity.Travelrecord;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @Title: TravelrecordService
9 | * @Description:
10 | * @author: youqing
11 | * @version: 1.0
12 | * @date: 2018/8/31 15:49
13 | */
14 | public interface TravelrecordService {
15 |
16 | List getList();
17 |
18 | int save(Travelrecord travelrecord);
19 |
20 | int deleteById(Long id);
21 | }
22 |
--------------------------------------------------------------------------------
/springboot-mycat/src/main/java/com/haiyu/service/impl/TravelrecordServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service.impl;
2 |
3 | import com.haiyu.entity.Travelrecord;
4 | import com.haiyu.mapper.TravelrecordMapper;
5 | import com.haiyu.service.TravelrecordService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * @Title: TravelrecordServiceImpl
13 | * @Description:
14 | * @author: youqing
15 | * @version: 1.0
16 | * @date: 2018/8/31 15:50
17 | */
18 | @Service
19 | public class TravelrecordServiceImpl implements TravelrecordService {
20 |
21 | @Autowired
22 | private TravelrecordMapper travelrecordMapper;
23 |
24 | @Override
25 | public List getList() {
26 | return travelrecordMapper.selectAll();
27 | }
28 |
29 | @Override
30 | public int save(Travelrecord travelrecord) {
31 | return travelrecordMapper.insert(travelrecord);
32 | }
33 |
34 | @Override
35 | public int deleteById(Long id) {
36 | return travelrecordMapper.deleteByPrimaryKey(id);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/springboot-mycat/src/main/java/com/haiyu/utils/MyMapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.utils;
2 |
3 | import tk.mybatis.mapper.common.Mapper;
4 | import tk.mybatis.mapper.common.MySqlMapper;
5 |
6 | /**
7 | * @Title: MyMapper
8 | * @Description:
9 | * @author: youqing
10 | * @version: 1.0
11 | * @date: 2018/8/31 15:40
12 | */
13 | public interface MyMapper extends Mapper,MySqlMapper {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/springboot-mycat/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | druid:
4 | url: jdbc:mysql://192.168.0.184:8066/TESTDB?useUnicode=true&characterEncoding=utf-8&useSSL=false
5 | username: root
6 | password: 123456
7 | initial-size: 1
8 | min-idle: 1
9 | max-active: 20
10 | test-on-borrow: true
11 | driver-class-name: com.mysql.jdbc.Driver
12 |
13 | #mybatis
14 | mybatis:
15 | type-aliases-package: com.haiyu.entity
16 | mapper-locations: classpath:mapper/*.xml
17 |
18 |
--------------------------------------------------------------------------------
/springboot-mycat/src/main/resources/generator/generatorConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
33 |
37 |
38 |
--------------------------------------------------------------------------------
/springboot-mycat/src/main/resources/mapper/TravelrecordMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/springboot-mycat/src/test/java/com/haiyu/SpringbootMycatApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMycatApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-mysql/src/main/java/com/haiyu/SpringbootMysqlApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMysqlApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMysqlApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-mysql/src/main/java/com/haiyu/config/MyBatisMapperScannerConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import org.mybatis.spring.mapper.MapperScannerConfigurer;
4 | import org.springframework.boot.autoconfigure.AutoConfigureAfter;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.context.annotation.Configuration;
7 |
8 | /**
9 | * @Title: MyBatisMapperScannerConfig
10 | * @Description:
11 | * @author: youqing
12 | * @version: 1.0
13 | * @date: 2018/9/5 16:18
14 | */
15 | @Configuration
16 | @AutoConfigureAfter(TableConfig.class)
17 | public class MyBatisMapperScannerConfig {
18 |
19 | @Bean
20 | public MapperScannerConfigurer mapperScannerConfigurer() throws Exception{
21 | MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
22 | mapperScannerConfigurer.setBasePackage("com.haiyu.mapper.*;com.gitee.sunchenbin.mybatis.actable.dao.*");
23 | mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
24 | return mapperScannerConfigurer;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/springboot-mysql/src/main/java/com/haiyu/entity/Test.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
4 | import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
5 | import com.gitee.sunchenbin.mybatis.actable.command.BaseModel;
6 | import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
7 | import lombok.Data;
8 |
9 | import java.util.Date;
10 |
11 | /**
12 | * @Title: Test
13 | * @Description:
14 | * @author: youqing
15 | * @version: 1.0
16 | * @date: 2018/9/5 16:20
17 | */
18 | @Table(name = "test")
19 | @Data
20 | public class Test extends BaseModel {
21 |
22 | private static final long serialVersionUID = 5199200306752426433L;
23 |
24 | @Column(name = "id",type = MySqlTypeConstant.INT,length = 11,isKey = true,isAutoIncrement = true)
25 | private Integer id;
26 |
27 | @Column(name = "name",type = MySqlTypeConstant.VARCHAR,length = 111)
28 | private String name;
29 |
30 | @Column(name = "description",type = MySqlTypeConstant.TEXT)
31 | private String description;
32 |
33 | @Column(name = "create_time",type = MySqlTypeConstant.DATETIME)
34 | private Date create_time;
35 |
36 | @Column(name = "update_time",type = MySqlTypeConstant.DATETIME)
37 | private Date update_time;
38 |
39 | @Column(name = "number",type = MySqlTypeConstant.BIGINT,length = 5)
40 | private Long number;
41 |
42 | @Column(name = "lifecycle",type = MySqlTypeConstant.CHAR,length = 1)
43 | private String lifecycle;
44 |
45 | @Column(name = "dekes",type = MySqlTypeConstant.DOUBLE,length = 5,decimalLength = 2)
46 | private Double dekes;
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/springboot-mysql/src/main/java/com/haiyu/mapper/TestMapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.mapper;
2 |
3 | import org.apache.ibatis.annotations.Mapper;
4 |
5 | /**
6 | * @Title: TestMapper
7 | * @Description:
8 | * @author: youqing
9 | * @version: 1.0
10 | * @date: 2018/9/5 16:49
11 | */
12 | @Mapper
13 | public interface TestMapper {
14 | }
15 |
--------------------------------------------------------------------------------
/springboot-mysql/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | mybatis.table.auto=update
2 | mybatis.model.pack=com.haiyu.entity
3 | mybatis.database.type=mysql
--------------------------------------------------------------------------------
/springboot-mysql/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | driver-class-name: com.mysql.jdbc.Driver
4 | url: jdbc:mysql://localhost:3306/db1?characterEncoding=utf8&useSSL=false&autoReconnect=true
5 | username: root
6 | password: root
--------------------------------------------------------------------------------
/springboot-mysql/src/test/java/com/haiyu/SpringbootMysqlApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMysqlApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-oauth2/src/main/java/com/haiyu/SpringbootOauth2Application.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootOauth2Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootOauth2Application.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-oauth2/src/main/java/com/haiyu/web/TestController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.web;
2 |
3 | import org.springframework.security.core.Authentication;
4 | import org.springframework.security.core.context.SecurityContextHolder;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 | import org.springframework.web.bind.annotation.PathVariable;
7 | import org.springframework.web.bind.annotation.RestController;
8 |
9 | /**
10 | * @Title: TestController
11 | * @Description:
12 | * @author: youqing
13 | * @version: 1.0
14 | * @date: 2018/9/2 16:06
15 | */
16 | @RestController
17 | public class TestController {
18 | @GetMapping("/product/{id}")
19 | public String getProduct(@PathVariable String id) {
20 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
21 | return "product id : " + id;
22 | }
23 |
24 | @GetMapping("/order/{id}")
25 | public String getOrder(@PathVariable String id) {
26 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
27 | return "order id : " + id;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/springboot-oauth2/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | redis:
3 | host: 47.98.104.146
4 | logging.level.org.springframework.security: DEBUG
--------------------------------------------------------------------------------
/springboot-oauth2/src/test/java/com/haiyu/SpringbootOauth2ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootOauth2ApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-qrcode/src/main/java/com/haiyu/SpringbootQrcodeApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootQrcodeApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootQrcodeApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-qrcode/src/main/java/com/haiyu/config/BeanConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.data.redis.connection.RedisConnectionFactory;
6 | import org.springframework.data.redis.core.StringRedisTemplate;
7 |
8 | /**
9 | * Created by Administrator on 2018/5/21.
10 | */
11 | @Configuration
12 | public class BeanConfig {
13 | @Bean
14 | public StringRedisTemplate template(RedisConnectionFactory connectionFactory) {
15 | return new StringRedisTemplate(connectionFactory);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/springboot-qrcode/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # session
2 | spring.session.store-type=redis
--------------------------------------------------------------------------------
/springboot-qrcode/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 二维码登录
6 |
7 |
8 | 二维码登录
9 |
10 |
11 | 注销
12 |
13 |
--------------------------------------------------------------------------------
/springboot-qrcode/src/test/java/com/haiyu/SpringbootQrcodeApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootQrcodeApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.1.RELEASE
9 |
10 |
11 | com.haiyu
12 | springboot-rabbitmq
13 | 0.0.1-SNAPSHOT
14 | springboot-rabbitmq
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-amqp
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-test
34 | test
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-maven-plugin
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/haiyu/SpringbootRabbitmqApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootRabbitmqApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootRabbitmqApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/haiyu/config/FanoutRabbitConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import org.springframework.amqp.core.Binding;
4 | import org.springframework.amqp.core.BindingBuilder;
5 | import org.springframework.amqp.core.FanoutExchange;
6 | import org.springframework.amqp.core.Queue;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 |
10 | /**
11 | * @Title: FanoutRabbitConfig
12 | * @Description:
13 | * @author: youqing
14 | * @version: 1.0
15 | * @date: 2019/1/3 19:18
16 | */
17 | @Configuration
18 | public class FanoutRabbitConfig {
19 | @Bean
20 | public Queue AMessage() {
21 | return new Queue("fanout.A");
22 | }
23 |
24 | @Bean
25 | public Queue BMessage() {
26 | return new Queue("fanout.B");
27 | }
28 |
29 | @Bean
30 | public Queue CMessage() {
31 | return new Queue("fanout.C");
32 | }
33 |
34 | @Bean
35 | FanoutExchange fanoutExchange() {
36 | return new FanoutExchange("fanoutExchange");
37 | }
38 |
39 | //A、B、C三个队列绑定到Fanout交换机上面
40 |
41 | @Bean
42 | Binding bindingExchangeA(Queue AMessage, FanoutExchange fanoutExchange) {
43 | return BindingBuilder.bind(AMessage).to(fanoutExchange);
44 | }
45 |
46 | @Bean
47 | Binding bindingExchangeB(Queue BMessage, FanoutExchange fanoutExchange) {
48 | return BindingBuilder.bind(BMessage).to(fanoutExchange);
49 | }
50 |
51 | @Bean
52 | Binding bindingExchangeC(Queue CMessage, FanoutExchange fanoutExchange) {
53 | return BindingBuilder.bind(CMessage).to(fanoutExchange);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/haiyu/config/RabbitConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import org.springframework.amqp.core.Queue;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | /**
8 | * @Title: RabbitConfig
9 | * @Description:
10 | * @author: youqing
11 | * @version: 1.0
12 | * @date: 2019/1/3 19:09
13 | */
14 | @Configuration
15 | public class RabbitConfig {
16 | @Bean
17 | public Queue Queue() {
18 | return new Queue("hello");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/haiyu/config/TopicRabbitConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import org.springframework.amqp.core.Binding;
4 | import org.springframework.amqp.core.BindingBuilder;
5 | import org.springframework.amqp.core.Queue;
6 | import org.springframework.amqp.core.TopicExchange;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 |
10 | /**
11 | * @Title: TopicRabbitConfig
12 | * @Description:
13 | * @author: youqing
14 | * @version: 1.0
15 | * @date: 2019/1/3 19:16
16 | */
17 | @Configuration
18 | public class TopicRabbitConfig {
19 | final static String message = "topic.message";
20 | final static String messages = "topic.messages";
21 |
22 | @Bean
23 | public Queue queueMessage() {
24 | return new Queue(TopicRabbitConfig.message);
25 | }
26 |
27 | @Bean
28 | public Queue queueMessages() {
29 | return new Queue(TopicRabbitConfig.messages);
30 | }
31 |
32 | @Bean
33 | TopicExchange exchange() {
34 | return new TopicExchange("exchange");
35 | }
36 |
37 | @Bean
38 | Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) {
39 | return BindingBuilder.bind(queueMessage).to(exchange).with("topic.message");
40 | }
41 |
42 | @Bean
43 | Binding bindingExchangeMessages(Queue queueMessages, TopicExchange exchange) {
44 | return BindingBuilder.bind(queueMessages).to(exchange).with("topic.#");
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/haiyu/receiver/HelloReceiver.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.receiver;
2 |
3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler;
4 | import org.springframework.amqp.rabbit.annotation.RabbitListener;
5 | import org.springframework.stereotype.Component;
6 |
7 | /**
8 | * @Title: HelloReceiver
9 | * @Description:
10 | * @author: youqing
11 | * @version: 1.0
12 | * @date: 2019/1/3 19:12
13 | */
14 | @Component
15 | @RabbitListener(queues = "hello")
16 | public class HelloReceiver {
17 | @RabbitHandler
18 | public void process(String hello) {
19 | System.out.println("Receiver1 : " + hello);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/haiyu/sender/HelloSender.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.sender;
2 |
3 | import org.springframework.amqp.core.AmqpTemplate;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Component;
6 |
7 | import java.util.Date;
8 |
9 | /**
10 | * @Title: HelloSender
11 | * @Description:
12 | * @author: youqing
13 | * @version: 1.0
14 | * @date: 2019/1/3 19:11
15 | */
16 | @Component
17 | public class HelloSender {
18 | @Autowired
19 | private AmqpTemplate rabbitTemplate;
20 |
21 | public void send(int i) {
22 | String context = "hello " + new Date()+"***********"+i;
23 | System.out.println("Sender1 : " + context);
24 | this.rabbitTemplate.convertAndSend("hello", context);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.rabbitmq.host=127.0.0.1
2 | spring.rabbitmq.port=5672
3 | spring.rabbitmq.username=guest
4 | spring.rabbitmq.password=guest
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/test/java/com/haiyu/SpringbootRabbitmqApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import com.haiyu.sender.HelloSender;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.amqp.core.AmqpTemplate;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 | import org.springframework.test.context.junit4.SpringRunner;
10 |
11 | @RunWith(SpringRunner.class)
12 | @SpringBootTest
13 | public class SpringbootRabbitmqApplicationTests {
14 |
15 | @Autowired
16 | private HelloSender helloSender1;
17 |
18 | @Autowired
19 | private HelloSender helloSender2;
20 |
21 | //一对一
22 | @Test
23 | public void hello() throws Exception {
24 | helloSender1.send(1);
25 | }
26 |
27 | //一对多
28 | @Test
29 | public void oneToMany() throws Exception {
30 | for (int i=0;i<100;i++){
31 | helloSender1.send(i);
32 | }
33 | }
34 |
35 | //多对多
36 | @Test
37 | public void manyToMany() throws Exception {
38 | for (int i=0;i<100;i++){
39 | helloSender1.send(i);
40 | helloSender2.send(i);
41 | }
42 | }
43 |
44 | @Autowired
45 | private AmqpTemplate rabbitTemplate;
46 |
47 | public void send() {
48 | String context = "hi, fanout msg ";
49 | System.out.println("Sender : " + context);
50 | this.rabbitTemplate.convertAndSend("fanoutExchange","", context);
51 | }
52 |
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/SpringbootSecurityApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import com.haiyu.config.SpringUtil;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.stereotype.Controller;
7 |
8 | @SpringBootApplication
9 | public class SpringbootSecurityApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootSecurityApplication.class, args);
13 |
14 | String[] controllers = SpringUtil.controllers(Controller.class);
15 | if(controllers != null) {
16 | for (String controllerBeanName : controllers) {
17 | System.out.println(controllerBeanName);
18 | }
19 | }
20 | System.out.println("Controller的数量:"+controllers.length);
21 | }
22 |
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/config/SpringUtil.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import org.springframework.beans.BeansException;
4 | import org.springframework.context.ApplicationContext;
5 | import org.springframework.context.ApplicationContextAware;
6 | import org.springframework.stereotype.Component;
7 | import org.springframework.stereotype.Controller;
8 |
9 | import java.lang.annotation.Annotation;
10 |
11 | /**
12 | * @Title: SpringUtil
13 | * @Description:
14 | * @author: youqing
15 | * @version: 1.0
16 | * @date: 2018/6/7 16:27
17 | */
18 | @Component
19 | public class SpringUtil implements ApplicationContextAware{
20 | private static ApplicationContext applicationContext = null;
21 |
22 | @Override
23 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
24 | if(SpringUtil.applicationContext == null){
25 | SpringUtil.applicationContext = applicationContext;
26 | }
27 | System.out.println("--------获取applicationContext----------");
28 | }
29 |
30 | //获取applicationContext
31 | public static ApplicationContext getApplicationContext() {
32 | return applicationContext;
33 | }
34 |
35 |
36 | public static String[] controllers(Class extends Annotation> clazz){
37 | return getApplicationContext().getBeanNamesForAnnotation(clazz);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/config/WebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.config;
2 |
3 | import org.springframework.context.annotation.Configuration;
4 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
6 |
7 | /**
8 | * @Title: WebMvcConfig
9 | * @Description:
10 | * @author: youqing
11 | * @version: 1.0
12 | * @date: 2018/6/6 18:01
13 | */
14 | @Configuration
15 | public class WebMvcConfig extends WebMvcConfigurerAdapter {
16 | @Override
17 | public void addViewControllers(ViewControllerRegistry registry) {
18 | registry.addViewController("/login").setViewName("login");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/controller/MainController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.controller;
2 |
3 | import com.haiyu.entity.Msg;
4 | import org.springframework.stereotype.Controller;
5 | import org.springframework.ui.Model;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RequestMethod;
8 |
9 | /**
10 | * @Title: MainController
11 | * @Description:
12 | * @author: youqing
13 | * @version: 1.0
14 | * @date: 2018/6/6 11:48
15 | */
16 | @Controller
17 | public class MainController {
18 |
19 | @RequestMapping("/")
20 | public String index(Model model) {
21 | Msg msg = new Msg("测试标题", "测试内容", "额外信息,只对管理员显示");
22 | model.addAttribute("msg", msg);
23 | return "index";
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/entity/Msg.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | /**
4 | * @Title: Msg
5 | * @Description:
6 | * @author: youqing
7 | * @version: 1.0
8 | * @date: 2018/6/6 18:01
9 | */
10 | public class Msg {
11 | private String title;
12 | private String content;
13 | private String extraInfo;
14 |
15 | public Msg() {
16 | }
17 |
18 | public String getTitle() {
19 | return title;
20 | }
21 |
22 | public void setTitle(String title) {
23 | this.title = title;
24 | }
25 |
26 | public String getContent() {
27 | return content;
28 | }
29 |
30 | public void setContent(String content) {
31 | this.content = content;
32 | }
33 |
34 | public String getExtraInfo() {
35 | return extraInfo;
36 | }
37 |
38 | public void setExtraInfo(String extraInfo) {
39 | this.extraInfo = extraInfo;
40 | }
41 |
42 | public Msg(String title, String content, String extraInfo) {
43 | this.title = title;
44 | this.content = content;
45 | this.extraInfo = extraInfo;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/entity/SysRole.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | /**
8 | * @Title: SysRole
9 | * @Description:
10 | * @author: youqing
11 | * @version: 1.0
12 | * @date: 2018/6/6 17:57
13 | */
14 | @Entity
15 | public class SysRole {
16 | @Id
17 | @GeneratedValue
18 | private Long id;
19 | private String name;
20 |
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public void setId(Long id) {
27 | this.id = id;
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | public void setName(String name) {
35 | this.name = name;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/repository/SysUserRepository.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.repository;
2 |
3 | import com.haiyu.entity.SysUser;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | /**
7 | * @Title: SysUserRepository
8 | * @Description:
9 | * @author: youqing
10 | * @version: 1.0
11 | * @date: 2018/6/6 18:00
12 | */
13 | public interface SysUserRepository extends JpaRepository {
14 | SysUser findByUsername(String username);
15 | }
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/haiyu/security/CustomUserService.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.security;
2 |
3 | import com.haiyu.entity.SysUser;
4 | import com.haiyu.repository.SysUserRepository;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.security.core.userdetails.UserDetails;
7 | import org.springframework.security.core.userdetails.UserDetailsService;
8 | import org.springframework.security.core.userdetails.UsernameNotFoundException;
9 | /**
10 | * @Title: CustomUserService
11 | * @Description:
12 | * @author: youqing
13 | * @version: 1.0
14 | * @date: 2018/6/6 14:39
15 | */
16 |
17 | public class CustomUserService implements UserDetailsService {
18 |
19 | @Autowired
20 | SysUserRepository userRepository;
21 | @Override
22 | public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
23 | SysUser user = userRepository.findByUsername(s);
24 | if (user == null) {
25 | throw new UsernameNotFoundException("用户名不存在");
26 | }
27 | System.out.println("s:"+s);
28 | System.out.println("username:"+user.getUsername()+";password:"+user.getPassword());
29 | return user;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/springboot-security/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost:3306/shiro
2 | spring.datasource.driverClassName=com.mysql.jdbc.Driver
3 | spring.datasource.username=root
4 | spring.datasource.password=root
5 |
6 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
7 |
8 | logging.level.org.springframework.security=info
9 | spring.thymeleaf.cache=false
10 | spring.jpa.hibernate.ddl-auto=update
11 | spring.jpa.show-sql=true
--------------------------------------------------------------------------------
/springboot-security/src/main/resources/static/css/signin.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 40px;
3 | padding-bottom: 40px;
4 | background-color: #eee;
5 | }
6 |
7 | .form-signin {
8 | max-width: 330px;
9 | padding: 15px;
10 | margin: 0 auto;
11 | }
12 | .form-signin .form-signin-heading,
13 | .form-signin .checkbox {
14 | margin-bottom: 10px;
15 | }
16 | .form-signin .checkbox {
17 | font-weight: normal;
18 | }
19 | .form-signin .form-control {
20 | position: relative;
21 | height: auto;
22 | -webkit-box-sizing: border-box;
23 | -moz-box-sizing: border-box;
24 | box-sizing: border-box;
25 | padding: 10px;
26 | font-size: 16px;
27 | }
28 | .form-signin .form-control:focus {
29 | z-index: 2;
30 | }
31 | .form-signin input[type="email"] {
32 | margin-bottom: -1px;
33 | border-bottom-right-radius: 0;
34 | border-bottom-left-radius: 0;
35 | }
36 | .form-signin input[type="password"] {
37 | margin-bottom: 10px;
38 | border-top-left-radius: 0;
39 | border-top-right-radius: 0;
40 | }
--------------------------------------------------------------------------------
/springboot-security/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
16 | index
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
29 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/springboot-security/src/main/resources/templates/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 | login
17 |
18 |
19 |
20 |
21 |
已注销
22 |
有错误,请重试
23 |
使用账号密码登录
24 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/springboot-security/src/test/java/com/haiyu/SpringbootSecurityApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootSecurityApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/SpringbootShiroApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @SpringBootApplication
8 | @MapperScan("com.haiyu.dao")
9 | public class SpringbootShiroApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootShiroApplication.class, args);
13 | }
14 |
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/controller/MainController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.controller;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 |
6 | /**
7 | * @author 林尤庆
8 | * @date 2018年3月22日 下午4:20:57
9 | * @version 1.0
10 | */
11 | @Controller
12 | @RequestMapping("/")
13 | public class MainController {
14 | @RequestMapping("/index")
15 | public String index(){
16 | return "index";
17 | }
18 |
19 | @RequestMapping("/toLogin")
20 | public String toLogin(){
21 | return "login";
22 | }
23 |
24 | @RequestMapping("/unAuth")
25 | public String unAuth(){
26 | return "unauth";
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/controller/ProductController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.controller;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 |
6 | /**
7 | * @author 林尤庆
8 | * @date 2018年3月22日 下午4:23:52
9 | * @version 1.0
10 | */
11 | @Controller
12 | @RequestMapping("/product")
13 | public class ProductController {
14 |
15 | @RequestMapping("/toAdd")
16 | public String toAdd(){
17 | return "product/add";
18 | }
19 |
20 | @RequestMapping("/toList")
21 | public String toList(){
22 | return "product/list";
23 | }
24 |
25 | @RequestMapping("/toUpdate")
26 | public String toUpdate(){
27 | return "product/update";
28 | }
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/dao/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.dao;
2 |
3 |
4 | import java.util.List;
5 |
6 | import com.haiyu.domain.User;
7 | import org.apache.ibatis.annotations.Mapper;
8 | import org.springframework.stereotype.Repository;
9 |
10 | /**
11 | * @author 林尤庆
12 | * @date 2018年3月23日 上午10:40:08
13 | * @version 1.0
14 | */
15 | @Mapper
16 | @Repository
17 | public interface UserMapper {
18 | /**
19 | * 根据用户名查询用户
20 | * @param name
21 | * @return
22 | */
23 | User findByName(String name);
24 |
25 | /**
26 | * 根据用户ID查询用户拥有的资源授权码
27 | */
28 | List findPermissionByUserId(Integer userId);
29 |
30 | /**
31 | * 更新用户密码的方法
32 | */
33 | void updatePassword(User user);
34 | }
35 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/domain/User.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.domain;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * @author 林尤庆
7 | * @date 2018年3月22日 下午5:01:20
8 | * @version 1.0
9 | */
10 | public class User implements Serializable{
11 | /**
12 | *
13 | */
14 | private static final long serialVersionUID = 1L;
15 | private Integer id;
16 | private String name;
17 | private String password;
18 | /**
19 | * @return the id
20 | */
21 | public Integer getId() {
22 | return id;
23 | }
24 | /**
25 | * @param id the id to set
26 | */
27 | public void setId(Integer id) {
28 | this.id = id;
29 | }
30 | /**
31 | * @return the name
32 | */
33 | public String getName() {
34 | return name;
35 | }
36 | /**
37 | * @param name the name to set
38 | */
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 | /**
43 | * @return the password
44 | */
45 | public String getPassword() {
46 | return password;
47 | }
48 | /**
49 | * @param password the password to set
50 | */
51 | public void setPassword(String password) {
52 | this.password = password;
53 | }
54 | @Override
55 | public String toString() {
56 | return "User [id=" + id + ", name=" + name + ", password=" + password + "]";
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/filter/UserFormAuthenticationFilter.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.filter;
2 |
3 | import com.shiro.domain.User;
4 | import org.apache.shiro.session.Session;
5 | import org.apache.shiro.subject.Subject;
6 | import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
7 |
8 | import javax.servlet.ServletRequest;
9 | import javax.servlet.ServletResponse;
10 |
11 | /**
12 | * @Title: UserFormAuthenticationFilter2
13 | * @Description:
14 | * @author: youqing
15 | * @version: 1.0
16 | * @date: 2018/5/24 18:35
17 | */
18 | public class UserFormAuthenticationFilter extends FormAuthenticationFilter {
19 |
20 | @Override
21 | protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
22 | Subject subject = getSubject(request, response);
23 |
24 | // 如果 isAuthenticated 为 false 证明不是登录过的,同时 isRememberd 为true
25 | // 证明是没登陆直接通过记住我功能进来的
26 | if (!subject.isAuthenticated() && subject.isRemembered()) {
27 |
28 | // 获取session看看是不是空的
29 | Session session = subject.getSession(true);
30 |
31 | // 查看session属性当前是否是空的
32 | if (session.getAttribute("userName") == null) {
33 | // 如果是空的才初始化
34 | User dbUser = (User)subject.getPrincipal();
35 | //存入用户数据
36 | session.setAttribute("userName", dbUser.getName());
37 | }
38 | }
39 |
40 | // 这个方法本来只返回 subject.isAuthenticated() 现在我们加上 subject.isRemembered()
41 | // 让它同时也兼容remember这种情况
42 | return subject.isAuthenticated() || subject.isRemembered();
43 | }
44 | }
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service;
2 |
3 | import java.util.List;
4 |
5 | import com.haiyu.domain.User;
6 |
7 | /**
8 | * @author 林尤庆
9 | * @date 2018年3月23日 上午11:14:42
10 | * @version 1.0
11 | */
12 | public interface UserService {
13 | User findByName(String name);
14 |
15 | List findPermissionByUserId(Integer userId);
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/service/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service.impl;
2 |
3 | import java.util.List;
4 | import com.haiyu.dao.UserMapper;
5 | import com.haiyu.domain.User;
6 | import com.haiyu.service.UserService;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 | import org.springframework.transaction.annotation.Transactional;
10 |
11 |
12 | /**
13 | * @author 林尤庆
14 | * @date 2018年3月23日 上午11:16:07
15 | * @version 1.0
16 | */
17 | @Service
18 | @Transactional
19 | public class UserServiceImpl implements UserService {
20 |
21 | @Autowired
22 | private UserMapper userMapper;
23 |
24 | public User findByName(String name) {
25 | return userMapper.findByName(name);
26 | }
27 |
28 | public List findPermissionByUserId(Integer userId) {
29 |
30 | return userMapper.findPermissionByUserId(userId);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/java/com/haiyu/shiro/KaptcharConfig.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.shiro;
2 |
3 |
4 | import java.util.Properties;
5 |
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.google.code.kaptcha.impl.DefaultKaptcha;
10 | import com.google.code.kaptcha.util.Config;
11 |
12 | /**
13 | * @author 林尤庆
14 | * @date 2018年3月23日 下午4:20:37
15 | * @version 1.0
16 | */
17 | @Component
18 | public class KaptcharConfig {
19 |
20 | @Bean
21 | public DefaultKaptcha getDefaultKaptcha() {
22 | DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
23 | Properties properties = new Properties();
24 | properties.setProperty("kaptcha.border", "yes");
25 | properties.setProperty("kaptcha.border.color", "105,179,90");
26 | properties.setProperty("kaptcha.textproducer.font.color", "blue");
27 | properties.setProperty("kaptcha.image.width", "110");
28 | properties.setProperty("kaptcha.image.height", "40");
29 | properties.setProperty("kaptcha.textproducer.font.size", "30");
30 | properties.setProperty("kaptcha.session.key", "code");
31 | properties.setProperty("kaptcha.textproducer.char.length", "4");
32 | properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
33 | Config config = new Config(properties);
34 | defaultKaptcha.setConfig(config);
35 |
36 | return defaultKaptcha;
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:mysql://localhost:3306/shiro
2 | spring.datasource.driverClassName=com.mysql.jdbc.Driver
3 | spring.datasource.username=root
4 | spring.datasource.password=root
5 |
6 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
7 |
8 | mybatis.type-aliases-package=com.haiyu.domain
9 | mybatis.mapper-locations=classpath:mapper/*.xml
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
24 |
25 |
26 | update shiro.t_user
27 | set password = #{password}
28 | where id = #{id}
29 |
30 |
31 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 商品管理系统后台主页
6 |
7 |
8 | 商品管理系统后台主页
9 |
10 | 当前用户名:,注销
11 |
12 |
13 |
14 | 商品添加
15 |
16 |
17 | 商品修改
18 |
19 |
20 | 商品列表
21 |
22 |
23 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/templates/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 登录页面
6 |
7 |
8 | 用户登录
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/templates/product/add.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 商品添加
6 |
7 |
8 | 商品添加
9 |
10 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/templates/product/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 商品列表
6 |
7 |
8 | 商品列表
9 |
10 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/templates/product/update.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 商品修改
6 |
7 |
8 | 商品修改
9 |
10 |
--------------------------------------------------------------------------------
/springboot-shiro/src/main/resources/templates/unauth.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 未授权提示页面
6 |
7 |
8 | 亲,你没有权限访问此页面
9 |
10 |
--------------------------------------------------------------------------------
/springboot-shiro/src/test/java/com/haiyu/SpringbootShiroApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootShiroApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-solr/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | data:
3 | solr:
4 | host: http://192.168.0.197:8983/solr/ik_core
5 |
--------------------------------------------------------------------------------
/springboot-solr/src/test/java/com/haiyu/SpringbootSolrApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootSolrApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/java/com/haiyu/SpringbootSpringbatchApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootSpringbatchApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootSpringbatchApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/java/com/haiyu/batch/CsvBeanValidator.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.batch;
2 |
3 | import org.springframework.batch.item.validator.ValidationException;
4 | import org.springframework.batch.item.validator.Validator;
5 | import org.springframework.beans.factory.InitializingBean;
6 |
7 | import javax.validation.ConstraintViolation;
8 | import javax.validation.Validation;
9 | import javax.validation.ValidatorFactory;
10 | import java.util.Set;
11 |
12 |
13 | /**
14 | * Created by Administrator on 2018/5/20.
15 | */
16 | public class CsvBeanValidator implements Validator,InitializingBean{
17 |
18 | private javax.validation.Validator validator;
19 |
20 | @Override
21 | public void validate(T value) throws ValidationException {
22 | /**
23 | * 使用Validator的validate方法校验数据
24 | */
25 | Set> constraintViolations =
26 | validator.validate(value);
27 | if (constraintViolations.size() > 0) {
28 | StringBuilder message = new StringBuilder();
29 | for (ConstraintViolation constraintViolation : constraintViolations) {
30 | message.append(constraintViolation.getMessage() + "\n");
31 | }
32 | throw new ValidationException(message.toString());
33 | }
34 | }
35 |
36 | /**
37 | * 使用JSR-303的Validator来校验我们的数据,在此进行JSR-303的Validator的初始化
38 | * @throws Exception
39 | */
40 | @Override
41 | public void afterPropertiesSet() throws Exception {
42 | ValidatorFactory validatorFactory =
43 | Validation.buildDefaultValidatorFactory();
44 | validator = validatorFactory.usingContext().getValidator();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/java/com/haiyu/batch/CsvItemProcessor.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.batch;
2 |
3 | import com.haiyu.entity.Person;
4 | import org.springframework.batch.item.validator.ValidatingItemProcessor;
5 | import org.springframework.batch.item.validator.ValidationException;
6 |
7 | /**
8 | * Created by Administrator on 2018/5/20.
9 | */
10 | public class CsvItemProcessor extends ValidatingItemProcessor {
11 | @Override
12 | public Person process(Person item) throws ValidationException {
13 | /**
14 | * 需要执行super.process(item)才会调用自定义校验器
15 | */
16 | super.process(item);
17 | /**
18 | * 对数据进行简单的处理,若民族为汉族,则数据转换为01,其余转换为02
19 | */
20 | if (item.getNation().equals("汉族")) {
21 | item.setNation("01");
22 | } else {
23 | item.setNation("02");
24 | }
25 | return item;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/java/com/haiyu/batch/CsvJobListener.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.batch;
2 |
3 | import org.springframework.batch.core.JobExecution;
4 | import org.springframework.batch.core.JobExecutionListener;
5 |
6 | /**
7 | * Created by Administrator on 2018/5/20.
8 | */
9 | public class CsvJobListener implements JobExecutionListener {
10 | private long startTime;
11 | private long endTime;
12 | @Override
13 | public void beforeJob(JobExecution jobExecution) {
14 | startTime = System.currentTimeMillis();
15 | System.out.println("任务处理开始");
16 | }
17 |
18 | @Override
19 | public void afterJob(JobExecution jobExecution) {
20 | endTime = System.currentTimeMillis();
21 | System.out.println("任务处理结束");
22 | System.out.println("耗时:"+(endTime-startTime)+"ms");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/java/com/haiyu/controller/TestController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.controller;
2 |
3 | import org.springframework.batch.core.Job;
4 | import org.springframework.batch.core.JobParameters;
5 | import org.springframework.batch.core.JobParametersBuilder;
6 | import org.springframework.batch.core.launch.JobLauncher;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import java.text.SimpleDateFormat;
12 |
13 | /**
14 | * Created by Administrator on 2018/5/20.
15 | */
16 | @RestController
17 | public class TestController {
18 | @Autowired
19 | private JobLauncher jobLauncher;
20 | @Autowired
21 | private Job importJob;
22 | public JobParameters jobParameters;
23 |
24 | @RequestMapping("/imp")
25 | public String imp ()throws Exception{
26 | String fileName = "person";
27 | String path = fileName+".csv";
28 | SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS");
29 | String date =df.format(System.currentTimeMillis());
30 | jobParameters = new JobParametersBuilder()
31 | .addString("time",date)
32 | .addString("input.file.name",path)
33 | .toJobParameters();
34 | jobLauncher.run(importJob, jobParameters);
35 | return "ok";
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/java/com/haiyu/entity/Person.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | import javax.validation.constraints.Size;
4 |
5 | /**
6 | * Created by Administrator on 2018/5/20.
7 | */
8 | public class Person {
9 | /**
10 | * 使用JSR-303注解来校验数据
11 | */
12 | //@Size(max = 5,min = 2)
13 | private String name;
14 | private int age;
15 | private String nation;
16 | private String address;
17 |
18 | public String getName() {
19 | return name;
20 | }
21 |
22 | public void setName(String name) {
23 | this.name = name;
24 | }
25 |
26 | public int getAge() {
27 | return age;
28 | }
29 |
30 | public void setAge(int age) {
31 | this.age = age;
32 | }
33 |
34 | public String getNation() {
35 | return nation;
36 | }
37 |
38 | public void setNation(String nation) {
39 | this.nation = nation;
40 | }
41 |
42 | public String getAddress() {
43 | return address;
44 | }
45 |
46 | public void setAddress(String address) {
47 | this.address = address;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/java/com/haiyu/service/ScheduledTaskService.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.service;
2 |
3 | import org.springframework.batch.core.Job;
4 | import org.springframework.batch.core.JobParameters;
5 | import org.springframework.batch.core.JobParametersBuilder;
6 | import org.springframework.batch.core.launch.JobLauncher;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.scheduling.annotation.Scheduled;
9 | import org.springframework.stereotype.Service;
10 |
11 | import java.text.SimpleDateFormat;
12 |
13 | /**
14 | * Created by Administrator on 2018/5/20.
15 | */
16 | @Service
17 | public class ScheduledTaskService {
18 | @Autowired
19 | JobLauncher jobLauncher;
20 | @Autowired
21 | Job importJob;
22 | public JobParameters jobParameters;
23 | @Scheduled(fixedRate = 5000)
24 | public void execute()throws Exception{
25 | SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS");
26 | String date =df.format(System.currentTimeMillis());
27 | jobParameters = new JobParametersBuilder()
28 | .addString("time",date)
29 | .toJobParameters();
30 | jobLauncher.run(importJob, jobParameters);
31 | }
32 | }
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | driver-class-name: com.mysql.jdbc.Driver
4 | url: jdbc:mysql://127.0.0.1:3306/basedb
5 | username: root
6 | password: root
7 |
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/resources/person.csv:
--------------------------------------------------------------------------------
1 | jack1,18,汉族,北京
2 | jack2,19,汉族,上海
3 | jack3,20,非汉族,广州
4 | jack4,21,非汉族,深圳
5 | jack5,22,汉族,长沙
--------------------------------------------------------------------------------
/springboot-springbatch/src/main/resources/person.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE person(
2 | id int PRIMARY KEY AUTO_INCREMENT,
3 | name VARCHAR(20),
4 | age int,
5 | nation VARCHAR(20),
6 | address VARCHAR(20)
7 | );
--------------------------------------------------------------------------------
/springboot-springbatch/src/test/java/com/haiyu/SpringbootSpringbatchApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootSpringbatchApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-webflux/helloworld/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.1.RELEASE
9 |
10 |
11 | com.haiyu
12 | helloworld
13 | 0.0.1-SNAPSHOT
14 | helloworld
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-webflux
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-test
29 | test
30 |
31 |
32 |
33 |
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-maven-plugin
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/springboot-webflux/helloworld/src/main/java/com/haiyu/Handler/WorldHandler.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.Handler;
2 |
3 | import org.springframework.http.MediaType;
4 | import org.springframework.stereotype.Component;
5 | import org.springframework.web.reactive.function.BodyInserters;
6 | import org.springframework.web.reactive.function.server.ServerRequest;
7 | import org.springframework.web.reactive.function.server.ServerResponse;
8 | import reactor.core.publisher.Mono;
9 |
10 | /**
11 | * @Title: WorldHandler
12 | * @Description: 处理器类WorldHandler
13 | * @author: youing
14 | * @version: 1.0
15 | * @date: 2018/7/6 16:19
16 | */
17 | @Component
18 | public class WorldHandler {
19 |
20 | /***
21 | * ServerResponse 是对响应的封装,可以设置响应状态,响应头,响应正文。
22 | * 比如 ok 代表的是 200 响应码
23 | * MediaType 枚举是代表这文本内容类型
24 | * 返回的是 String 的对象。
25 | * 这里用 Mono 作为返回对象,是因为返回包含了一个 ServerResponse 对象,而不是多个元素。
26 | */
27 | public Mono helloWorld(ServerRequest request) {
28 | return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN)
29 | .body(BodyInserters.fromObject("Hello World!!!"));
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/springboot-webflux/helloworld/src/main/java/com/haiyu/HelloworldApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class HelloworldApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(HelloworldApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-webflux/helloworld/src/main/java/com/haiyu/router/WorldRouter.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.router;
2 |
3 | import com.haiyu.Handler.WorldHandler;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.http.MediaType;
7 | import org.springframework.web.reactive.function.server.RequestPredicates;
8 | import org.springframework.web.reactive.function.server.RouterFunction;
9 | import org.springframework.web.reactive.function.server.RouterFunctions;
10 | import org.springframework.web.reactive.function.server.ServerResponse;
11 |
12 | /**
13 | * @Title: WorldRouter
14 | * @Description: 路由器类 WorldRouter
15 | * @athor: youqing
16 | * @version: 1.0
17 | * @date: 2018/7/6 16:23
18 | */
19 | @Configuration
20 | public class WorldRouter {
21 |
22 | /***
23 | * RouterFunctions 对请求路由处理类,即将请求路由到处理器。
24 | * 这里将一个 GET 请求 /hello 路由到处理器 worldHandler 的 helloWorld 方法上(跟 Spring MVC 模式下的 HandleMapping 的作用类似)。
25 | * RouterFunctions.route(RequestPredicate, HandlerFunction) 方法,对应的入参是请求参数和处理函数,如果请求匹配,就调用对应的处理器函数。
26 | */
27 | @Bean
28 | public RouterFunction routWorld(WorldHandler worldHandler) {
29 | return RouterFunctions
30 | .route(RequestPredicates.GET("/hello")
31 | .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
32 | worldHandler::helloWorld);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/springboot-webflux/helloworld/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Radom7/springboot/5c12b4e516c02cd38d2b24dddd3920f7f2e56ffd/springboot-webflux/helloworld/src/main/resources/application.properties
--------------------------------------------------------------------------------
/springboot-webflux/helloworld/src/test/java/com/haiyu/HelloworldApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class HelloworldApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.1.RELEASE
9 |
10 |
11 | com.haiyu
12 | httpjson
13 | 0.0.1-SNAPSHOT
14 | httpjson
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-webflux
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-test
31 | test
32 |
33 |
34 |
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-maven-plugin
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/src/main/java/com/haiyu/Handler/PersonHandler.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.Handler;
2 |
3 | import com.haiyu.dao.PersonRepository;
4 | import com.haiyu.entity.Person;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Component;
7 | import reactor.core.publisher.Flux;
8 | import reactor.core.publisher.Mono;
9 |
10 | /**
11 | * @Title: PersonHandler
12 | * @Description:
13 | * @author: youqing
14 | * @version: 1.0
15 | * @date: 2018/7/6 17:06
16 | */
17 | @Component
18 | public class PersonHandler {
19 | private final PersonRepository personHandler;
20 |
21 | @Autowired
22 | public PersonHandler(PersonRepository personHandler) {
23 | this.personHandler = personHandler;
24 | }
25 |
26 | public Mono save(Person person) {
27 | return Mono.create(personMonoSink -> personMonoSink.success(personHandler.save(person)));
28 | }
29 |
30 | public Mono findPersonById(Long id) {
31 | return Mono.justOrEmpty(personHandler.findPersonById(id));
32 | }
33 |
34 | public Flux findAllPerson() {
35 | return Flux.fromIterable(personHandler.findAll());
36 | }
37 |
38 | public Mono updatePerson(Person person) {
39 | return Mono.create(personMonoSink -> personMonoSink.success(personHandler.updatePerson(person)));
40 | }
41 |
42 | public Mono deletePerson(Long id) {
43 | return Mono.create(personMonoSink -> personMonoSink.success(personHandler.deletePerson(id)));
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/src/main/java/com/haiyu/HttpjsonApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class HttpjsonApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(HttpjsonApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/src/main/java/com/haiyu/controller/PersonWebFluxController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.controller;
2 |
3 | import com.haiyu.Handler.PersonHandler;
4 | import com.haiyu.entity.Person;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Controller;
7 | import org.springframework.web.bind.annotation.*;
8 | import reactor.core.publisher.Flux;
9 | import reactor.core.publisher.Mono;
10 |
11 | /**
12 | * @Title: PersonWebFluxController
13 | * @Description:
14 | * @author: youqing
15 | * @version: 1.0
16 | * @date: 2018/7/6 17:32
17 | */
18 | @RestController
19 | @RequestMapping(value = "/person")
20 | public class PersonWebFluxController {
21 | @Autowired
22 | private PersonHandler personHandler;
23 |
24 | @GetMapping(value = "/{id}")
25 | public Mono findPersonById(@PathVariable("id") Long id) {
26 | return personHandler.findPersonById(id);
27 | }
28 |
29 | @GetMapping("findAll")
30 | public Flux findAllPerson() {
31 | return personHandler.findAllPerson();
32 | }
33 |
34 | @PostMapping("save")
35 | public Mono save(@RequestBody Person person) {
36 | return personHandler.save(person);
37 | }
38 |
39 | @PutMapping("update")
40 | public Mono updatePerson(@RequestBody Person person) {
41 | return personHandler.updatePerson(person);
42 | }
43 |
44 | @DeleteMapping(value = "delete/{id}")
45 | public Mono deletePerson(@PathVariable("id") Long id) {
46 | return personHandler.deletePerson(id);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/src/main/java/com/haiyu/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.dao;
2 |
3 | import com.haiyu.entity.Person;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import java.util.Collection;
7 | import java.util.concurrent.ConcurrentHashMap;
8 | import java.util.concurrent.ConcurrentMap;
9 | import java.util.concurrent.atomic.AtomicLong;
10 |
11 | /**
12 | * @Title: PersonRepository
13 | * @Description:
14 | * @author: youqing
15 | * @version: 1.0
16 | * @date: 2018/7/6 17:03
17 | */
18 | @Repository
19 | public class PersonRepository {
20 | private ConcurrentMap repository = new ConcurrentHashMap<>();
21 |
22 | private static final AtomicLong idGenerator = new AtomicLong(0);
23 |
24 | public Long save(Person person) {
25 | Long id = idGenerator.incrementAndGet();
26 | person.setId(id);
27 | repository.put(id, person);
28 | return id;
29 | }
30 |
31 | public Collection findAll() {
32 | return repository.values();
33 | }
34 |
35 |
36 | public Person findPersonById(Long id) {
37 | return repository.get(id);
38 | }
39 |
40 | public Long updatePerson(Person person) {
41 | repository.put(person.getId(), person);
42 | return person.getId();
43 | }
44 |
45 | public Long deletePerson(Long id) {
46 | repository.remove(id);
47 | return id;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/src/main/java/com/haiyu/entity/Person.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | /**
4 | * @Title: Person
5 | * @Description: 实体类
6 | * @author: youqing
7 | * @version: 1.0
8 | * @date: 2018/7/6 16:58
9 | */
10 | public class Person {
11 | private Long id;
12 | private String name;
13 | private Integer age;
14 |
15 | public Long getId() {
16 | return id;
17 | }
18 |
19 | public void setId(Long id) {
20 | this.id = id;
21 | }
22 |
23 | public String getName() {
24 | return name;
25 | }
26 |
27 | public void setName(String name) {
28 | this.name = name;
29 | }
30 |
31 | public Integer getAge() {
32 | return age;
33 | }
34 |
35 | public void setAge(Integer age) {
36 | this.age = age;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Radom7/springboot/5c12b4e516c02cd38d2b24dddd3920f7f2e56ffd/springboot-webflux/httpjson/src/main/resources/application.properties
--------------------------------------------------------------------------------
/springboot-webflux/httpjson/src/test/java/com/haiyu/HttpjsonApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class HttpjsonApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-webflux/mongodb/src/main/java/com/haiyu/MongodbApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class MongodbApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(MongodbApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-webflux/mongodb/src/main/java/com/haiyu/dao/PersonRepository.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.dao;
2 |
3 | import com.haiyu.entity.Person;
4 | import org.springframework.context.annotation.Primary;
5 | import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
6 | import org.springframework.stereotype.Repository;
7 |
8 | /**
9 | * @Title: PersonRepository
10 | * @Description:
11 | * @author: youqing
12 | * @version: 1.0
13 | * @date: 2018/7/25 17:26
14 | */
15 | @Repository
16 | @Primary
17 | public interface PersonRepository extends ReactiveMongoRepository {
18 | }
19 |
--------------------------------------------------------------------------------
/springboot-webflux/mongodb/src/main/java/com/haiyu/entity/Person.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import org.springframework.data.annotation.Id;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * @Title: Person
12 | * @Description:
13 | * @author: youqing
14 | * @version: 1.0
15 | * @date: 2018/7/25 17:23
16 | */
17 | @Data
18 | @AllArgsConstructor
19 | @NoArgsConstructor
20 | public class Person implements Serializable {
21 | @Id
22 | private Long id;
23 |
24 | private String name;
25 |
26 | public Long getId() {
27 | return id;
28 | }
29 |
30 | public void setId(Long id) {
31 | this.id = id;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "Person{" +
45 | "id='" + id + '\'' +
46 | ", name='" + name + '\'' +
47 | '}';
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/springboot-webflux/mongodb/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | redis:
3 | host: 192.168.0.139
4 | port: 6379
5 | timeout: 5000
6 | data:
7 | mongodb:
8 | host: 192.168.0.139
9 | port: 27017
--------------------------------------------------------------------------------
/springboot-webflux/mongodb/src/test/java/com/haiyu/MongodbApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class MongodbApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-webflux/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.1.RELEASE
9 |
10 |
11 | com.haiyu
12 | springboot-webflux
13 | 0.0.1-SNAPSHOT
14 | springboot-webflux
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-test
30 | test
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-maven-plugin
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/java/com/haiyu/SpringbootWpayApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootWpayApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootWpayApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/java/com/haiyu/entity/SignInfo.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.entity;
2 |
3 | import com.thoughtworks.xstream.annotations.XStreamAlias;
4 |
5 | /**
6 | * @Title: SignInfo
7 | * @Description: 签名信息
8 | * @author: youqing
9 | * @version: 1.0
10 | * @date: 2018/6/5 11:44
11 | */
12 | public class SignInfo {
13 | private String appId;//小程序ID
14 | private String timeStamp;//时间戳
15 | private String nonceStr;//随机串
16 | @XStreamAlias("package")
17 | private String repay_id;
18 | private String signType;//签名方式
19 |
20 | public String getAppId() {
21 | return appId;
22 | }
23 | public void setAppId(String appId) {
24 | this.appId = appId;
25 | }
26 | public String getTimeStamp() {
27 | return timeStamp;
28 | }
29 | public void setTimeStamp(String timeStamp) {
30 | this.timeStamp = timeStamp;
31 | }
32 | public String getNonceStr() {
33 | return nonceStr;
34 | }
35 | public void setNonceStr(String nonceStr) {
36 | this.nonceStr = nonceStr;
37 | }
38 | public String getRepay_id() {
39 | return repay_id;
40 | }
41 | public void setRepay_id(String repay_id) {
42 | this.repay_id = repay_id;
43 | }
44 | public String getSignType() {
45 | return signType;
46 | }
47 | public void setSignType(String signType) {
48 | this.signType = signType;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/java/com/haiyu/utils/Configure.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.utils;
2 |
3 | /**
4 | * @Title: Configure
5 | * @Description:
6 | * @author: youqing
7 | * @version: 1.0
8 | * @date: 2018/6/5 11:34
9 | */
10 | public class Configure {
11 | private static String key = "022ad1995704907f0db176d84126bab7";
12 |
13 | //小程序ID
14 | private static String appID = "wx2537437d11cdec0b";
15 | //商户号
16 | private static String mch_id = "1381483602";
17 | //
18 | private static String secret = "022ad1995704907f0db176d84126bab7";
19 |
20 | public static String getSecret() {
21 | return secret;
22 | }
23 |
24 | public static void setSecret(String secret) {
25 | Configure.secret = secret;
26 | }
27 |
28 | public static String getKey() {
29 | return key;
30 | }
31 |
32 | public static void setKey(String key) {
33 | Configure.key = key;
34 | }
35 |
36 | public static String getAppID() {
37 | return appID;
38 | }
39 |
40 | public static void setAppID(String appID) {
41 | Configure.appID = appID;
42 | }
43 |
44 | public static String getMch_id() {
45 | return mch_id;
46 | }
47 |
48 | public static void setMch_id(String mch_id) {
49 | Configure.mch_id = mch_id;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/java/com/haiyu/utils/MyX509TrustManager.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.utils;
2 |
3 | import java.security.cert.CertificateException;
4 | import java.security.cert.X509Certificate;
5 |
6 | import javax.net.ssl.X509TrustManager;
7 |
8 | /**
9 | *
10 | * 功能描述:自定义证书管理器,信任所有证书
11 | *
12 | * @param:
13 | * @return:
14 | * @auther: youqing
15 | * @date: 2018/6/5 11:32
16 | */
17 | public class MyX509TrustManager implements X509TrustManager {
18 |
19 | public void checkClientTrusted(X509Certificate[] arg0, String arg1)
20 | throws CertificateException {
21 | // TODO Auto-generated method stub
22 |
23 | }
24 |
25 | public void checkServerTrusted(X509Certificate[] arg0, String arg1)
26 | throws CertificateException {
27 | // TODO Auto-generated method stub
28 |
29 | }
30 |
31 | public X509Certificate[] getAcceptedIssuers() {
32 | // TODO Auto-generated method stub
33 | return null;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/java/com/haiyu/utils/StreamUtil.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.utils;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.InputStream;
5 |
6 | /**
7 | * @Title: StreamUtil
8 | * @Description:
9 | * @author: youqing
10 | * @version: 1.0
11 | * @date: 2018/6/5 11:41
12 | */
13 | public class StreamUtil {
14 | public static String read(InputStream is){
15 | try {
16 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
17 | int len = 0;
18 | byte[] buffer = new byte[512];
19 | while((len = is.read(buffer)) != -1){
20 | baos.write(buffer, 0, len);
21 | }
22 | return new String(baos.toByteArray(), 0, baos.size(), "utf-8");
23 | }catch (Exception e) {
24 | // TODO Auto-generated catch block
25 | e.printStackTrace();
26 | }
27 | return "";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/java/com/haiyu/utils/Util.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.utils;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 | import java.util.Random;
6 |
7 | /**
8 | * @author 林尤庆
9 | * @date 2018年3月31日 下午5:17:42
10 | * @version 1.0
11 | */
12 | public class Util {
13 | public static String getRandomString(int length) {
14 | Random random = new Random();
15 |
16 | StringBuffer sb = new StringBuffer();
17 |
18 | for (int i = 0; i < length; ++i) {
19 | int number = random.nextInt(3);
20 | long result = 0;
21 | switch (number) {
22 | case 0:
23 | result = Math.round(Math.random() * 25 + 65);
24 | sb.append(String.valueOf((char) result));
25 | break;
26 | case 1:
27 | result = Math.round(Math.random() * 25 + 97);
28 | sb.append(String.valueOf((char) result));
29 | break;
30 | case 2:
31 | sb.append(String.valueOf(new Random().nextInt(10)));
32 | break;
33 | }
34 | }
35 |
36 | return sb.toString();
37 | }
38 |
39 | public static String getCurrTime() {
40 | Date now = new Date();
41 | SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
42 | String s = outFormat.format(now);
43 | return s;
44 | }
45 |
46 | /**
47 | * 获取一定长度的随机字符串
48 | * @param length 指定字符串长度
49 | * @return 一定长度的字符串
50 | */
51 | public static String getRandomStringByLength(int length) {
52 | String base = "abcdefghijklmnopqrstuvwxyz0123456789";
53 | Random random = new Random();
54 | StringBuffer sb = new StringBuffer();
55 | for (int i = 0; i < length; i++) {
56 | int number = random.nextInt(base.length());
57 | sb.append(base.charAt(number));
58 | }
59 | return sb.toString();
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/java/com/haiyu/utils/XSteram.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.utils;
2 |
3 | import java.io.Writer;
4 |
5 | import com.thoughtworks.xstream.XStream;
6 | import com.thoughtworks.xstream.core.util.QuickWriter;
7 | import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
8 | import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
9 | import com.thoughtworks.xstream.io.xml.XppDriver;
10 |
11 | public class XSteram {
12 |
13 |
14 | public static XStream xstream = new XStream(new XppDriver() {
15 |
16 | public HierarchicalStreamWriter createWriter(Writer out) {
17 | return new PrettyPrintWriter(out) {
18 | boolean cdata = true;
19 | public void startNode(String name, Class clazz) {
20 | super.startNode(name, clazz);
21 | }
22 |
23 | protected void writeText(QuickWriter writer, String text) {
24 | if (cdata) {
25 | writer.write("");
28 | } else {
29 | writer.write(text);
30 | }
31 | }
32 | };
33 | }
34 | });
35 |
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.thymleaf.cache = false
2 | spring.thymeleaf.mode=HTML
3 | spring.thymeleaf.suffix=.html
--------------------------------------------------------------------------------
/springboot-wpay/src/main/resources/templates/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 | 41111112
9 |
10 |
--------------------------------------------------------------------------------
/springboot-wpay/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 微信扫码付款
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/springboot-wpay/src/test/java/com/haiyu/SpringbootWpayApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootWpayApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-wxauth/src/main/java/com/haiyu/SpringbootWxauthApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootWxauthApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootWxauthApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-wxauth/src/main/java/com/haiyu/controller/LoginController.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.controller;
2 |
3 | import com.haiyu.utils.AuthUtil;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.springframework.stereotype.Controller;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 |
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpServletResponse;
10 | import java.io.IOException;
11 | import java.net.URLEncoder;
12 |
13 | /**
14 | * @Title: LoginController
15 | * @Description:
16 | * @author: youqing
17 | * @version: 1.0
18 | * @date: 2019/1/10 14:21
19 | */
20 | @Controller
21 | @RequestMapping("/wx")
22 | @Slf4j
23 | public class LoginController {
24 |
25 | @RequestMapping("/login")
26 | public void login(HttpServletRequest request, HttpServletResponse response) throws IOException {
27 | String backUrl = "http://linliuxing.top:8090/ok";
28 | String url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
29 | +"appid=" + AuthUtil.APPID
30 | +"&redirect_uri="+ URLEncoder.encode(backUrl,"UTF-8")
31 | +"&response_type=code"
32 | +"&scope=snsapi_userinfo"
33 | +"&state=STATE#wechat_redict";
34 |
35 | response.sendRedirect(url);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/springboot-wxauth/src/main/java/com/haiyu/utils/AuthUtil.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.utils;
2 |
3 | import com.alibaba.fastjson.JSONObject;
4 | import org.apache.http.HttpEntity;
5 | import org.apache.http.HttpResponse;
6 | import org.apache.http.client.methods.HttpGet;
7 | import org.apache.http.impl.client.DefaultHttpClient;
8 | import org.apache.http.util.EntityUtils;
9 |
10 | import java.io.IOException;
11 |
12 | /**
13 | * @Title: AuthUtil
14 | * @Description:
15 | * @author: youqing
16 | * @version: 1.0
17 | * @date: 2019/1/10 14:02
18 | */
19 | public class AuthUtil {
20 |
21 | public static final String APPID = "wxf59660c089a04881";
22 |
23 | public static final String APPSECRET = "dd534c1a2b414aed73d639d80f304a26";
24 |
25 | public static JSONObject doGetJson(String url) throws IOException {
26 | JSONObject jsonObject = null;
27 | DefaultHttpClient client = new DefaultHttpClient();
28 | HttpGet httpGet = new HttpGet(url);
29 | HttpResponse response = client.execute(httpGet);
30 | HttpEntity entity = response.getEntity();
31 | if (entity != null){
32 | String result = EntityUtils.toString(entity,"UTF-8");
33 | jsonObject = JSONObject.parseObject(result);
34 | }
35 | httpGet.releaseConnection();
36 | return jsonObject;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/springboot-wxauth/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8090
--------------------------------------------------------------------------------
/springboot-wxauth/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | index
7 |
8 |
9 | 微信公众授权登录
10 |
11 |
--------------------------------------------------------------------------------
/springboot-wxauth/src/main/resources/templates/ok.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | OK
6 |
7 |
8 | 欢迎登录!
9 |
10 |
--------------------------------------------------------------------------------
/springboot-wxauth/src/test/java/com/haiyu/SpringbootWxauthApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootWxauthApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-wxlogin/src/main/java/com/haiyu/SpringbootWxloginApplication.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootWxloginApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootWxloginApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springboot-wxlogin/src/main/java/com/haiyu/conmmon/WxApp.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.conmmon;
2 |
3 | /**
4 | * @Desc: 微信小程序的参数
5 | * @Author: liuxing
6 | * @Date: 2019/1/12 11:13
7 | * @Version 1.0
8 | */
9 | public class WxApp {
10 | public static final String APPID ="";//填写微信小程序的appid
11 | public static final String SECRET ="";//填写微信小程序的SECRET
12 | }
13 |
--------------------------------------------------------------------------------
/springboot-wxlogin/src/main/java/com/haiyu/model/WXSessionModel.java:
--------------------------------------------------------------------------------
1 | package com.haiyu.model;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @Desc: 微信请求的返回体
7 | * @Author: liuxing
8 | * @Date: 2019/1/12 11:19
9 | * @Version 1.0
10 | */
11 | @Data
12 | public class WXSessionModel {
13 | private String session_key;
14 | private String openid;
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-wxlogin/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8080
3 |
4 | spring:
5 | redis:
6 | database: 0
7 | host: 127.0.0.1
8 | port: 6379
--------------------------------------------------------------------------------
/springboot-wxlogin/src/test/java/com/haiyu/SpringbootWxloginApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haiyu;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootWxloginApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------