();
13 |
14 | /**
15 | * @Description: 设置数据源类型
16 | * @param dataSourceType 数据库类型
17 | */
18 | public static void setDataSourceType(String dataSourceType) {
19 | contextHolder.set(dataSourceType);
20 | }
21 |
22 | /**
23 | * @Description: 获取数据源类型
24 | */
25 | public static String getDataSourceType() {
26 | return contextHolder.get();
27 | }
28 |
29 | /**
30 | * @Description: 清除数据源类型
31 | */
32 | public static void clearDataSourceType() {
33 | contextHolder.remove();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/gaowh/scaffold/core/mutidatesource/DynamicDataSource.java:
--------------------------------------------------------------------------------
1 | package com.gaowh.scaffold.core.mutidatesource;
2 |
3 | import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
4 |
5 | /**
6 | *
7 | * 动态数据源
8 | *
9 | * @author gaowh
10 | * @date 2017年3月5日 上午9:11:49
11 | */
12 | public class DynamicDataSource extends AbstractRoutingDataSource {
13 |
14 | @Override
15 | protected Object determineCurrentLookupKey() {
16 | return DataSourceContextHolder.getDataSourceType();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/gaowh/scaffold/core/shiro/check/ICheck.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017, Chill Zhuang 庄骞 (smallchill@163.com).
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.gaowh.scaffold.core.shiro.check;
17 |
18 |
19 | /**
20 | * 检查用接口
21 | */
22 | public interface ICheck {
23 |
24 | /**
25 | * 检查指定角色
26 | * @param permissions
27 | * @return boolean
28 | */
29 | boolean check(Object[] permissions);
30 |
31 | /**
32 | * 检查全体角色
33 | * @return boolean
34 | */
35 | boolean checkAll();
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/gaowh/scaffold/core/support/ObjectKit.java:
--------------------------------------------------------------------------------
1 | package com.gaowh.scaffold.core.support;
2 |
3 | /**
4 | * 一些通用的函数
5 | *
6 | * @author Looly
7 | *
8 | */
9 | public class ObjectKit {
10 | /**
11 | * 比较两个对象是否相等。
12 | * 相同的条件有两个,满足其一即可:
13 | * 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2)
14 | *
15 | * @param obj1 对象1
16 | * @param obj2 对象2
17 | * @return 是否相等
18 | */
19 | public static boolean equals(Object obj1, Object obj2) {
20 | return (obj1 != null) ? (obj1.equals(obj2)) : (obj2 == null);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/gaowh/scaffold/core/util/HttpSessionHolder.java:
--------------------------------------------------------------------------------
1 | package com.gaowh.scaffold.core.util;
2 |
3 | import javax.servlet.http.HttpSession;
4 |
5 | /**
6 | * 非Controller中获取当前session的工具类
7 | *
8 | * @author gaowh
9 | * @date 2016年11月28日 上午10:24:31
10 | */
11 | public class HttpSessionHolder {
12 |
13 | private static ThreadLocal tl = new ThreadLocal();
14 |
15 | public static void put(HttpSession s) {
16 | tl.set(s);
17 | }
18 |
19 | public static HttpSession get() {
20 | return tl.get();
21 | }
22 |
23 | public static void remove() {
24 | tl.remove();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/gaowh/scaffold/core/util/SqlUtil.java:
--------------------------------------------------------------------------------
1 | package com.gaowh.scaffold.core.util;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * sql语句工具类
8 | *
9 | * @author gaowh
10 | * @date 2016年12月6日 下午1:01:54
11 | */
12 | public class SqlUtil {
13 |
14 | /**
15 | * @Description 根据集合的大小,输出相应个数"?"
16 | * @author gaowh
17 | */
18 | public static String parse(List> list) {
19 | String str = "";
20 | if (list != null && list.size() > 0) {
21 | str = str + "?";
22 | for (int i = 1; i < list.size(); i++) {
23 | str = str + ",?";
24 | }
25 | }
26 | return str;
27 | }
28 |
29 | public static void main(String[] args) {
30 | ArrayList