diff --git a/backend/app/admin/model/role.py b/backend/app/admin/model/role.py index 3ac756f41..0a9d63266 100644 --- a/backend/app/admin/model/role.py +++ b/backend/app/admin/model/role.py @@ -25,7 +25,7 @@ class Role(Base): name: Mapped[str] = mapped_column(String(20), unique=True, comment='角色名称') status: Mapped[int] = mapped_column(default=1, comment='角色状态(0停用 1正常)') is_filter_scopes: Mapped[bool] = mapped_column( - Boolean().with_variant(INTEGER, 'postgresql'), default=False, comment='过滤数据权限(0否 1是)' + Boolean().with_variant(INTEGER, 'postgresql'), default=True, comment='过滤数据权限(0否 1是)' ) remark: Mapped[str | None] = mapped_column( LONGTEXT().with_variant(TEXT, 'postgresql'), default=None, comment='备注' diff --git a/backend/app/admin/schema/role.py b/backend/app/admin/schema/role.py index a322b1bae..353c5ac49 100644 --- a/backend/app/admin/schema/role.py +++ b/backend/app/admin/schema/role.py @@ -15,7 +15,7 @@ class RoleSchemaBase(SchemaBase): name: str = Field(description='角色名称') status: StatusType = Field(StatusType.enable, description='状态') - is_filter_scopes: bool = Field(False, description='过滤数据权限') + is_filter_scopes: bool = Field(True, description='过滤数据权限') remark: str | None = Field(None, description='备注') diff --git a/backend/sql/mysql/create_tables.sql b/backend/sql/mysql/create_tables.sql index ac5086ae6..02e3a48b6 100644 --- a/backend/sql/mysql/create_tables.sql +++ b/backend/sql/mysql/create_tables.sql @@ -288,13 +288,14 @@ create index ix_sys_opera_log_id create table sys_role ( - id int auto_increment comment '主键 ID' + id int auto_increment comment '主键 ID' primary key, - name varchar(20) not null comment '角色名称', - status int not null comment '角色状态(0停用 1正常)', - remark longtext null comment '备注', - created_time datetime not null comment '创建时间', - updated_time datetime null comment '更新时间', + name varchar(20) not null comment '角色名称', + status int not null comment '角色状态(0停用 1正常)', + is_filter_scopes tinyint(1) not null comment '过滤数据权限(0否 1是)', + remark longtext null comment '备注', + created_time datetime not null comment '创建时间', + updated_time datetime null comment '更新时间', constraint name unique (name) ) diff --git a/backend/sql/mysql/init_test_data.sql b/backend/sql/mysql/init_test_data.sql index cfd86c088..af1086ab0 100644 --- a/backend/sql/mysql/init_test_data.sql +++ b/backend/sql/mysql/init_test_data.sql @@ -25,14 +25,14 @@ values (1, '测试', 'Test', 'test', 0, null, 0, null, null, 0, 0, 0, null, nul (21, '官网', 'Site', '', 998, 'dashicons:admin-site', 4, null, null, 1, 1, 0, 'https://fastapi-practices.github.io/fastapi_best_architecture_docs/', null, null, '2024-07-27 19:22:24', null), (22, '赞助', 'Sponsor', '', 999, 'material-icon-theme:github-sponsors', 4, null, null, 1, 1, 0, 'https://wu-clan.github.io/sponsor/', null, null, '2024-07-27 12:39:57', null); -insert into sys_role (id, name, status, remark, created_time, updated_time) -values (1, 'test', 1, null, '2023-06-26 17:13:45', null); +insert into sys_role (id, name, status, is_filter_scopes, remark, created_time, updated_time) +values (1, 'test', 1, 1, null, '2023-06-26 17:13:45', null); insert into sys_role_menu (id, role_id, menu_id) values (1, 1, 1); insert into sys_user (id, uuid, username, nickname, password, salt, email, is_superuser, is_staff, status, is_multi_login, avatar, phone, join_time, last_login_time, dept_id, created_time, updated_time) -values (1, 'af4c804f-3966-4949-ace2-3bb7416ea926', 'admin', '用户88888', '$2b$12$8y2eNucX19VjmZ3tYhBLcOsBwy9w1IjBQE4SSqwMDL5bGQVp2wqS.', 0x24326224313224387932654E7563583139566A6D5A33745968424C634F, 'admin@example.com', 1, 1, 1, 0, null, null, '2023-06-26 17:13:45', '2024-11-18 13:53:57', 1, '2023-06-26 17:13:45', '2024-11-18 13:53:57'); +values (1, 'af4c804f-3966-4949-ace2-3bb7416ea926', 'admin', '用户88888', '$2b$12$8y2eNucX19VjmZ3tYhBLcOsBwy9w1IjBQE4SSqwMDL5bGQVp2wqS.', 0x24326224313224387932654E7563583139566A6D5A33745968424C634F, 'admin@example.com', 1, 1, 1, 1, null, null, '2023-06-26 17:13:45', '2024-11-18 13:53:57', 1, '2023-06-26 17:13:45', '2024-11-18 13:53:57'); insert into sys_user_role (id, user_id, role_id) values (1, 1, 1); diff --git a/backend/sql/postgresql/create_tables.sql b/backend/sql/postgresql/create_tables.sql index 11d53033f..547cfb854 100644 --- a/backend/sql/postgresql/create_tables.sql +++ b/backend/sql/postgresql/create_tables.sql @@ -268,14 +268,15 @@ create index ix_sys_opera_log_id create table sys_role ( - id serial + id serial primary key, - name varchar(20) not null + name varchar(20) not null unique, - status integer not null, - remark text, - created_time timestamp with time zone not null, - updated_time timestamp with time zone + status integer not null, + is_filter_scopes integer not null, + remark text, + created_time timestamp with time zone not null, + updated_time timestamp with time zone ); comment on table sys_role is '角色表'; @@ -286,6 +287,8 @@ comment on column sys_role.name is '角色名称'; comment on column sys_role.status is '角色状态(0停用 1正常)'; +comment on column sys_role.is_filter_scopes is '过滤数据权限(0否 1是)'; + comment on column sys_role.remark is '备注'; comment on column sys_role.created_time is '创建时间'; diff --git a/backend/sql/postgresql/init_test_data.sql b/backend/sql/postgresql/init_test_data.sql index d2186d743..1c6c78972 100644 --- a/backend/sql/postgresql/init_test_data.sql +++ b/backend/sql/postgresql/init_test_data.sql @@ -25,14 +25,14 @@ values (1, '测试', 'Test', 'test', 0, null, 0, null, null, 0, 0, 0, null, nul (21, '官网', 'Site', '', 998, 'dashicons:admin-site', 4, null, null, 1, 1, 0, 'https://fastapi-practices.github.io/fastapi_best_architecture_docs/', null, null, '2024-07-27 19:22:24', null), (22, '赞助', 'Sponsor', '', 999, 'material-icon-theme:github-sponsors', 4, null, null, 1, 1, 0, 'https://wu-clan.github.io/sponsor/', null, null, '2024-07-27 12:39:57', null); -insert into sys_role (id, name, status, remark, created_time, updated_time) -values (1, 'test', 1, null, '2023-06-26 17:13:45', null); +insert into sys_role (id, name, status, is_filter_scopes, remark, created_time, updated_time) +values (1, 'test', 1, 1, null, '2023-06-26 17:13:45', null); insert into sys_role_menu (id, role_id, menu_id) values (1, 1, 1); insert into sys_user (id, uuid, username, nickname, password, salt, email, is_superuser, is_staff, status, is_multi_login, avatar, phone, join_time, last_login_time, dept_id, created_time, updated_time) -values (1, 'af4c804f-3966-4949-ace2-3bb7416ea926', 'admin', '用户88888', '$2b$12$8y2eNucX19VjmZ3tYhBLcOsBwy9w1IjBQE4SSqwMDL5bGQVp2wqS.', '0x24326224313224387932654E7563583139566A6D5A33745968424C634F', 'admin@example.com', 1, 1, 1, 0, null, null, '2023-06-26 17:13:45', '2024-11-18 13:53:57', 1, '2023-06-26 17:13:45', '2024-11-18 13:53:57'); +values (1, 'af4c804f-3966-4949-ace2-3bb7416ea926', 'admin', '用户88888', '$2b$12$8y2eNucX19VjmZ3tYhBLcOsBwy9w1IjBQE4SSqwMDL5bGQVp2wqS.', '0x24326224313224387932654E7563583139566A6D5A33745968424C634F', 'admin@example.com', 1, 1, 1, 1, null, null, '2023-06-26 17:13:45', '2024-11-18 13:53:57', 1, '2023-06-26 17:13:45', '2024-11-18 13:53:57'); insert into sys_user_role (id, user_id, role_id) values (1, 1, 1);