forked from xkcoding/spring-boot-demo
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
344 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
Navicat Premium Data Transfer | ||
Source Server : 本机 | ||
Source Server Type : MySQL | ||
Source Server Version : 50718 | ||
Source Host : localhost:3306 | ||
Source Schema : spring-boot-demo | ||
Target Server Type : MySQL | ||
Target Server Version : 50718 | ||
File Encoding : 65001 | ||
Date: 12/12/2018 18:52:51 | ||
*/ | ||
|
||
SET NAMES utf8mb4; | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- ---------------------------- | ||
-- Table structure for sec_user | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `shiro_user`; | ||
CREATE TABLE `shiro_user` | ||
( | ||
`id` bigint(64) NOT NULL COMMENT '主键', | ||
`username` varchar(50) NOT NULL COMMENT '用户名', | ||
`password` varchar(60) NOT NULL COMMENT '密码', | ||
`salt` varchar(60) NOT NULL COMMENT '盐值', | ||
`nickname` varchar(255) DEFAULT NULL COMMENT '昵称', | ||
`phone` varchar(11) DEFAULT NULL COMMENT '手机', | ||
`email` varchar(50) DEFAULT NULL COMMENT '邮箱', | ||
`birthday` bigint(13) DEFAULT NULL COMMENT '生日', | ||
`sex` int(2) DEFAULT NULL COMMENT '性别,男-1,女-2', | ||
`status` int(2) NOT NULL DEFAULT '1' COMMENT '状态,启用-1,禁用-0', | ||
`create_time` bigint(13) NOT NULL COMMENT '创建时间', | ||
`update_time` bigint(13) NOT NULL COMMENT '更新时间', | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `username` (`username`), | ||
UNIQUE KEY `phone` (`phone`), | ||
UNIQUE KEY `email` (`email`) | ||
) ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8 COMMENT ='用户表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for sec_role | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `shiro_role`; | ||
CREATE TABLE `shiro_role` | ||
( | ||
`id` bigint(64) NOT NULL COMMENT '主键', | ||
`name` varchar(50) NOT NULL COMMENT '角色名', | ||
`description` varchar(100) DEFAULT NULL COMMENT '描述', | ||
`create_time` bigint(13) NOT NULL COMMENT '创建时间', | ||
`update_time` bigint(13) NOT NULL COMMENT '更新时间', | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `name` (`name`) | ||
) ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8 COMMENT ='角色表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for sec_user_role | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `shiro_user_role`; | ||
CREATE TABLE `shiro_user_role` | ||
( | ||
`user_id` bigint(64) NOT NULL COMMENT '用户主键', | ||
`role_id` bigint(64) NOT NULL COMMENT '角色主键', | ||
PRIMARY KEY (`user_id`, `role_id`) | ||
) ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8 COMMENT ='用户角色关系表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for sec_permission | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `shiro_permission`; | ||
CREATE TABLE `shiro_permission` | ||
( | ||
`id` bigint(64) NOT NULL COMMENT '主键', | ||
`name` varchar(50) NOT NULL COMMENT '权限名', | ||
`url` varchar(1000) DEFAULT NULL COMMENT '类型为页面时,代表前端路由地址,类型为按钮时,代表后端接口地址', | ||
`type` int(2) NOT NULL COMMENT '权限类型,页面-1,按钮-2', | ||
`permission` varchar(50) DEFAULT NULL COMMENT '权限表达式', | ||
`method` varchar(50) DEFAULT NULL COMMENT '后端接口访问方式', | ||
`sort` int(11) NOT NULL COMMENT '排序', | ||
`parent_id` bigint(64) NOT NULL COMMENT '父级id', | ||
PRIMARY KEY (`id`) | ||
) ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8 COMMENT ='权限表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for sec_role_permission | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `shiro_role_permission`; | ||
CREATE TABLE `shiro_role_permission` | ||
( | ||
`role_id` bigint(64) NOT NULL COMMENT '角色主键', | ||
`permission_id` bigint(64) NOT NULL COMMENT '权限主键', | ||
PRIMARY KEY (`role_id`, `permission_id`) | ||
) ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8 COMMENT ='角色权限关系表'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
spring-boot-demo-rbac-shiro/src/main/java/com/xkcoding/rbac/shiro/common/IResultCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.xkcoding.rbac.shiro.common; | ||
|
||
/** | ||
* <p> | ||
* 统一状态码接口 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.rbac.shiro.common | ||
* @description: 统一状态码接口 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-21 16:28 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
public interface IResultCode { | ||
/** | ||
* 获取状态码 | ||
* | ||
* @return 状态码 | ||
*/ | ||
Integer getCode(); | ||
|
||
/** | ||
* 获取返回消息 | ||
* | ||
* @return 返回消息 | ||
*/ | ||
String getMessage(); | ||
} |
95 changes: 95 additions & 0 deletions
95
spring-boot-demo-rbac-shiro/src/main/java/com/xkcoding/rbac/shiro/common/R.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.xkcoding.rbac.shiro.common; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* <p> | ||
* 统一API对象返回 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.rbac.shiro.common | ||
* @description: 统一API对象返回 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-21 16:24 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
public class R<T> { | ||
/** | ||
* 状态码 | ||
*/ | ||
private Integer code; | ||
|
||
/** | ||
* 返回消息 | ||
*/ | ||
private String message; | ||
|
||
/** | ||
* 状态 | ||
*/ | ||
private boolean status; | ||
|
||
/** | ||
* 返回数据 | ||
*/ | ||
private T data; | ||
|
||
public R(Integer code, String message, boolean status, T data) { | ||
this.code = code; | ||
this.message = message; | ||
this.status = status; | ||
this.data = data; | ||
} | ||
|
||
public R(IResultCode resultCode, boolean status, T data) { | ||
this.code = resultCode.getCode(); | ||
this.message = resultCode.getMessage(); | ||
this.status = status; | ||
this.data = data; | ||
} | ||
|
||
public R(IResultCode resultCode, boolean status) { | ||
this.code = resultCode.getCode(); | ||
this.message = resultCode.getMessage(); | ||
this.status = status; | ||
this.data = null; | ||
} | ||
|
||
public static <T> R success() { | ||
return new R<>(ResultCode.OK, true); | ||
} | ||
|
||
public static <T> R message(String message) { | ||
return new R<>(ResultCode.OK.getCode(), message, true, null); | ||
} | ||
|
||
public static <T> R success(T data) { | ||
return new R<>(ResultCode.OK, true, data); | ||
} | ||
|
||
public static <T> R fail() { | ||
return new R<>(ResultCode.ERROR, false); | ||
} | ||
|
||
public static <T> R fail(IResultCode resultCode) { | ||
return new R<>(resultCode, false); | ||
} | ||
|
||
public static <T> R fail(Integer code, String message) { | ||
return new R<>(code, message, false, null); | ||
} | ||
|
||
public static <T> R fail(IResultCode resultCode, T data) { | ||
return new R<>(resultCode, false, data); | ||
} | ||
|
||
public static <T> R fail(Integer code, String message, T data) { | ||
return new R<>(code, message, false, data); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
spring-boot-demo-rbac-shiro/src/main/java/com/xkcoding/rbac/shiro/common/ResultCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.xkcoding.rbac.shiro.common; | ||
|
||
import lombok.Getter; | ||
|
||
/** | ||
* <p> | ||
* 通用状态枚举 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.rbac.shiro.common | ||
* @description: 通用状态枚举 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-21 16:31 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
@Getter | ||
public enum ResultCode implements IResultCode { | ||
/** | ||
* 成功 | ||
*/ | ||
OK(200, "成功"), | ||
/** | ||
* 失败 | ||
*/ | ||
ERROR(500, "失败"); | ||
|
||
/** | ||
* 返回码 | ||
*/ | ||
private Integer code; | ||
|
||
/** | ||
* 返回消息 | ||
*/ | ||
private String message; | ||
|
||
ResultCode(Integer code, String message) { | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...boot-demo-rbac-shiro/src/main/java/com/xkcoding/rbac/shiro/controller/TestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.xkcoding.rbac.shiro.controller; | ||
|
||
import com.xkcoding.rbac.shiro.common.R; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* <p> | ||
* 测试Controller | ||
* </p> | ||
* | ||
* @package: com.xkcoding.rbac.shiro.controller | ||
* @description: 测试Controller | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-21 16:13 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
@RestController | ||
@RequestMapping("/test") | ||
public class TestController { | ||
|
||
@GetMapping("") | ||
public R test() { | ||
return R.success(); | ||
} | ||
} |
Empty file.
4 changes: 4 additions & 0 deletions
4
spring-boot-demo-rbac-shiro/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
server: | ||
port: 8080 | ||
servlet: | ||
context-path: /demo |