Skip to content

Commit 7bab8cc

Browse files
authored
Update default value for role filter scopes (#649)
1 parent 7659b63 commit 7bab8cc

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

backend/app/admin/model/role.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Role(Base):
2525
name: Mapped[str] = mapped_column(String(20), unique=True, comment='角色名称')
2626
status: Mapped[int] = mapped_column(default=1, comment='角色状态(0停用 1正常)')
2727
is_filter_scopes: Mapped[bool] = mapped_column(
28-
Boolean().with_variant(INTEGER, 'postgresql'), default=False, comment='过滤数据权限(0否 1是)'
28+
Boolean().with_variant(INTEGER, 'postgresql'), default=True, comment='过滤数据权限(0否 1是)'
2929
)
3030
remark: Mapped[str | None] = mapped_column(
3131
LONGTEXT().with_variant(TEXT, 'postgresql'), default=None, comment='备注'

backend/app/admin/schema/role.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RoleSchemaBase(SchemaBase):
1515

1616
name: str = Field(description='角色名称')
1717
status: StatusType = Field(StatusType.enable, description='状态')
18-
is_filter_scopes: bool = Field(False, description='过滤数据权限')
18+
is_filter_scopes: bool = Field(True, description='过滤数据权限')
1919
remark: str | None = Field(None, description='备注')
2020

2121

backend/sql/mysql/create_tables.sql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,14 @@ create index ix_sys_opera_log_id
288288

289289
create table sys_role
290290
(
291-
id int auto_increment comment '主键 ID'
291+
id int auto_increment comment '主键 ID'
292292
primary key,
293-
name varchar(20) not null comment '角色名称',
294-
status int not null comment '角色状态(0停用 1正常)',
295-
remark longtext null comment '备注',
296-
created_time datetime not null comment '创建时间',
297-
updated_time datetime null comment '更新时间',
293+
name varchar(20) not null comment '角色名称',
294+
status int not null comment '角色状态(0停用 1正常)',
295+
is_filter_scopes tinyint(1) not null comment '过滤数据权限(0否 1是)',
296+
remark longtext null comment '备注',
297+
created_time datetime not null comment '创建时间',
298+
updated_time datetime null comment '更新时间',
298299
constraint name
299300
unique (name)
300301
)

backend/sql/mysql/init_test_data.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ values (1, '测试', 'Test', 'test', 0, null, 0, null, null, 0, 0, 0, null, nul
2525
(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),
2626
(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);
2727

28-
insert into sys_role (id, name, status, remark, created_time, updated_time)
29-
values (1, 'test', 1, null, '2023-06-26 17:13:45', null);
28+
insert into sys_role (id, name, status, is_filter_scopes, remark, created_time, updated_time)
29+
values (1, 'test', 1, 1, null, '2023-06-26 17:13:45', null);
3030

3131
insert into sys_role_menu (id, role_id, menu_id)
3232
values (1, 1, 1);
3333

3434
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)
35-
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');
35+
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');
3636

3737
insert into sys_user_role (id, user_id, role_id)
3838
values (1, 1, 1);

backend/sql/postgresql/create_tables.sql

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,15 @@ create index ix_sys_opera_log_id
268268

269269
create table sys_role
270270
(
271-
id serial
271+
id serial
272272
primary key,
273-
name varchar(20) not null
273+
name varchar(20) not null
274274
unique,
275-
status integer not null,
276-
remark text,
277-
created_time timestamp with time zone not null,
278-
updated_time timestamp with time zone
275+
status integer not null,
276+
is_filter_scopes integer not null,
277+
remark text,
278+
created_time timestamp with time zone not null,
279+
updated_time timestamp with time zone
279280
);
280281

281282
comment on table sys_role is '角色表';
@@ -286,6 +287,8 @@ comment on column sys_role.name is '角色名称';
286287

287288
comment on column sys_role.status is '角色状态(0停用 1正常)';
288289

290+
comment on column sys_role.is_filter_scopes is '过滤数据权限(0否 1是)';
291+
289292
comment on column sys_role.remark is '备注';
290293

291294
comment on column sys_role.created_time is '创建时间';

backend/sql/postgresql/init_test_data.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ values (1, '测试', 'Test', 'test', 0, null, 0, null, null, 0, 0, 0, null, nul
2525
(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),
2626
(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);
2727

28-
insert into sys_role (id, name, status, remark, created_time, updated_time)
29-
values (1, 'test', 1, null, '2023-06-26 17:13:45', null);
28+
insert into sys_role (id, name, status, is_filter_scopes, remark, created_time, updated_time)
29+
values (1, 'test', 1, 1, null, '2023-06-26 17:13:45', null);
3030

3131
insert into sys_role_menu (id, role_id, menu_id)
3232
values (1, 1, 1);
3333

3434
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)
35-
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');
35+
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');
3636

3737
insert into sys_user_role (id, user_id, role_id)
3838
values (1, 1, 1);

0 commit comments

Comments
 (0)