",{id:f+"_addTag"}).append(i.interactive?a("
",{id:f+"_tag",class:"tag-input",value:"",placeholder:i.placeholder}):null));a(l).insertAfter(this),a(k.holder).css("width",i.width),a(k.holder).css("min-height",i.height),a(k.holder).css("height",i.height),""!==a(k.real_input).val()&&a.fn.tagsInput.importTags(a(k.real_input),a(k.real_input).val()),i.interactive&&(a(k.fake_input).val(""),a(k.fake_input).data("pasted",!1),a(k.fake_input).on("focus",k,function(b){a(k.holder).addClass("focus"),""===a(this).val()&&a(this).removeClass("error")}),a(k.fake_input).on("blur",k,function(b){a(k.holder).removeClass("focus")}),null!==i.autocomplete&&void 0!==jQuery.ui.autocomplete?(a(k.fake_input).autocomplete(i.autocomplete),a(k.fake_input).on("autocompleteselect",k,function(b,c){return a(b.data.real_input).addTag(c.item.value,{focus:!0,unique:i.unique}),!1}),a(k.fake_input).on("keypress",k,function(b){g(b)&&a(this).autocomplete("close")})):a(k.fake_input).on("blur",k,function(b){return a(b.data.real_input).addTag(a(b.data.fake_input).val(),{focus:!0,unique:i.unique}),!1}),a(k.fake_input).on("keypress",k,function(b){if(g(b))return b.preventDefault(),a(b.data.real_input).addTag(a(b.data.fake_input).val(),{focus:!0,unique:i.unique}),!1}),a(k.fake_input).on("paste",function(){a(this).data("pasted",!0)}),a(k.fake_input).on("input",k,function(b){if(a(this).data("pasted")){a(this).data("pasted",!1);var c=a(b.data.fake_input).val();c=c.replace(/\n/g,""),c=c.replace(/\s/g,"");var d=h(b.data.delimiter,c);if(d.length>1){for(var e=0;e
span").text(),d=a(this).attr("id").replace(/_tag$/,"");a("#"+d).removeTag(encodeURI(c)),a(this).trigger("focus")}}),a(k.fake_input).keydown(function(b){jQuery.inArray(b.keyCode,[13,37,38,39,40,27,16,17,18,225])===-1&&a(this).removeClass("error")}))}}),this},a.fn.tagsInput.updateTagsField=function(c,d){var f=a(c).attr("id");a(c).val(d.join(e(b[f])))},a.fn.tagsInput.importTags=function(c,e){a(c).val("");var f=a(c).attr("id"),g=h(b[f],e);for(i=0;ic.maxChars&&(f=!1),null!==c.limit&&d.length>=c.limit&&(f=!1),null===c.validationPattern||c.validationPattern.test(b)||(f=!1),"string"==typeof e?b.indexOf(e)>-1&&(f=!1):a.each(e,function(a,c){return b.indexOf(c)>-1&&(f=!1),!1}),f},g=function(b){var c=!1;return 13===b.which||("string"==typeof b.data.delimiter?b.which===b.data.delimiter.charCodeAt(0)&&(c=!0):a.each(b.data.delimiter,function(a,d){b.which===d.charCodeAt(0)&&(c=!0)}),c)},h=function(b,c){if(""===c)return[];if("string"==typeof b)return c.split(b);var d="∞",e=c;return a.each(b,function(a,b){e=e.split(b).join(d)}),e.split(d)}}(jQuery);
--------------------------------------------------------------------------------
/src/main/resources/static/assets/module/admin.js:
--------------------------------------------------------------------------------
1 | /** 封装admin模块 */
2 | layui.define(['layer'], function (exports) {
3 | var $ = layui.jquery;
4 | var layer = layui.layer;
5 |
6 | var admin = {
7 | // 缓存token
8 | putToken: function (access_token) {
9 | layui.data(admin.getTableName(), {
10 | key: 'access_token',
11 | value: access_token
12 | });
13 | },
14 | // 获取缓存的token
15 | getToken: function () {
16 | return layui.data(admin.getTableName()).access_token;
17 | },
18 | // 清除token
19 | removeToken: function () {
20 | layui.data(admin.getTableName(), {
21 | key: 'access_token',
22 | remove: true
23 | });
24 | },
25 | // 封装ajax请求,返回数据类型为json
26 | req: function (url, data, success, method) {
27 | if ('put' == method.toLowerCase()) {
28 | method = 'POST';
29 | data._method = 'PUT';
30 | } else if ('delete' == method.toLowerCase()) {
31 | method = 'POST';
32 | data._method = 'DELETE';
33 | }
34 | admin.ajax({
35 | url: (base_server ? base_server : '') + url,
36 | data: data,
37 | type: method,
38 | dataType: 'json',
39 | success: success
40 | });
41 | },
42 | // 封装ajax请求
43 | ajax: function (param) {
44 | var successCallback = param.success;
45 | param.success = function (result, status, xhr) {
46 | // 判断登录过期和没有权限
47 | var jsonRs;
48 | if ('json' == param.dataType.toLowerCase()) {
49 | jsonRs = result;
50 | } else {
51 | jsonRs = admin.parseJSON(result);
52 | }
53 | if (jsonRs && admin.ajaxSuccessBefore(jsonRs) == false) {
54 | return;
55 | }
56 | successCallback(result, status, xhr);
57 | };
58 | param.error = function (xhr) {
59 | param.success({code: xhr.status, msg: xhr.statusText});
60 | };
61 | param.beforeSend = function (xhr) {
62 | /*var headers = admin.getAjaxHeaders();
63 | for (var i = 0; i < headers.length; i++) {
64 | xhr.setRequestHeader(headers[i].name, headers[i].value);
65 | }*/
66 | };
67 | if (admin.getToken()) {
68 | param.data.access_token = admin.getToken();
69 | }
70 | $.ajax(param);
71 | },
72 | // ajax自动传递header
73 | getAjaxHeaders: function () {
74 | var headers = [];
75 | var access_token = admin.getToken();
76 | if (access_token) {
77 | headers.push({
78 | name: 'Authorization',
79 | value: 'Bearer ' + access_token
80 | });
81 | }
82 | return headers;
83 | },
84 | // ajax请求结束后的处理,返回false阻止代码执行
85 | ajaxSuccessBefore: function (res) {
86 | if (res.code == 401) {
87 | admin.removeToken();
88 | layer.msg('登录过期', {icon: 2, time: 1500}, function () {
89 | top.location.reload();
90 | });
91 | return false;
92 | } else if (res.code == 403) {
93 | layer.msg('没有访问权限', {icon: 2});
94 | } else if (res.code == 404) {
95 | layer.msg('目标不存在(404)', {icon: 2});
96 | }
97 | return true;
98 | },
99 | // 转换json
100 | parseJSON: function (str) {
101 | if (typeof str == 'string') {
102 | try {
103 | var obj = JSON.parse(str);
104 | if (typeof obj == 'object' && obj) {
105 | return obj;
106 | }
107 | } catch (e) {
108 | console.error(e);
109 | }
110 | }
111 | },
112 | // 获取本地存储表名
113 | getTableName: function () {
114 | return tableName ? tableName : 'easyweb-jwtp';
115 | }
116 | };
117 |
118 | // 所有ew-event
119 | $('body').on('click', '*[ew-event]', function () {
120 | var event = $(this).attr('ew-event');
121 | if (event == 'closeDialog') {
122 | var id = $(this).parents('.layui-layer').attr('id').substring(11);
123 | layer.close(id);
124 | }
125 | });
126 |
127 | // 侧边栏点击事件
128 | $('body').on('click', '*[lay-href]', function () {
129 | try {
130 | var url = $(this).attr('lay-href');
131 | top.layui.jquery('iframe[name=body]').attr('src', url);
132 | } catch (e) {
133 | }
134 | });
135 |
136 | exports('admin', admin);
137 | });
138 |
--------------------------------------------------------------------------------
/src/main/resources/static/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 旅游信息后台管理系统
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |

19 |
旅游信息后台管理系统
20 |
21 |
36 |
37 |
38 |
39 |
96 |
97 |
--------------------------------------------------------------------------------
/src/test/java/com/dh/tourism/TourismApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.dh.tourism;
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 TourismApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------