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 | *
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 cn.stylefeng.guns;
17 |
18 | import cn.stylefeng.roses.core.config.WebAutoConfiguration;
19 | import org.slf4j.Logger;
20 | import org.slf4j.LoggerFactory;
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 |
24 | /**
25 | * SpringBoot方式启动类
26 | *
27 | * @author stylefeng
28 | * @Date 2017/5/21 12:06
29 | */
30 | @SpringBootApplication(exclude = WebAutoConfiguration.class)
31 | public class GunsApplication {
32 |
33 | private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class);
34 |
35 | public static void main(String[] args) {
36 | SpringApplication.run(GunsApplication.class, args);
37 | logger.info("GunsApplication is success!");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/GunsServletInitializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns;
17 |
18 | import org.springframework.boot.builder.SpringApplicationBuilder;
19 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
20 |
21 | /**
22 | * Guns Web程序启动类
23 | *
24 | * @author fengshuonan
25 | * @date 2017-05-21 9:43
26 | */
27 | public class GunsServletInitializer extends SpringBootServletInitializer {
28 |
29 | @Override
30 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
31 | return builder.sources(GunsApplication.class);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/config/SpringSessionConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.config;
17 |
18 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
19 |
20 | /**
21 | * spring session配置
22 | *
23 | * @author fengshuonan
24 | * @date 2017-07-13 21:05
25 | */
26 | //@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 1800) //session过期时间 如果部署多机环境,需要打开注释
27 | @ConditionalOnProperty(prefix = "guns", name = "spring-session-open", havingValue = "true")
28 | public class SpringSessionConfig {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/annotion/BussinessLog.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.annotion;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 | import cn.stylefeng.guns.core.common.constant.dictmap.base.SystemDict;
20 |
21 | import java.lang.annotation.*;
22 |
23 | /**
24 | * 标记需要做业务日志的方法
25 | *
26 | * @author fengshuonan
27 | * @date 2017-03-31 12:46
28 | */
29 | @Inherited
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target({ElementType.METHOD})
32 | public @interface BussinessLog {
33 |
34 | /**
35 | * 业务的名称,例如:"修改菜单"
36 | */
37 | String value() default "";
38 |
39 | /**
40 | * 被修改的实体的唯一标识,例如:菜单实体的唯一标识为"id"
41 | */
42 | String key() default "id";
43 |
44 | /**
45 | * 字典(用于查找key的中文名称和字段的中文名称)
46 | */
47 | Class extends AbstractDictMap> dict() default SystemDict.class;
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/annotion/Permission.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.annotion;
17 |
18 | import java.lang.annotation.*;
19 |
20 | /**
21 | * 权限注解 用于检查权限 规定访问权限
22 | *
23 | * @example @Permission({role1,role2})
24 | * @example @Permission
25 | */
26 | @Inherited
27 | @Retention(RetentionPolicy.RUNTIME)
28 | @Target({ElementType.METHOD})
29 | public @interface Permission {
30 |
31 | /**
32 | *
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 | *
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 cn.stylefeng.guns.core.common.constant;
17 |
18 | /**
19 | * 系统常量
20 | *
21 | * @author fengshuonan
22 | * @date 2017年2月12日 下午9:42:53
23 | */
24 | public interface Const {
25 |
26 | /**
27 | * 系统默认的管理员密码
28 | */
29 | String DEFAULT_PWD = "111111";
30 |
31 | /**
32 | * 管理员角色的名字
33 | */
34 | String ADMIN_NAME = "administrator";
35 |
36 | /**
37 | * 管理员id
38 | */
39 | Integer ADMIN_ID = 1;
40 |
41 | /**
42 | * 超级管理员角色id
43 | */
44 | Integer ADMIN_ROLE_ID = 1;
45 |
46 | /**
47 | * 接口文档的菜单名
48 | */
49 | String API_MENU_NAME = "接口文档";
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/DatasourceEnum.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant;
17 |
18 | /**
19 | * 多数据源的枚举
20 | *
21 | * @author fengshuonan
22 | * @date 2017年3月5日 上午10:15:02
23 | */
24 | public interface DatasourceEnum {
25 |
26 | String DATA_SOURCE_GUNS = "dataSourceGuns"; //guns数据源
27 |
28 | String DATA_SOURCE_BIZ = "dataSourceBiz"; //其他业务的数据源
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/JwtConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant;
17 |
18 | /**
19 | * jwt相关配置
20 | *
21 | * @author fengshuonan
22 | * @date 2017-08-23 9:23
23 | */
24 | public interface JwtConstants {
25 |
26 | String AUTH_HEADER = "Authorization";
27 |
28 | String SECRET = "defaultSecret";
29 |
30 | Long EXPIRATION = 604800L;
31 |
32 | String AUTH_PATH = "/gunsApi/auth";
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/cache/Cache.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.cache;
17 |
18 | /**
19 | * 所有缓存名称的集合
20 | *
21 | * @author fengshuonan
22 | * @date 2017-04-24 21:56
23 | */
24 | public interface Cache {
25 |
26 | /**
27 | * 常量缓存
28 | */
29 | String CONSTANT = "CONSTANT";
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/cache/CacheKey.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.cache;
17 |
18 | /**
19 | * 缓存标识前缀集合,常用在ConstantFactory类中
20 | *
21 | * @author fengshuonan
22 | * @date 2017-04-25 9:37
23 | */
24 | public interface CacheKey {
25 |
26 | /**
27 | * 角色名称(多个)
28 | */
29 | String ROLES_NAME = "roles_name_";
30 |
31 | /**
32 | * 角色名称(单个)
33 | */
34 | String SINGLE_ROLE_NAME = "single_role_name_";
35 |
36 | /**
37 | * 角色英文名称
38 | */
39 | String SINGLE_ROLE_TIP = "single_role_tip_";
40 |
41 | /**
42 | * 部门名称
43 | */
44 | String DEPT_NAME = "dept_name_";
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/DeleteDict.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 用于删除业务的字典
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:01
25 | */
26 | public class DeleteDict extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("roleId", "角色名称");
31 | put("deptId", "部门名称");
32 | put("menuId", "菜单名称");
33 | put("dictId", "字典名称");
34 | put("noticeId", "标题");
35 | }
36 |
37 | @Override
38 | protected void initBeWrapped() {
39 | putFieldWrapperMethodName("roleId", "getCacheObject");
40 | putFieldWrapperMethodName("deptId", "getCacheObject");
41 | putFieldWrapperMethodName("menuId", "getCacheObject");
42 | putFieldWrapperMethodName("dictId", "getCacheObject");
43 | putFieldWrapperMethodName("noticeId", "getCacheObject");
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/DeptDict.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 部门的映射
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:01
25 | */
26 | public class DeptDict extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("deptId", "部门名称");
31 | put("num", "部门排序");
32 | put("pid", "上级名称");
33 | put("simplename", "部门简称");
34 | put("fullname", "部门全称");
35 | put("tips", "备注");
36 | }
37 |
38 | @Override
39 | protected void initBeWrapped() {
40 | putFieldWrapperMethodName("deptId", "getDeptName");
41 | putFieldWrapperMethodName("pid", "getDeptName");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/DictMap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 字典map
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:43
25 | */
26 | public class DictMap extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("dictId", "字典名称");
31 | put("dictName", "字典名称");
32 | put("dictValues", "字典内容");
33 | }
34 |
35 | @Override
36 | protected void initBeWrapped() {
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/LogDict.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 日志的字典
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:01
25 | */
26 | public class LogDict extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("tips", "备注");
31 | }
32 |
33 | @Override
34 | protected void initBeWrapped() {
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/MenuDict.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 菜单的字典
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:01
25 | */
26 | public class MenuDict extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("menuId", "菜单id");
31 | put("id", "菜单id");
32 | put("code", "菜单编号");
33 | put("pcode", "菜单父编号");
34 | put("name", "菜单名称");
35 | put("icon", "菜单图标");
36 | put("url", "url地址");
37 | put("num", "菜单排序号");
38 | put("levels", "菜单层级");
39 | put("tips", "备注");
40 | put("status", "菜单状态");
41 | put("isopen", "是否打开");
42 | put("", "");
43 | }
44 |
45 | @Override
46 | protected void initBeWrapped() {
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/NoticeMap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 通知的映射
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:01
25 | */
26 | public class NoticeMap extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("title", "标题");
31 | put("content", "内容");
32 | }
33 |
34 | @Override
35 | protected void initBeWrapped() {
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/RoleDict.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 角色的字典
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:01
25 | */
26 | public class RoleDict extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("roleId", "角色名称");
31 | put("num", "角色排序");
32 | put("pid", "角色的父级");
33 | put("name", "角色名称");
34 | put("deptid", "部门名称");
35 | put("tips", "备注");
36 | put("ids", "资源名称");
37 | }
38 |
39 | @Override
40 | protected void initBeWrapped() {
41 | putFieldWrapperMethodName("pid", "getSingleRoleName");
42 | putFieldWrapperMethodName("deptid", "getDeptName");
43 | putFieldWrapperMethodName("roleId", "getSingleRoleName");
44 | putFieldWrapperMethodName("ids", "getMenuNames");
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/UserDict.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap;
17 |
18 | import cn.stylefeng.guns.core.common.constant.dictmap.base.AbstractDictMap;
19 |
20 | /**
21 | * 用户的字典
22 | *
23 | * @author fengshuonan
24 | * @date 2017-05-06 15:01
25 | */
26 | public class UserDict extends AbstractDictMap {
27 |
28 | @Override
29 | public void init() {
30 | put("userId", "账号");
31 | put("avatar", "头像");
32 | put("account", "账号");
33 | put("name", "名字");
34 | put("birthday", "生日");
35 | put("sex", "性别");
36 | put("email", "电子邮件");
37 | put("phone", "电话");
38 | put("roleid", "角色名称");
39 | put("deptid", "部门名称");
40 | put("roleIds", "角色名称集合");
41 | }
42 |
43 | @Override
44 | protected void initBeWrapped() {
45 | putFieldWrapperMethodName("sex", "getSexName");
46 | putFieldWrapperMethodName("deptid", "getDeptName");
47 | putFieldWrapperMethodName("roleid", "getSingleRoleName");
48 | putFieldWrapperMethodName("userId", "getUserAccountById");
49 | putFieldWrapperMethodName("roleIds", "getRoleName");
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/dictmap/base/SystemDict.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.dictmap.base;
17 |
18 | /**
19 | * 系统相关的字典
20 | *
21 | * @author fengshuonan
22 | * @date 2017-05-06 15:48
23 | */
24 | public class SystemDict extends AbstractDictMap {
25 |
26 | @Override
27 | public void init() {
28 | }
29 |
30 | @Override
31 | protected void initBeWrapped() {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/state/LogSucceed.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.state;
17 |
18 | /**
19 | * 业务是否成功的日志记录
20 | *
21 | * @author fengshuonan
22 | * @Date 2017年1月22日 下午12:14:59
23 | */
24 | public enum LogSucceed {
25 |
26 | SUCCESS("成功"),
27 | FAIL("失败");
28 |
29 | String message;
30 |
31 | LogSucceed(String message) {
32 | this.message = message;
33 | }
34 |
35 | public String getMessage() {
36 | return message;
37 | }
38 |
39 | public void setMessage(String message) {
40 | this.message = message;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/state/LogType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.state;
17 |
18 | /**
19 | * 日志类型
20 | *
21 | * @author fengshuonan
22 | * @Date 2017年1月22日 下午12:14:59
23 | */
24 | public enum LogType {
25 |
26 | LOGIN("登录日志"),
27 | LOGIN_FAIL("登录失败日志"),
28 | EXIT("退出日志"),
29 | EXCEPTION("异常日志"),
30 | BUSSINESS("业务日志");
31 |
32 | String message;
33 |
34 | LogType(String message) {
35 | this.message = message;
36 | }
37 |
38 | public String getMessage() {
39 | return message;
40 | }
41 |
42 | public void setMessage(String message) {
43 | this.message = message;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/state/MenuStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.state;
17 |
18 | /**
19 | * 菜单的状态
20 | *
21 | * @author fengshuonan
22 | * @Date 2017年1月22日 下午12:14:59
23 | */
24 | public enum MenuStatus {
25 |
26 | ENABLE(1, "启用"),
27 | DISABLE(0, "禁用");
28 |
29 | int code;
30 | String message;
31 |
32 | MenuStatus(int code, String message) {
33 | this.code = code;
34 | this.message = message;
35 | }
36 |
37 | public int getCode() {
38 | return code;
39 | }
40 |
41 | public void setCode(int code) {
42 | this.code = code;
43 | }
44 |
45 | public String getMessage() {
46 | return message;
47 | }
48 |
49 | public void setMessage(String message) {
50 | this.message = message;
51 | }
52 |
53 | public static String valueOf(Integer status) {
54 | if (status == null) {
55 | return "";
56 | } else {
57 | for (MenuStatus s : MenuStatus.values()) {
58 | if (s.getCode() == status) {
59 | return s.getMessage();
60 | }
61 | }
62 | return "";
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/constant/state/Order.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.constant.state;
17 |
18 | /**
19 | * 数据库排序
20 | *
21 | * @author fengshuonan
22 | * @Date 2017年5月31日20:48:41
23 | */
24 | public enum Order {
25 |
26 | ASC("asc"), DESC("desc");
27 |
28 | private String des;
29 |
30 | Order(String des) {
31 | this.des = des;
32 | }
33 |
34 | public String getDes() {
35 | return des;
36 | }
37 |
38 | public void setDes(String des) {
39 | this.des = des;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/controller/GlobalController.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.controller;
17 |
18 | import org.springframework.stereotype.Controller;
19 | import org.springframework.ui.Model;
20 | import org.springframework.web.bind.annotation.RequestMapping;
21 |
22 | /**
23 | * 全局的控制器
24 | *
25 | * @author fengshuonan
26 | * @date 2016年11月13日 下午11:04:45
27 | */
28 | @Controller
29 | @RequestMapping("/global")
30 | public class GlobalController {
31 |
32 | /**
33 | * 跳转到404页面
34 | *
35 | * @author fengshuonan
36 | */
37 | @RequestMapping(path = "/error")
38 | public String errorPage() {
39 | return "/404.html";
40 | }
41 |
42 | /**
43 | * 跳转到session超时页面
44 | *
45 | * @author fengshuonan
46 | */
47 | @RequestMapping(path = "/sessionError")
48 | public String errorPageInfo(Model model) {
49 | model.addAttribute("tips", "session超时");
50 | return "/login.html";
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/controller/GunsErrorView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.controller;
17 |
18 | import org.springframework.web.servlet.View;
19 |
20 | import javax.servlet.http.HttpServletRequest;
21 | import javax.servlet.http.HttpServletResponse;
22 | import java.util.Map;
23 |
24 | /**
25 | * 错误页面的默认跳转(例如请求404的时候,默认走这个视图解析器)
26 | *
27 | * @author fengshuonan
28 | * @date 2017-05-21 11:34
29 | */
30 | public class GunsErrorView implements View {
31 |
32 | @Override
33 | public String getContentType() {
34 | return "text/html";
35 | }
36 |
37 | @Override
38 | public void render(Map map, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
39 | httpServletRequest.getRequestDispatcher("/global/error").forward(httpServletRequest, httpServletResponse);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/exception/InvalidKaptchaException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.exception;
17 |
18 | /**
19 | * 验证码错误异常
20 | *
21 | * @author fengshuonan
22 | * @date 2017-05-05 23:52
23 | */
24 | public class InvalidKaptchaException extends RuntimeException {
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/common/page/PageInfoBT.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.common.page;
17 |
18 | import com.baomidou.mybatisplus.plugins.Page;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * 分页结果的封装(for Bootstrap Table)
24 | *
25 | * @author fengshuonan
26 | * @Date 2017年1月22日 下午11:06:41
27 | */
28 | public class PageInfoBT {
29 |
30 | // 结果集
31 | private List rows;
32 |
33 | // 总数
34 | private long total;
35 |
36 | public PageInfoBT(Page page) {
37 | this.rows = page.getRecords();
38 | this.total = page.getTotal();
39 | }
40 |
41 | public List getRows() {
42 | return rows;
43 | }
44 |
45 | public void setRows(List rows) {
46 | this.rows = rows;
47 | }
48 |
49 | public long getTotal() {
50 | return total;
51 | }
52 |
53 | public void setTotal(long total) {
54 | this.total = total;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/interceptor/SessionHolderInterceptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.interceptor;
17 |
18 | import cn.stylefeng.roses.core.base.controller.BaseController;
19 | import cn.stylefeng.roses.core.util.HttpSessionContext;
20 | import org.aspectj.lang.ProceedingJoinPoint;
21 | import org.aspectj.lang.annotation.Around;
22 | import org.aspectj.lang.annotation.Aspect;
23 | import org.aspectj.lang.annotation.Pointcut;
24 | import org.springframework.stereotype.Component;
25 |
26 | /**
27 | * 静态调用session的拦截器
28 | *
29 | * @author fengshuonan
30 | * @date 2016年11月13日 下午10:15:42
31 | */
32 | @Aspect
33 | @Component
34 | public class SessionHolderInterceptor extends BaseController {
35 |
36 | @Pointcut("execution(* cn.stylefeng.guns.*..controller.*.*(..))")
37 | public void cutService() {
38 | }
39 |
40 | @Around("cutService()")
41 | public Object sessionKit(ProceedingJoinPoint point) throws Throwable {
42 | HttpSessionContext.put(super.getHttpServletRequest().getSession());
43 | try {
44 | return point.proceed();
45 | } finally {
46 | HttpSessionContext.remove();
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/listener/ConfigListener.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 | *
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 cn.stylefeng.guns.core.listener;
17 |
18 | import javax.servlet.ServletContext;
19 | import javax.servlet.ServletContextEvent;
20 | import javax.servlet.ServletContextListener;
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | /**
25 | * ServletContext监听器
26 | *
27 | * @author stylefeng
28 | * @Date 2018/2/22 21:07
29 | */
30 | public class ConfigListener implements ServletContextListener {
31 |
32 | private static Map conf = new HashMap<>();
33 |
34 | public static Map getConf() {
35 | return conf;
36 | }
37 |
38 | @Override
39 | public void contextDestroyed(ServletContextEvent arg0) {
40 | conf.clear();
41 | }
42 |
43 | @Override
44 | public void contextInitialized(ServletContextEvent evt) {
45 | ServletContext sc = evt.getServletContext();
46 |
47 | //项目发布,当前运行环境的绝对路径
48 | conf.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));
49 |
50 | //servletContextPath,默认""
51 | conf.put("contextPath", sc.getContextPath());
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/log/LogManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.log;
17 |
18 | import java.util.TimerTask;
19 | import java.util.concurrent.ScheduledThreadPoolExecutor;
20 | import java.util.concurrent.TimeUnit;
21 |
22 | /**
23 | * 日志管理器
24 | *
25 | * @author fengshuonan
26 | * @date 2017-03-30 16:29
27 | */
28 | public class LogManager {
29 |
30 | //日志记录操作延时
31 | private final int OPERATE_DELAY_TIME = 10;
32 |
33 | //异步操作记录日志的线程池
34 | private ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10);
35 |
36 | private LogManager() {
37 | }
38 |
39 | public static LogManager logManager = new LogManager();
40 |
41 | public static LogManager me() {
42 | return logManager;
43 | }
44 |
45 | public void executeLog(TimerTask task) {
46 | executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/log/LogObjectHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.log;
17 |
18 | import cn.stylefeng.roses.core.util.SpringContextHolder;
19 | import org.springframework.context.annotation.Scope;
20 | import org.springframework.stereotype.Component;
21 | import org.springframework.web.context.WebApplicationContext;
22 |
23 | import java.io.Serializable;
24 |
25 | /**
26 | * 被修改的bean临时存放的地方
27 | *
28 | * @author fengshuonan
29 | * @date 2017-03-31 11:19
30 | */
31 | @Component
32 | @Scope(scopeName = WebApplicationContext.SCOPE_SESSION)
33 | public class LogObjectHolder implements Serializable {
34 |
35 | private Object object = null;
36 |
37 | public void set(Object obj) {
38 | this.object = obj;
39 | }
40 |
41 | public Object get() {
42 | return object;
43 | }
44 |
45 | public static LogObjectHolder me() {
46 | return SpringContextHolder.getBean(LogObjectHolder.class);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/shiro/service/PermissionCheckService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.shiro.service;
17 |
18 | /**
19 | * 检查用接口
20 | */
21 | public interface PermissionCheckService {
22 |
23 | /**
24 | * 检查当前登录用户是否拥有指定的角色访问当
25 | */
26 | boolean check(Object[] permissions);
27 |
28 | /**
29 | * 检查当前登录用户是否拥有当前请求的servlet的权限
30 | */
31 | boolean checkAll();
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/shiro/service/UserAuthService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 cn.stylefeng.guns.core.shiro.service;
17 |
18 | import cn.stylefeng.guns.core.shiro.ShiroUser;
19 | import cn.stylefeng.guns.modular.system.model.User;
20 | import org.apache.shiro.authc.SimpleAuthenticationInfo;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * 定义shirorealm所需数据的接口
26 | *
27 | * @author fengshuonan
28 | * @date 2016年12月5日 上午10:23:34
29 | */
30 | public interface UserAuthService {
31 |
32 | /**
33 | * 根据账号获取登录用户
34 | *
35 | * @param account 账号
36 | */
37 | User user(String account);
38 |
39 | /**
40 | * 根据系统用户获取Shiro的用户
41 | *
42 | * @param user 系统用户
43 | */
44 | ShiroUser shiroUser(User user);
45 |
46 | /**
47 | * 获取权限列表通过角色id
48 | *
49 | * @param roleId 角色id
50 | */
51 | List findPermissionsByRoleId(Integer roleId);
52 |
53 | /**
54 | * 根据角色id获取角色名称
55 | *
56 | * @param roleId 角色id
57 | */
58 | String findRoleNameByRoleId(Integer roleId);
59 |
60 | /**
61 | * 获取shiro的认证信息
62 | */
63 | SimpleAuthenticationInfo info(ShiroUser shiroUser, User user, String realmName);
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/cn/stylefeng/guns/core/util/KaptchaUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
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 | *
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 | *