diff --git "a/\351\231\210\345\220\257/20240907 picgo.md" "b/\351\231\210\345\220\257/20240907 picgo.md" new file mode 100644 index 0000000000000000000000000000000000000000..38056501206db32e80d33aefb8a59b3fb8fe34a1 --- /dev/null +++ "b/\351\231\210\345\220\257/20240907 picgo.md" @@ -0,0 +1,22 @@ +# 一、图床使用方法 + +## 1. gitee当图床: + +1.病床,矿床,床是一个容器,图床一般指网络某个云服务。可用来存放图片,并通过url访问这上图片, + +2.新建仓库,用来存图片 + +3.获取私人令牌 + +## 2. 安装picgo + +1. 安装gitee uploader的插件 +2. 设置这个插件,仓库的地址,私人令牌 + +![image-20240908201306015](https://gitee.com/chenqi85689/picture-bed/raw/master/images/202409082013243.png) + +![image-20240908201424428](https://gitee.com/chenqi85689/picture-bed/raw/master/images/202409082014568.png) + +配置typora + +![image-20240908201451712](https://gitee.com/chenqi85689/picture-bed/raw/master/images/202409082014855.png) \ No newline at end of file diff --git "a/\351\231\210\345\220\257/20240908 rbac.md" "b/\351\231\210\345\220\257/20240908 rbac.md" new file mode 100644 index 0000000000000000000000000000000000000000..61afdeba4fcf5c592c9ca04eef2ac5cb4e462919 --- /dev/null +++ "b/\351\231\210\345\220\257/20240908 rbac.md" @@ -0,0 +1,248 @@ +## 1.RBAC(Role-Based Access Control) + +1.基于角色的访问控制 + +权限——》角色——》用户 + +1. 角色(Role):角色是指在系统中具有一组相关权限的抽象概念,代表了用户在特定上下文中的身份或职能,例如管理员、普通用户等。 +2. 权限(Permission):权限是指对系统资源进行操作的许可,如读取、写入、修改等。权限可以被分配给角色。 +3. 用户(User):用户是指系统的实际使用者,每个用户可以被分配一个或多个角色。 +4. 分配(Assignment):分配是指将角色与用户关联起来,以赋予用户相应的权限 + +简单来说就是将权限分配给角色,在将角色分配给用户,使不同的用户拥有不同的权限 + + + +# 、学校管理系统 + +## 1. 需求分析 + +不同的角色拥有不同的权限 + +教师:增删改查 + +学生:查 + +数据表: + +1. 个人信息表 +2. 教师表 +3. 学生表 +4. 角色表 +5. 权限表 + + + +# 概念模型 + +![捕获](https://gitee.com/chenqi85689/picture-bed/raw/master/images/202409082000091.png) + +# 逻辑模型 + +![捕获1](https://gitee.com/chenqi85689/picture-bed/raw/master/images/202409082000521.png) + + + +# 物理模型 + +![捕获2](https://gitee.com/chenqi85689/picture-bed/raw/master/images/202409082001191.png) + +sql语句 + +```sql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024-09-08 10:50:06 */ +/*==============================================================*/ + + +drop table if exists Access2; + +drop table if exists access; + +drop table if exists role; + +drop table if exists user; + +/*==============================================================*/ +/* Table: Access2 */ +/*==============================================================*/ +create table Access2 +( + a_id int not null, + r_id int not null, + primary key (a_id, r_id) +); + +/*==============================================================*/ +/* Table: access */ +/*==============================================================*/ +create table access +( + a_id int not null, + a_name varchar(255), + primary key (a_id) +); + +/*==============================================================*/ +/* Table: role */ +/*==============================================================*/ +create table role +( + r_id int not null, + r_name varchar(255), + primary key (r_id) +); + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table user +( + uid int not null, + r_id int not null, + u_name varchar(255), + u_sex char(1), + u_account int, + u_password varchar(255), + primary key (uid) +); + +alter table Access2 add constraint FK_Access foreign key (a_id) + references access (a_id) on delete restrict on update restrict; + +alter table Access2 add constraint FK_Access2 foreign key (r_id) + references role (r_id) on delete restrict on update restrict; + +alter table user add constraint FK_Relationship foreign key (r_id) + references role (r_id) on delete restrict on update restrict; + + +``` + +添加数据 + +```sql +/* + Navicat Premium Dump SQL + + Source Server : JAVA + Source Server Type : MySQL + Source Server Version : 80034 (8.0.34) + Source Host : localhost:3306 + Source Schema : java + + Target Server Type : MySQL + Target Server Version : 80034 (8.0.34) + File Encoding : 65001 + + Date: 08/09/2024 11:33:33 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for access +-- ---------------------------- +DROP TABLE IF EXISTS `access`; +CREATE TABLE `access` ( + `a_id` int NOT NULL, + `a_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + PRIMARY KEY (`a_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of access +-- ---------------------------- +INSERT INTO `access` VALUES (1, '添加成绩'); +INSERT INTO `access` VALUES (2, '修改成绩'); +INSERT INTO `access` VALUES (3, '查询成绩'); +INSERT INTO `access` VALUES (4, '修改密码'); + +-- ---------------------------- +-- Table structure for access2 +-- ---------------------------- +DROP TABLE IF EXISTS `access2`; +CREATE TABLE `access2` ( + `a_id` int NOT NULL, + `r_id` int NOT NULL, + PRIMARY KEY (`a_id`, `r_id`) USING BTREE, + INDEX `FK_Access2`(`r_id` ASC) USING BTREE, + CONSTRAINT `FK_Access` FOREIGN KEY (`a_id`) REFERENCES `access` (`a_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `FK_Access2` FOREIGN KEY (`r_id`) REFERENCES `role` (`r_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of access2 +-- ---------------------------- +INSERT INTO `access2` VALUES (3, 1); +INSERT INTO `access2` VALUES (4, 1); +INSERT INTO `access2` VALUES (1, 2); +INSERT INTO `access2` VALUES (2, 2); +INSERT INTO `access2` VALUES (3, 2); +INSERT INTO `access2` VALUES (4, 2); +INSERT INTO `access2` VALUES (1, 3); +INSERT INTO `access2` VALUES (2, 3); +INSERT INTO `access2` VALUES (3, 3); +INSERT INTO `access2` VALUES (4, 3); + +-- ---------------------------- +-- Table structure for role +-- ---------------------------- +DROP TABLE IF EXISTS `role`; +CREATE TABLE `role` ( + `r_id` int NOT NULL, + `r_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + PRIMARY KEY (`r_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of role +-- ---------------------------- +INSERT INTO `role` VALUES (1, '学生'); +INSERT INTO `role` VALUES (2, '老师'); +INSERT INTO `role` VALUES (3, '班主任'); + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `uid` int NOT NULL, + `r_id` int NOT NULL, + `u_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `u_sex` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `u_account` int NULL DEFAULT NULL, + `u_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + PRIMARY KEY (`uid`) USING BTREE, + INDEX `FK_Relationship`(`r_id` ASC) USING BTREE, + CONSTRAINT `FK_Relationship` FOREIGN KEY (`r_id`) REFERENCES `role` (`r_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES (1, 1, '张三', '男', 123, '123'); +INSERT INTO `user` VALUES (2, 2, '王五', '男', 1234, '1234'); +INSERT INTO `user` VALUES (3, 3, '李六', '女', 12345, '12345'); + +SET FOREIGN_KEY_CHECKS = 1; + + +``` + +查询数据![image-20240908130759511](https://gitee.com/chenqi85689/picture-bed/raw/master/images/202409082003675.png) + +## RBAC是什么? + +Role-Based Access Control,中文意思是:**基于角色(Role)的访问控制。** + +简单来说,就是通过将**权限**分配给**角色**,再将**角色**分配给用户,来实现对系统资源的访问控制。 + +用户与角色之间,角色与权限之间,一般者是多对多的关系。具体而言,RBAC模型定义了以下几个核心概念: + +1. 角色(Role):角色是指在系统中具有一组相关权限的抽象概念,代表了用户在特定上下文中的身份或职能,**例如管理员、普通用户等。** +2. 权限(Permission):权限是指对系统资源进行操作的许可,**如读取、写入、修改等。权限可以被分配给角色。** +3. 用户(User):**用户是指系统的实际使用者,每个用户可以被分配一个或多个角色。** +4. 分配(Assignment):分配是指将角色与用户关联起来,以赋予用户相应的权限 \ No newline at end of file