diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql b/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql index 2e87336901..76c6e053fe 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/data/mysql-data.sql @@ -189,130 +189,13 @@ insert into `t_menu` values (150502, 150500, 'member add', null, null, 'member:a insert into `t_menu` values (150503, 150500, 'member update', null, null, 'member:update', null, '1', 1, null, now(), now()); insert into `t_menu` values (150504, 150500, 'member delete', null, null, 'member:delete', null, '1', 1, null, now(), now()); --- ---------------------------- --- Records of t_role --- ---------------------------- -insert into `t_role` values (100001, 'developer', now(), now(), 'developer'); -insert into `t_role` values (100002, 'team admin', now(), now(), 'Team Admin has all permissions inside the team.'); - --- ---------------------------- --- Records of t_role_menu --- ---------------------------- -insert into `t_role_menu` values (100000, 100001, 110000); -insert into `t_role_menu` values (100001, 100001, 110100); -insert into `t_role_menu` values (100002, 100001, 110101); -insert into `t_role_menu` values (100003, 100001, 110102); -insert into `t_role_menu` values (100004, 100001, 110103); -insert into `t_role_menu` values (100005, 100001, 110104); -insert into `t_role_menu` values (100006, 100001, 110105); -insert into `t_role_menu` values (100007, 100001, 110106); -insert into `t_role_menu` values (100008, 100001, 110107); -insert into `t_role_menu` values (100009, 100001, 110108); -insert into `t_role_menu` values (100010, 100001, 110109); -insert into `t_role_menu` values (100011, 100001, 110110); -insert into `t_role_menu` values (100012, 100001, 110111); -insert into `t_role_menu` values (100013, 100001, 110112); -insert into `t_role_menu` values (100014, 100001, 110113); -insert into `t_role_menu` values (100015, 100001, 110114); -insert into `t_role_menu` values (100016, 100001, 110115); -insert into `t_role_menu` values (100017, 100001, 110116); -insert into `t_role_menu` values (100018, 100001, 110117); -insert into `t_role_menu` values (100019, 100001, 110118); -insert into `t_role_menu` values (100020, 100001, 110200); -insert into `t_role_menu` values (100021, 100001, 110300); -insert into `t_role_menu` values (100022, 100001, 110301); -insert into `t_role_menu` values (100023, 100001, 110302); -insert into `t_role_menu` values (100024, 100001, 120000); -insert into `t_role_menu` values (100025, 100001, 130000); -insert into `t_role_menu` values (100026, 100001, 130100); -insert into `t_role_menu` values (100027, 100001, 130101); -insert into `t_role_menu` values (100028, 100001, 130102); -insert into `t_role_menu` values (100029, 100001, 130103); -insert into `t_role_menu` values (100030, 100001, 130104); -insert into `t_role_menu` values (100031, 100001, 130105); -insert into `t_role_menu` values (100032, 100001, 130200); -insert into `t_role_menu` values (100033, 100001, 130201); -insert into `t_role_menu` values (100034, 100001, 130202); -insert into `t_role_menu` values (100035, 100001, 130203); -insert into `t_role_menu` values (100036, 100001, 130204); -insert into `t_role_menu` values (100037, 100001, 130205); -insert into `t_role_menu` values (100038, 100001, 130206); -insert into `t_role_menu` values (100039, 100001, 130207); -insert into `t_role_menu` values (100040, 100001, 130300); -insert into `t_role_menu` values (100041, 100001, 130301); -insert into `t_role_menu` values (100042, 100001, 130302); -insert into `t_role_menu` values (100043, 100001, 130303); -insert into `t_role_menu` values (100044, 100001, 140000); -insert into `t_role_menu` values (100045, 100001, 140100); -insert into `t_role_menu` values (100046, 100001, 140101); -insert into `t_role_menu` values (100047, 100002, 110000); -insert into `t_role_menu` values (100048, 100002, 110100); -insert into `t_role_menu` values (100049, 100002, 110101); -insert into `t_role_menu` values (100050, 100002, 110102); -insert into `t_role_menu` values (100051, 100002, 110103); -insert into `t_role_menu` values (100052, 100002, 110104); -insert into `t_role_menu` values (100053, 100002, 110105); -insert into `t_role_menu` values (100054, 100002, 110106); -insert into `t_role_menu` values (100055, 100002, 110107); -insert into `t_role_menu` values (100056, 100002, 110108); -insert into `t_role_menu` values (100057, 100002, 110109); -insert into `t_role_menu` values (100058, 100002, 110110); -insert into `t_role_menu` values (100059, 100002, 110111); -insert into `t_role_menu` values (100060, 100002, 110112); -insert into `t_role_menu` values (100061, 100002, 110113); -insert into `t_role_menu` values (100062, 100002, 110114); -insert into `t_role_menu` values (100063, 100002, 110115); -insert into `t_role_menu` values (100064, 100002, 110116); -insert into `t_role_menu` values (100065, 100002, 110117); -insert into `t_role_menu` values (100066, 100002, 110118); -insert into `t_role_menu` values (100067, 100002, 110200); -insert into `t_role_menu` values (100068, 100002, 110300); -insert into `t_role_menu` values (100069, 100002, 110301); -insert into `t_role_menu` values (100070, 100002, 110302); -insert into `t_role_menu` values (100071, 100002, 120000); -insert into `t_role_menu` values (100072, 100002, 130000); -insert into `t_role_menu` values (100073, 100002, 130100); -insert into `t_role_menu` values (100074, 100002, 130101); -insert into `t_role_menu` values (100075, 100002, 130102); -insert into `t_role_menu` values (100076, 100002, 130103); -insert into `t_role_menu` values (100077, 100002, 130104); -insert into `t_role_menu` values (100078, 100002, 130105); -insert into `t_role_menu` values (100079, 100002, 130200); -insert into `t_role_menu` values (100080, 100002, 130201); -insert into `t_role_menu` values (100081, 100002, 130202); -insert into `t_role_menu` values (100082, 100002, 130203); -insert into `t_role_menu` values (100083, 100002, 130204); -insert into `t_role_menu` values (100084, 100002, 130205); -insert into `t_role_menu` values (100085, 100002, 130206); -insert into `t_role_menu` values (100086, 100002, 130207); -insert into `t_role_menu` values (100087, 100002, 130300); -insert into `t_role_menu` values (100088, 100002, 130301); -insert into `t_role_menu` values (100089, 100002, 130302); -insert into `t_role_menu` values (100090, 100002, 130303); -insert into `t_role_menu` values (100091, 100002, 140000); -insert into `t_role_menu` values (100092, 100002, 140100); -insert into `t_role_menu` values (100093, 100002, 140101); -insert into `t_role_menu` values (100094, 100002, 140102); -insert into `t_role_menu` values (100095, 100002, 140200); -insert into `t_role_menu` values (100096, 100002, 140300); -insert into `t_role_menu` values (100097, 100002, 140301); -insert into `t_role_menu` values (100098, 100002, 140302); -insert into `t_role_menu` values (100099, 100002, 140303); -insert into `t_role_menu` values (100100, 100002, 140304); -insert into `t_role_menu` values (100101, 100002, 140400); -insert into `t_role_menu` values (100102, 100002, 140401); -insert into `t_role_menu` values (100103, 100002, 140402); -insert into `t_role_menu` values (100104, 100002, 140403); -insert into `t_role_menu` values (100105, 100002, 150000); -insert into `t_role_menu` values (100106, 100002, 150500); -insert into `t_role_menu` values (100107, 100002, 150501); -insert into `t_role_menu` values (100108, 100002, 150502); -insert into `t_role_menu` values (100109, 100002, 150503); -insert into `t_role_menu` values (100110, 100002, 150504); - -- ---------------------------- -- Records of t_setting -- ---------------------------- +delete from `t_menu` +where `type` = '1' + or `path` in ('/system/menu', '/system/role', '/system/team', '/system/member', '/system/token'); + insert into `t_setting` values (1, 'streampark.maven.settings', null, 'Maven Settings File Path', 'Maven Settings.xml full path', 1); insert into `t_setting` values (2, 'streampark.maven.central.repository', null, 'Maven Central Repository', 'Maven private server address', 1); insert into `t_setting` values (3, 'streampark.maven.auth.user', null, 'Maven Central Repository Auth User', 'Maven private server authentication username', 1); @@ -333,9 +216,4 @@ insert into `t_setting` values (15, 'ingress.mode.default', null, 'Ingress domai -- ---------------------------- insert into `t_user` values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, 0, 100000, '1', now(), now(),null,0,null,null); --- ---------------------------- --- Records of t_member --- ---------------------------- -insert into `t_member` values (100000, 100000, 100000, 100001, now(), now()); - set foreign_key_checks = 1; diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql b/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql index a3f2d6c354..e9c3156ab2 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/data/pgsql-data.sql @@ -154,114 +154,13 @@ insert into "public"."t_menu" values (130601, 130600, 'add yarn queue', null, nu insert into "public"."t_menu" values (130602, 130600, 'edit yarn queue', null, null, 'yarnQueue:update', '', '1', '0', null, now(), now()); insert into "public"."t_menu" values (130603, 130600, 'delete yarn queue', null, null, 'yarnQueue:delete', '', '1', '0', null, now(), now()); --- ---------------------------- --- Records of t_role --- ---------------------------- -insert into "public"."t_role" values (100001, 'developer', now(), now(), 'developer'); -insert into "public"."t_role" values (100002, 'team admin', now(), now(), 'Team Admin has all permissions inside the team.'); - --- ---------------------------- --- Records of t_role_menu --- ---------------------------- -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120000); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120100); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120101); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120102); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120104); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120105); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120200); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120201); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120202); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120203); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120204); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120206); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120207); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120208); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120209); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120210); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120211); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120212); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120213); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120215); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120216); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120217); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120300); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120304); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120306); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120307); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120400); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120401); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120402); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 120403); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 130000); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 130100); -insert into "public"."t_role_menu" (role_id, menu_id) values (100001, 130101); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 110000); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 110600); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 110601); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 110602); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 110603); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 110604); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 110605); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120000); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120100); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120101); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120102); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120103); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120104); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120105); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120200); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120201); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120202); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120203); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120204); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120205); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120206); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120207); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120208); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120209); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120210); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120211); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120212); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120213); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120214); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120215); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120216); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120217); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120218); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120300); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120301); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120302); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120303); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120304); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120305); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120306); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120307); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120400); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120401); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120402); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 120403); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130000); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130100); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130101); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130200); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130300); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130400); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130401); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130402); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130500); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130501); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130502); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130503); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130504); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130600); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130601); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130602); -insert into "public"."t_role_menu" (role_id, menu_id) values (100002, 130603); - -- ---------------------------- -- Records of t_setting -- ---------------------------- +delete from "public"."t_menu" +where "type" = '1' + or "path" in ('/system/menu', '/system/role', '/system/team', '/system/member', '/system/token'); + insert into "public"."t_setting" values (1, 'streampark.maven.settings', null, 'Maven Settings File Path', 'Maven Settings.xml full path', 1); insert into "public"."t_setting" values (2, 'streampark.maven.central.repository', null, 'Maven Central Repository', 'Maven private server address', 1); insert into "public"."t_setting" values (3, 'streampark.maven.auth.user', null, 'Maven Central Repository Auth User', 'Maven private server authentication username', 1); @@ -282,8 +181,3 @@ insert into "public"."t_setting" values (15, 'ingress.mode.default', null, 'Ingr -- Records of t_user -- ---------------------------- insert into "public"."t_user" values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, 0, 100000, '1', now(), now(), null, 0, null, null); - --- ---------------------------- --- Records of t_member --- ---------------------------- -insert into "public"."t_member" values (100000, 100000, 100000, 100001, now(), now()); diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql b/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql index db29202ced..6e082a91c7 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/schema/mysql-schema.sql @@ -339,33 +339,6 @@ create table `t_variable` ( ) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci; --- ---------------------------- --- Table structure for t_role --- ---------------------------- -drop table if exists `t_role`; -create table `t_role` ( - `role_id` bigint not null auto_increment comment 'user id', - `role_name` varchar(64) collate utf8mb4_general_ci not null comment 'role name', - `create_time` datetime default null comment 'create time', - `modify_time` datetime default null comment 'modify time', - `description` varchar(255) collate utf8mb4_general_ci default null comment 'description', - primary key (`role_id`) using btree -) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci; - - --- ---------------------------- --- Table structure for t_role_menu --- ---------------------------- -drop table if exists `t_role_menu`; -create table `t_role_menu` ( - `id` bigint not null auto_increment, - `role_id` bigint not null, - `menu_id` bigint not null, - primary key (`id`) using btree, - unique key `un_role_menu_inx` (`role_id`,`menu_id`) using btree -) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci; - - -- ---------------------------- -- Table structure for t_setting -- ---------------------------- @@ -392,7 +365,7 @@ create table `t_user` ( `salt` varchar(26) collate utf8mb4_general_ci default null comment 'salt', `password` varchar(64) collate utf8mb4_general_ci default null comment 'password', `email` varchar(64) collate utf8mb4_general_ci default null comment 'email', - `user_type` int not null comment 'user type 1:admin 2:user', + `user_type` int not null comment 'user role 1:admin 2:editor', `login_type` tinyint default 0 comment 'login type 0:password 1:ldap 2:sso', `last_team_id` bigint default null comment 'last team id', `status` char(1) collate utf8mb4_general_ci not null comment 'status 0:locked 1:active', @@ -407,22 +380,6 @@ create table `t_user` ( ) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci; --- ---------------------------- --- Table structure for t_member --- ---------------------------- -drop table if exists `t_member`; -create table `t_member` ( - `id` bigint not null auto_increment, - `team_id` bigint not null comment 'team id', - `user_id` bigint not null comment 'user id', - `role_id` bigint not null comment 'role id', - `create_time` datetime default null comment 'create time', - `modify_time` datetime default null comment 'modify time', - primary key (`id`) using btree, - unique key `un_user_team_role_inx` (`user_id`,`team_id`,`role_id`) using btree -) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci; - - -- ---------------------------- -- Table of t_app_build_pipe -- ---------------------------- diff --git a/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql b/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql index a638e7eebd..f20b07ea23 100644 --- a/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql +++ b/streampark-console/streampark-console-service/src/main/assembly/script/schema/pgsql-schema.sql @@ -20,10 +20,7 @@ -- ---------------------------- drop table if exists "public"."t_user"; -drop table if exists "public"."t_member"; drop table if exists "public"."t_setting"; -drop table if exists "public"."t_role"; -drop table if exists "public"."t_role_menu"; drop table if exists "public"."t_menu"; drop table if exists "public"."t_message"; drop table if exists "public"."t_flink_sql"; @@ -49,9 +46,6 @@ drop table if exists "public"."t_yarn_queue"; -- drop sequence if exists -- ---------------------------- drop sequence if exists "public"."streampark_t_user_id_seq"; -drop sequence if exists "public"."streampark_t_member_id_seq"; -drop sequence if exists "public"."streampark_t_role_id_seq"; -drop sequence if exists "public"."streampark_t_role_menu_id_seq"; drop sequence if exists "public"."streampark_t_menu_id_seq"; drop sequence if exists "public"."streampark_t_message_id_seq"; drop sequence if exists "public"."streampark_t_flink_sql_id_seq"; @@ -80,7 +74,6 @@ drop trigger if exists "streampark_t_app_build_pipe_modify_time_tri" on "public" drop trigger if exists "streampark_t_flink_app_modify_time_tri" on "public"."t_flink_app"; drop trigger if exists "streampark_t_flink_project_modify_time_tri" on "public"."t_flink_project"; drop trigger if exists "streampark_t_menu_modify_time_tri" on "public"."t_menu"; -drop trigger if exists "streampark_t_role_modify_time_tri" on "public"."t_role"; drop trigger if exists "streampark_t_user_modify_time_tri" on "public"."t_user"; drop trigger if exists "streampark_t_alert_config_modify_time_tri" on "public"."t_alert_config"; @@ -671,47 +664,6 @@ create index "un_team_dname_inx" on "public"."t_resource" using btree ( "resource_name" collate "pg_catalog"."default" "pg_catalog"."text_ops" asc nulls last ); --- ---------------------------- --- table structure for t_role --- ---------------------------- -create sequence "public"."streampark_t_role_id_seq" - increment 1 start 10000 cache 1 minvalue 10000 maxvalue 9223372036854775807; - -create table "public"."t_role" ( - "role_id" int8 not null default nextval('streampark_t_role_id_seq'::regclass), - "role_name" varchar(64) collate "pg_catalog"."default" not null, - "create_time" timestamp(6), - "modify_time" timestamp(6), - "description" varchar(255) collate "pg_catalog"."default" -) -; -comment on column "public"."t_role"."role_id" is 'role id'; -comment on column "public"."t_role"."role_name" is 'role name'; -comment on column "public"."t_role"."description" is 'role description'; -comment on column "public"."t_role"."create_time" is 'creation time'; -comment on column "public"."t_role"."modify_time" is 'modify time'; -alter table "public"."t_role" add constraint "t_role_pkey" primary key ("role_id"); - - --- ---------------------------- --- table structure for t_role_menu --- ---------------------------- -create sequence "public"."streampark_t_role_menu_id_seq" - increment 1 start 10000 cache 1 minvalue 10000 maxvalue 9223372036854775807; - -create table "public"."t_role_menu" ( - "id" int8 not null default nextval('streampark_t_role_menu_id_seq'::regclass), - "role_id" int8 not null, - "menu_id" int8 not null -) -; -alter table "public"."t_role_menu" add constraint "t_role_menu_pkey" primary key ("id"); -create index "un_role_menu_inx" on "public"."t_role_menu" using btree ( - "role_id" "pg_catalog"."int8_ops" asc nulls last, - "menu_id" "pg_catalog"."int8_ops" asc nulls last -); - - -- ---------------------------- -- table structure for t_setting -- ---------------------------- @@ -758,7 +710,7 @@ comment on column "public"."t_user"."nick_name" is 'nick name'; comment on column "public"."t_user"."salt" is 'salt'; comment on column "public"."t_user"."password" is 'password'; comment on column "public"."t_user"."email" is 'email'; -comment on column "public"."t_user"."user_type" is 'user type 1:admin 2:user'; +comment on column "public"."t_user"."user_type" is 'user role 1:admin 2:editor'; comment on column "public"."t_user"."login_type" is 'login type 0:password 1:ldap 2:sso'; comment on column "public"."t_user"."last_team_id" is 'last team id'; comment on column "public"."t_user"."status" is 'status 0:locked 1:active'; @@ -774,32 +726,6 @@ create index "un_username" on "public"."t_user" using btree ( ); --- ---------------------------- --- table structure for t_member --- ---------------------------- -create sequence "public"."streampark_t_member_id_seq" - increment 1 start 10000 cache 1 minvalue 10000 maxvalue 9223372036854775807; - -create table "public"."t_member" ( - "id" int8 not null default nextval('streampark_t_member_id_seq'::regclass), - "team_id" int8, - "user_id" int8, - "role_id" int8, - "create_time" timestamp(6), - "modify_time" timestamp(6) -) -; -comment on column "public"."t_member"."team_id" is 'team id'; -comment on column "public"."t_member"."user_id" is 'user id'; -comment on column "public"."t_member"."role_id" is 'role id'; -alter table "public"."t_member" add constraint "t_member_pkey" primary key ("id"); -create index "un_user_role_inx" on "public"."t_member" using btree ( - "team_id" "pg_catalog"."int8_ops" asc nulls last, - "user_id" "pg_catalog"."int8_ops" asc nulls last, - "role_id" "pg_catalog"."int8_ops" asc nulls last -); - - -- ---------------------------- -- table structure for t_external_link -- ---------------------------- @@ -861,5 +787,4 @@ create trigger "streampark_t_access_token_modify_time_tri" before update on "pub create trigger "streampark_t_flink_app_modify_time_tri" before update on "public"."t_flink_app" for each row execute procedure "public"."update_modify_time"(); create trigger "streampark_t_flink_project_modify_time_tri" before update on "public"."t_flink_project" for each row execute procedure "public"."update_modify_time"(); create trigger "streampark_t_menu_modify_time_tri" before update on "public"."t_menu" for each row execute procedure "public"."update_modify_time"(); -create trigger "streampark_t_role_modify_time_tri" before update on "public"."t_role" for each row execute procedure "public"."update_modify_time"(); create trigger "streampark_t_user_modify_time_tri" before update on "public"."t_user" for each row execute procedure "public"."update_modify_time"(); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/annotation/Permission.java b/streampark-console/streampark-console-service/src/main/assembly/script/upgrade/mysql/3.0.0.sql similarity index 62% rename from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/annotation/Permission.java rename to streampark-console/streampark-console-service/src/main/assembly/script/upgrade/mysql/3.0.0.sql index 491dccd6fb..514c0bcf20 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/annotation/Permission.java +++ b/streampark-console/streampark-console-service/src/main/assembly/script/upgrade/mysql/3.0.0.sql @@ -15,20 +15,18 @@ * limitations under the License. */ -package org.apache.streampark.console.core.annotation; +use streampark; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +-- Map legacy team-admin membership to the built-in ADMIN user type before dropping role tables. +update `t_user` u + inner join `t_member` m on u.`user_id` = m.`user_id` +set u.`user_type` = 1 +where m.`role_id` = 100002; -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Permission { +delete from `t_menu` +where `type` = '1' + or `path` in ('/system/menu', '/system/role', '/system/team', '/system/member', '/system/token'); - String user() default ""; - - String team() default ""; - - String app() default ""; -} +drop table if exists `t_role_menu`; +drop table if exists `t_member`; +drop table if exists `t_role`; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/MemberMapper.java b/streampark-console/streampark-console-service/src/main/assembly/script/upgrade/pgsql/3.0.0.sql similarity index 53% rename from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/MemberMapper.java rename to streampark-console/streampark-console-service/src/main/assembly/script/upgrade/pgsql/3.0.0.sql index 9893db1aee..b01cff889a 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/MemberMapper.java +++ b/streampark-console/streampark-console-service/src/main/assembly/script/upgrade/pgsql/3.0.0.sql @@ -15,22 +15,21 @@ * limitations under the License. */ -package org.apache.streampark.console.system.mapper; - -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.entity.User; - -import org.apache.ibatis.annotations.Param; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - -import java.util.List; - -public interface MemberMapper extends BaseMapper { - - IPage selectPage(Page page, @Param("member") Member member); - - List selectUsersNotInTeam(@Param("teamId") Long teamId); -} +-- Map legacy team-admin membership to the built-in ADMIN user type before dropping role tables. +update "public"."t_user" u +set user_type = 1 +from "public"."t_member" m +where u.user_id = m.user_id + and m.role_id = 100002; + +delete from "public"."t_menu" +where "type" = '1' + or "path" in ('/system/menu', '/system/role', '/system/team', '/system/member', '/system/token'); + +drop table if exists "public"."t_role_menu"; +drop table if exists "public"."t_member"; +drop table if exists "public"."t_role"; + +drop sequence if exists "public"."streampark_t_role_menu_id_seq"; +drop sequence if exists "public"."streampark_t_member_id_seq"; +drop sequence if exists "public"."streampark_t_role_id_seq"; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java index 2231f7062a..1b52804ef2 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java @@ -33,5 +33,4 @@ public class Constant { public static final Long DEFAULT_TEAM_ID = 100000L; - public static final Long DEFAULT_ROLE_ID = 100001L; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/aspect/PermissionAspect.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/aspect/PermissionAspect.java deleted file mode 100644 index 7553974407..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/aspect/PermissionAspect.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.core.aspect; - -import org.apache.streampark.console.base.exception.ApiAlertException; -import org.apache.streampark.console.core.annotation.Permission; -import org.apache.streampark.console.core.entity.FlinkApplication; -import org.apache.streampark.console.core.enums.UserTypeEnum; -import org.apache.streampark.console.core.service.application.FlinkApplicationManageService; -import org.apache.streampark.console.core.util.ServiceHelper; -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.entity.User; -import org.apache.streampark.console.system.service.MemberService; - -import org.apache.commons.lang3.StringUtils; - -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.DefaultParameterNameDiscoverer; -import org.springframework.expression.EvaluationContext; -import org.springframework.expression.Expression; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.expression.spel.support.StandardEvaluationContext; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -@Aspect -public class PermissionAspect { - - @Autowired - private MemberService memberService; - - @Autowired - private FlinkApplicationManageService applicationManageService; - - @Pointcut("@annotation(org.apache.streampark.console.core.annotation.Permission)") - public void permissionPointcut() { - } - - @Around("permissionPointcut()") - public Object permissionAction(ProceedingJoinPoint joinPoint) throws Throwable { - MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); - Permission permission = methodSignature.getMethod().getAnnotation(Permission.class); - - User currentUser = ServiceHelper.getLoginUser(); - ApiAlertException.throwIfNull(currentUser, "Permission denied, please login first."); - - boolean isAdmin = currentUser.getUserType() == UserTypeEnum.ADMIN; - - if (!isAdmin) { - // 1) check userId - Long userId = getId(joinPoint, methodSignature, permission.user()); - ApiAlertException.throwIfTrue( - userId != null && !currentUser.getUserId().equals(userId), - "Permission denied, operations can only be performed with the permissions of the currently logged-in user."); - - // 2) check team - Long teamId = getId(joinPoint, methodSignature, permission.team()); - if (teamId != null) { - Member member = memberService.getByTeamIdUserName(teamId, currentUser.getUsername()); - ApiAlertException.throwIfTrue( - member == null, - "Permission denied, only members of this team can access this permission"); - } - - // 3) check app - Long appId = getId(joinPoint, methodSignature, permission.app()); - if (appId != null) { - FlinkApplication app = applicationManageService.getById(appId); - ApiAlertException.throwIfTrue(app == null, "Invalid operation, application is null"); - if (!currentUser.getUserId().equals(app.getUserId())) { - Member member = memberService.getByTeamIdUserName(app.getTeamId(), currentUser.getUsername()); - ApiAlertException.throwIfTrue( - member == null, - "Permission denied, this job not created by the current user, And the job cannot be found in the current user's team."); - } - } - } - - return joinPoint.proceed(); - } - - private Long getId(ProceedingJoinPoint joinPoint, MethodSignature methodSignature, String expr) { - if (StringUtils.isEmpty(expr)) { - return null; - } - SpelExpressionParser parser = new SpelExpressionParser(); - Expression expression = parser.parseExpression(expr); - EvaluationContext context = new StandardEvaluationContext(); - Object[] args = joinPoint.getArgs(); - DefaultParameterNameDiscoverer discoverer = new DefaultParameterNameDiscoverer(); - String[] parameterNames = discoverer.getParameterNames(methodSignature.getMethod()); - for (int i = 0; i < parameterNames.length; i++) { - context.setVariable(parameterNames[i], args[i]); - } - Object value = expression.getValue(context); - - if (value == null || StringUtils.isBlank(value.toString())) { - return null; - } - try { - return Long.parseLong(value.toString()); - } catch (NumberFormatException e) { - throw new ApiAlertException( - "Wrong use of annotation on method " + methodSignature.getName(), e); - } - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/AlertController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/AlertController.java index 35d7319fb8..15fc16ba1b 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/AlertController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/AlertController.java @@ -34,6 +34,8 @@ import org.apache.streampark.console.core.service.alert.AlertConfigService; import org.apache.streampark.console.core.service.alert.AlertService; +import org.apache.shiro.authz.annotation.RequiresPermissions; + import com.baomidou.mybatisplus.core.metadata.IPage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -63,6 +65,7 @@ public class AlertController { private final AlertService alertService; @PostMapping("/add") + @RequiresPermissions("setting:update") public RestResponseBody createAlertConfig(@Valid @RequestBody AlertConfigRequest request) { boolean save = alertConfigService.save(AlertAssembler.toEntity(request)); return RestResponseBody.success(save); @@ -77,6 +80,7 @@ public RestResponseBody verifyAlertConfig(@Valid @RequestBody AlertConf } @PostMapping("/update") + @RequiresPermissions("setting:update") public RestResponseBody updateAlertConfig(@Valid @RequestBody AlertConfigRequest request) { boolean update = alertConfigService.updateById(AlertAssembler.toEntity(request)); return RestResponseBody.success(update); @@ -102,12 +106,14 @@ public RestResponseBody> listAlertConfig() { } @DeleteMapping("/delete") + @RequiresPermissions("setting:update") public RestResponseBody deleteAlertConfig(@NotNull(message = "{required}") @Valid IdRequest request) { boolean result = alertConfigService.removeById(request.getId()); return RestResponseBody.success(result); } @PostMapping("/send") + @RequiresPermissions("setting:update") public RestResponseBody sendAlert(@Valid AlertSendRequest request) throws AlertException { AlertTemplate alertTemplate = new AlertTemplate(); alertTemplate.setTitle("Notify: StreamPark alert job for test"); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkApplicationController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkApplicationController.java index d3f545f69b..08031452d0 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkApplicationController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkApplicationController.java @@ -24,7 +24,6 @@ import org.apache.streampark.console.base.exception.InternalException; import org.apache.streampark.console.base.web.FormOrJson; import org.apache.streampark.console.core.annotation.AppChangeEvent; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.AppLogAssembler; import org.apache.streampark.console.core.assembler.FlinkApplicationAssembler; import org.apache.streampark.console.core.entity.FlinkApplication; @@ -101,7 +100,6 @@ public class FlinkApplicationController { private ResourceService resourceService; @PostMapping("get") - @Permission(app = "#request.id") @RequiresPermissions("app:detail") public RestResponseBody get(@Valid FlinkAppIdRequest request) { FlinkApplication application = applicationManageService.getApp(request.getId()); @@ -109,7 +107,6 @@ public RestResponseBody get(@Valid FlinkAppIdRequest request) return RestResponseBody.success(response); } - @Permission(team = "#request.teamId") @PostMapping("create") @RequiresPermissions("app:create") public RestResponseBody create(@Valid @FormOrJson FlinkAppCreateRequest request) throws IOException { @@ -118,7 +115,6 @@ public RestResponseBody create(@Valid @FormOrJson FlinkAppCreateRequest return RestResponseBody.success(saved); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("copy") @RequiresPermissions("app:copy") public RestResponseBody copy(@Valid @FormOrJson FlinkAppCopyRequest request) throws IOException { @@ -127,7 +123,6 @@ public RestResponseBody copy(@Valid @FormOrJson FlinkAppCopyRequest reques } @AppChangeEvent - @Permission(app = "#request.id") @PostMapping("update") @RequiresPermissions("app:update") public RestResponseBody update(@Valid @FormOrJson FlinkAppUpdateRequest request) { @@ -136,14 +131,12 @@ public RestResponseBody update(@Valid @FormOrJson FlinkAppUpdateRequest } @PostMapping("dashboard") - @Permission(team = "#request.teamId") public RestResponseBody dashboard(@Valid TeamIdRequest request) { Map dashboardMap = applicationInfoService.getDashboardDataMap(request.getTeamId()); return RestResponseBody.success(FlinkApplicationAssembler.toDashboardResponse(dashboardMap)); } @PostMapping("list") - @Permission(team = "#query.teamId") @RequiresPermissions("app:view") public RestResponseBody> list(@Valid FlinkAppListQueryRequest query, RestRequest request) { FlinkApplication appParam = FlinkApplicationAssembler.toEntity(query); @@ -153,7 +146,6 @@ public RestResponseBody> list(@Valid FlinkAppListQueryRe @AppChangeEvent @PostMapping("mapping") - @Permission(app = "#request.id") @RequiresPermissions("app:mapping") public RestResponseBody mapping(@Valid @FormOrJson FlinkAppMappingRequest request) { boolean flag = applicationManageService.mapping(FlinkApplicationAssembler.toEntity(request)); @@ -161,7 +153,6 @@ public RestResponseBody mapping(@Valid @FormOrJson FlinkAppMappingReque } @AppChangeEvent - @Permission(app = "#request.id") @PostMapping("revoke") @RequiresPermissions("app:release") public RestResponseBody revoke(@Valid @FormOrJson FlinkAppIdRequest request) { @@ -169,7 +160,6 @@ public RestResponseBody revoke(@Valid @FormOrJson FlinkAppIdRequest reques return RestResponseBody.success(); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("check/start") @RequiresPermissions("app:start") public RestResponseBody checkStart(@Valid FlinkAppIdRequest request) { @@ -177,7 +167,6 @@ public RestResponseBody checkStart(@Valid FlinkAppIdRequest request) { return RestResponseBody.success(stateEnum.get()); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("start") @RequiresPermissions("app:start") public RestResponseBody start(@Valid @FormOrJson FlinkAppStartRequest request) throws Exception { @@ -185,7 +174,6 @@ public RestResponseBody start(@Valid @FormOrJson FlinkAppStartRequest r return RestResponseBody.success(true); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("cancel") @RequiresPermissions("app:cancel") public RestResponseBody cancel(@Valid @FormOrJson FlinkAppCancelRequest request) throws Exception { @@ -194,7 +182,6 @@ public RestResponseBody cancel(@Valid @FormOrJson FlinkAppCancelRequest re } /** force stop(stop normal start or in progress) */ - @Permission(app = "#request.id") @PostMapping("abort") @RequiresPermissions("app:cancel") public RestResponseBody abort(@Valid @FormOrJson FlinkAppIdRequest request) { @@ -208,14 +195,12 @@ public RestResponseBody yarn() { } @PostMapping("name") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody yarnName(FlinkAppConfigRequest request) { String yarnName = applicationInfoService.getYarnName(request.getConfig()); return RestResponseBody.success(yarnName); } @PostMapping("check/name") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody checkName(@Valid FlinkAppCheckNameRequest request) { AppExistsStateEnum exists = applicationInfoService.checkExists(FlinkApplicationAssembler.toEntity(request)); return RestResponseBody.success(exists.get()); @@ -228,27 +213,23 @@ public RestResponseBody readConf(FlinkAppConfigRequest request) throws I } @PostMapping("main") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody getMain(FlinkAppGetMainRequest request) { String mainClass = applicationInfoService.getMain(FlinkApplicationAssembler.toEntity(request)); return RestResponseBody.success(mainClass); } @PostMapping("backups") - @Permission(app = "#query.appId", team = "#query.teamId") public RestResponseBody> backups(AppBackupQueryRequest query, RestRequest request) { return RestResponseBody.success( AppLogAssembler.toBackupPage(backUpService.getPage(AppLogAssembler.toEntity(query), request))); } @PostMapping("opt_log") - @Permission(app = "#query.appId", team = "#query.teamId") public RestResponseBody> log(AppOptLogQueryRequest query, RestRequest request) { return RestResponseBody.success( AppLogAssembler.toOptLogPage(applicationLogService.getPage(AppLogAssembler.toEntity(query), request))); } - @Permission(app = "#request.appId", team = "#request.teamId") @PostMapping("delete/opt_log") @RequiresPermissions("app:delete") public RestResponseBody deleteLog(@Valid @FormOrJson AppOptLogDeleteRequest request) { @@ -256,7 +237,6 @@ public RestResponseBody deleteLog(@Valid @FormOrJson AppOptLogDeleteReq return RestResponseBody.success(deleted); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("delete") @RequiresPermissions("app:delete") public RestResponseBody delete(@Valid @FormOrJson FlinkAppIdRequest request) throws InternalException { @@ -264,7 +244,6 @@ public RestResponseBody delete(@Valid @FormOrJson FlinkAppIdRequest req return RestResponseBody.success(deleted); } - @Permission(app = "#request.appId") @PostMapping("delete/backup") public RestResponseBody deleteBackup(@Valid @FormOrJson AppBackupDeleteRequest request) throws InternalException { Boolean deleted = backUpService.removeById(request.getId()); @@ -300,7 +279,6 @@ public RestResponseBody verifySchema(String path) { } @PostMapping("check/savepoint_path") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody checkSavepointPath(FlinkAppCheckSavepointPathRequest request) throws Exception { String error = applicationInfoService.checkSavepointPath(FlinkApplicationAssembler.toEntity(request)); if (error == null) { @@ -309,7 +287,6 @@ public RestResponseBody checkSavepointPath(FlinkAppCheckSavepointPathRe return RestResponseBody.success(false).message(error); } - @Permission(app = "#request.id") @PostMapping("k8s_log") public RestResponseBody k8sStartLog(FlinkAppK8sLogRequest request) throws Exception { String resp = applicationInfoService.k8sStartLog(request.getId(), request.getOffset(), request.getLimit()); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkPipelineController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkPipelineController.java index 8be66b81a4..41d24cfdc1 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkPipelineController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkPipelineController.java @@ -19,7 +19,6 @@ import org.apache.streampark.console.base.domain.RestResponseBody; import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.FlinkPipelineAssembler; import org.apache.streampark.console.core.bean.AppBuildDockerResolvedDetail; import org.apache.streampark.console.core.entity.ApplicationBuildPipeline; @@ -52,7 +51,6 @@ public class FlinkPipelineController { @Autowired private FlinkApplicationBuildPipelineService appBuildPipeService; - @Permission(app = "#request.appId") @PostMapping("build") @RequiresPermissions("app:create") public RestResponseBody buildApplication(@Valid @FormOrJson FlinkPipelineBuildRequest request) throws Exception { @@ -67,7 +65,6 @@ public RestResponseBody buildApplication(@Valid @FormOrJson FlinkPipeli * @return pipeline and docker resolved snapshot details */ @PostMapping("/detail") - @Permission(app = "#request.appId") @RequiresPermissions("app:view") public RestResponseBody getBuildProgressDetail(@Valid FlinkPipelineDetailRequest request) { Long appId = request.getAppId(); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkSqlController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkSqlController.java index c21c9d8aaf..b883656344 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkSqlController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkSqlController.java @@ -22,7 +22,6 @@ import org.apache.streampark.console.base.exception.ApiAlertException; import org.apache.streampark.console.base.exception.InternalException; import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.FlinkSqlAssembler; import org.apache.streampark.console.core.entity.FlinkSql; import org.apache.streampark.console.core.request.flink.FlinkAppIdRequest; @@ -92,7 +91,6 @@ public RestResponseBody verify(@Valid FlinkSqlVerifyRequest request) { } @PostMapping("list") - @Permission(app = "#query.appId", team = "#query.teamId") public RestResponseBody> list(@Valid FlinkSqlListQueryRequest query, RestRequest request) { IPage page = flinkSqlService.getPage(query.getAppId(), request); return RestResponseBody.success(FlinkSqlAssembler.toPageResponse(page)); @@ -100,7 +98,6 @@ public RestResponseBody> list(@Valid FlinkSqlListQueryRe @PostMapping("delete") @RequiresPermissions("sql:delete") - @Permission(app = "#request.appId", team = "#request.teamId") public RestResponseBody delete(@Valid @FormOrJson FlinkSqlDeleteRequest request) { Boolean deleted = flinkSqlService.removeById(request.getId()); return RestResponseBody.success(deleted); @@ -109,7 +106,6 @@ public RestResponseBody delete(@Valid @FormOrJson FlinkSqlDeleteRequest /** {@code data} is {@link FlinkSqlResponse} for one id, or {@link FlinkSqlResponse}{@code []} for two ids (legacy compare). */ @SuppressWarnings("java:S1452") @PostMapping("get") - @Permission(app = "#request.appId", team = "#request.teamId") public RestResponseBody get(@Valid FlinkSqlGetRequest request) throws InternalException { ApiAlertException.throwIfTrue( request.getAppId() == null || request.getTeamId() == null, @@ -129,7 +125,6 @@ public RestResponseBody get(@Valid FlinkSqlGetRequest request) throws Interna } @PostMapping("history") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody> history(@Valid FlinkAppIdRequest request) { List sqlList = flinkSqlService.listFlinkSqlHistory(request.getId()); return RestResponseBody.success(FlinkSqlAssembler.toListResponse(sqlList)); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/OpenAPIController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/OpenAPIController.java index f8b7af94b1..64f34ab31e 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/OpenAPIController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/OpenAPIController.java @@ -20,7 +20,6 @@ import org.apache.streampark.console.base.domain.RestResponseBody; import org.apache.streampark.console.base.web.FormOrJson; import org.apache.streampark.console.core.annotation.OpenAPI; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.FlinkApplicationAssembler; import org.apache.streampark.console.core.bean.ApiContractDocument; import org.apache.streampark.console.core.bean.OpenAPISchema; @@ -67,7 +66,6 @@ public class OpenAPIController { @OpenAPI.Param(name = "savepointPath", description = "savepoint or checkpoint path", required = false, type = String.class), @OpenAPI.Param(name = "allowNonRestored", description = "ignore savepoint if cannot be restored", required = false, type = Boolean.class, defaultValue = "false"), }) - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("app/start") @RequiresPermissions("app:start") public RestResponseBody flinkStart(@Valid @FormOrJson FlinkAppStartRequest request) throws Exception { @@ -84,7 +82,6 @@ public RestResponseBody flinkStart(@Valid @FormOrJson FlinkAppStartRequ @OpenAPI.Param(name = "savepointPath", description = "savepoint path", required = false, type = String.class), @OpenAPI.Param(name = "drain", description = "send max watermark before canceling", required = false, type = Boolean.class, defaultValue = "false"), }) - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("app/cancel") @RequiresPermissions("app:cancel") public RestResponseBody flinkCancel(@Valid @FormOrJson FlinkAppCancelRequest request) throws Exception { diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProjectController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProjectController.java index 4b90aa7474..a6caa877a1 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProjectController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProjectController.java @@ -23,7 +23,6 @@ import org.apache.streampark.console.base.exception.ApiAlertException; import org.apache.streampark.console.base.web.FormOrJson; import org.apache.streampark.console.core.annotation.AppChangeEvent; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.ProjectAssembler; import org.apache.streampark.console.core.entity.Project; import org.apache.streampark.console.core.enums.GitAuthorizedErrorEnum; @@ -68,7 +67,6 @@ public class ProjectController { private ProjectService projectService; @PostMapping("create") - @Permission(team = "#request.teamId") @RequiresPermissions("project:create") public RestResponseBody create(@Valid @FormOrJson ProjectCreateRequest request) { ApiAlertException.throwIfNull( @@ -83,21 +81,18 @@ public RestResponseBody create(@Valid @FormOrJson ProjectCreateRequest @AppChangeEvent @PostMapping("update") @RequiresPermissions("project:update") - @Permission(team = "#request.teamId") public RestResponseBody update(@Valid @FormOrJson ProjectUpdateRequest request) { boolean update = projectService.update(ProjectAssembler.toEntity(request)); return RestResponseBody.success(update); } @PostMapping("get") - @Permission(team = "#request.teamId") public RestResponseBody get(@Valid TeamScopedIdRequest request) { return RestResponseBody.success(ProjectAssembler.toResponse(projectService.getById(request.getId()))); } @PostMapping("build") @RequiresPermissions("project:build") - @Permission(team = "#request.teamId") public RestResponseBody build(@Valid @FormOrJson TeamScopedIdRequest request) throws Exception { projectService.build(request.getId()); return RestResponseBody.success(); @@ -105,7 +100,6 @@ public RestResponseBody build(@Valid @FormOrJson TeamScopedIdRequest reque @PostMapping("build_log") @RequiresPermissions("project:build") - @Permission(team = "#request.teamId") public RestResponseBody buildLog(ProjectBuildLogRequest request) { ProjectBuildLogResult result = projectService.getBuildLog(request.getId(), request.getStartOffset()); if (result.isFailed()) { @@ -123,7 +117,6 @@ public RestResponseBody buildLog(ProjectBuildLogRequest request) { @PostMapping("list") @RequiresPermissions("project:view") - @Permission(team = "#query.teamId") public RestResponseBody> list(ProjectListQueryRequest query, RestRequest restRequest) { if (query.getTeamId() == null) { Page emptyPage = new Page<>(); @@ -135,7 +128,6 @@ public RestResponseBody> list(ProjectListQueryRequest que } @PostMapping("branches") - @Permission(team = "#request.teamId") public RestResponseBody branches(ProjectGitRequest request) { Project project = ProjectAssembler.toEntity(request); List branches = projectService.getAllBranches(project); @@ -145,42 +137,36 @@ public RestResponseBody branches(ProjectGitRequest requ @PostMapping("delete") @RequiresPermissions("project:delete") - @Permission(team = "#request.teamId") public RestResponseBody delete(@Valid @FormOrJson TeamScopedIdRequest request) { Boolean deleted = projectService.removeById(request.getId()); return RestResponseBody.success(deleted); } @PostMapping("git_check") - @Permission(team = "#request.teamId") public RestResponseBody gitCheck(ProjectGitRequest request) { GitAuthorizedErrorEnum error = projectService.gitCheck(ProjectAssembler.toEntity(request)); return RestResponseBody.success(error.getType()); } @PostMapping("exists") - @Permission(team = "#request.teamId") public RestResponseBody exists(ProjectExistsRequest request) { boolean exists = projectService.exists(ProjectAssembler.toEntity(request)); return RestResponseBody.success(exists); } @PostMapping("modules") - @Permission(team = "#request.teamId") public RestResponseBody> modules(@Valid TeamScopedIdRequest request) { List result = projectService.listModules(request.getId()); return RestResponseBody.success(result); } @PostMapping("jars") - @Permission(team = "#request.teamId") public RestResponseBody> jars(ProjectModuleRequest request) { List result = projectService.listJars(ProjectAssembler.toEntity(request)); return RestResponseBody.success(result); } @PostMapping("list_conf") - @Permission(team = "#request.teamId") public RestResponseBody>> listConf(ProjectModuleRequest request) { List> list = projectService.listConf(ProjectAssembler.toEntity(request)); @@ -188,7 +174,6 @@ public RestResponseBody>> listConf(ProjectModuleRequest } @PostMapping("select") - @Permission(team = "#request.teamId") public RestResponseBody> select(@Valid TeamIdRequest request) { List list = projectService.listByTeamId(request.getTeamId()); return RestResponseBody.success(ProjectAssembler.toListResponse(list)); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java index e117db4fb3..98da406cb5 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java @@ -22,15 +22,11 @@ import org.apache.streampark.console.core.entity.FlinkApplication; import org.apache.streampark.console.core.entity.SparkApplication; import org.apache.streampark.console.core.enums.EngineTypeEnum; -import org.apache.streampark.console.core.enums.UserTypeEnum; import org.apache.streampark.console.core.service.ProxyService; import org.apache.streampark.console.core.service.application.ApplicationLogService; import org.apache.streampark.console.core.service.application.FlinkApplicationManageService; import org.apache.streampark.console.core.service.application.SparkApplicationManageService; import org.apache.streampark.console.core.util.ServiceHelper; -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.entity.User; -import org.apache.streampark.console.system.service.MemberService; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -63,9 +59,6 @@ public class ProxyController { @Autowired private ApplicationLogService logService; - @Autowired - private MemberService memberService; - @GetMapping("{type}/{id}/assets/**") public void proxyFlinkAssets(HttpServletRequest request, HttpServletResponse response, @PathVariable("type") String type, @PathVariable("id") Long id) throws Exception { @@ -81,16 +74,15 @@ public void proxyFlink(HttpServletRequest request, HttpServletResponse response, private void proxy(String type, HttpServletRequest request, HttpServletResponse response, Long id) throws Exception { + ApiAlertException.throwIfNull(ServiceHelper.getLoginUser(), "Permission denied, please login first."); ApplicationLog log; switch (type) { case "flink": FlinkApplication flinkApplication = flinkApplicationManageService.getApp(id); - checkProxyApp(flinkApplication.getTeamId()); proxyService.proxyFlink(request, response, flinkApplication); return; case "spark": SparkApplication sparkApplication = sparkApplicationManageService.getApp(id); - checkProxyApp(sparkApplication.getTeamId()); proxyService.proxySpark(request, response, sparkApplication); return; case "flink_cluster": @@ -111,26 +103,11 @@ private void proxy(String type, HttpServletRequest request, HttpServletResponse } } - private void checkProxyApp(Long teamId) { - User user = ServiceHelper.getLoginUser(); - ApiAlertException.throwIfNull(user, "Permission denied, please login first."); - - if (user.getUserType() != UserTypeEnum.ADMIN) { - Member member = memberService.getByTeamIdUserName(teamId, user.getUsername()); - ApiAlertException.throwIfNull(member, - "Permission denied, this job not created by the current user, And the job cannot be found in the current user's team."); - } - } - private void checkProxyAppLog(ApplicationLog log) { ApiAlertException.throwIfNull(log, "Invalid operation, The application log not found."); - if (log.getJobType() == EngineTypeEnum.FLINK.getCode()) { - FlinkApplication app = flinkApplicationManageService.getById(log.getAppId()); - checkProxyApp(app.getTeamId()); - } - if (log.getJobType() == EngineTypeEnum.SPARK.getCode()) { - SparkApplication app = sparkApplicationManageService.getById(log.getAppId()); - checkProxyApp(app.getTeamId()); - } + ApiAlertException.throwIfFalse( + log.getJobType() == EngineTypeEnum.FLINK.getCode() + || log.getJobType() == EngineTypeEnum.SPARK.getCode(), + "Invalid operation, unknown application log type."); } } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SavepointController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SavepointController.java index 7017845ed4..90c6d8634d 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SavepointController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SavepointController.java @@ -21,7 +21,6 @@ import org.apache.streampark.console.base.domain.RestResponseBody; import org.apache.streampark.console.base.exception.InternalException; import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.SavepointAssembler; import org.apache.streampark.console.core.entity.FlinkApplication; import org.apache.streampark.console.core.entity.FlinkSavepoint; @@ -57,7 +56,6 @@ public class SavepointController { private SavepointService savepointService; @PostMapping("history") - @Permission(app = "#query.appId", team = "#query.teamId") public RestResponseBody> history(SavepointHistoryQueryRequest query, RestRequest request) { FlinkSavepoint sp = SavepointAssembler.toEntity(query); IPage page = savepointService.getPage(sp, request); @@ -66,7 +64,6 @@ public RestResponseBody> history(SavepointHistoryQueryR @PostMapping("delete") @RequiresPermissions("savepoint:delete") - @Permission(app = "#request.appId", team = "#request.teamId") public RestResponseBody delete(@Valid @FormOrJson SavepointDeleteRequest request) throws InternalException { FlinkSavepoint savepoint = savepointService.getById(request.getId()); FlinkApplication application = applicationManageService.getById(savepoint.getAppId()); @@ -75,7 +72,6 @@ public RestResponseBody delete(@Valid @FormOrJson SavepointDeleteReques } @PostMapping("trigger") - @Permission(app = "#request.appId", team = "#request.teamId") @RequiresPermissions("savepoint:trigger") public RestResponseBody trigger(@Valid @FormOrJson SavepointTriggerRequest request) { savepointService.trigger(request.getAppId(), request.getSavepointPath(), request.getNativeFormat()); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkApplicationController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkApplicationController.java index 1119f35214..c3d46d2f31 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkApplicationController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkApplicationController.java @@ -24,7 +24,6 @@ import org.apache.streampark.console.base.exception.InternalException; import org.apache.streampark.console.base.web.FormOrJson; import org.apache.streampark.console.core.annotation.AppChangeEvent; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.AppLogAssembler; import org.apache.streampark.console.core.assembler.SparkApplicationAssembler; import org.apache.streampark.console.core.entity.SparkApplication; @@ -98,7 +97,6 @@ public class SparkApplicationController { private ResourceService resourceService; @PostMapping("get") - @Permission(app = "#request.id") @RequiresPermissions("app:detail") public RestResponseBody get(@Valid SparkAppIdRequest request) { SparkApplication application = applicationManageService.getApp(request.getId()); @@ -106,7 +104,6 @@ public RestResponseBody get(@Valid SparkAppIdRequest request) return RestResponseBody.success(response); } - @Permission(team = "#request.teamId") @PostMapping("create") @RequiresPermissions("app:create") public RestResponseBody create(@Valid @FormOrJson SparkAppCreateRequest request) throws IOException { @@ -115,7 +112,6 @@ public RestResponseBody create(@Valid @FormOrJson SparkAppCreateRequest return RestResponseBody.success(saved); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("copy") @RequiresPermissions("app:copy") public RestResponseBody copy(@Valid @FormOrJson SparkAppCopyRequest request) throws IOException { @@ -124,7 +120,6 @@ public RestResponseBody copy(@Valid @FormOrJson SparkAppCopyRequest reques } @AppChangeEvent - @Permission(app = "#request.id") @PostMapping("update") @RequiresPermissions("app:update") public RestResponseBody update(@Valid @FormOrJson SparkAppUpdateRequest request) { @@ -133,14 +128,12 @@ public RestResponseBody update(@Valid @FormOrJson SparkAppUpdateRequest } @PostMapping("dashboard") - @Permission(team = "#request.teamId") public RestResponseBody dashboard(@Valid TeamIdRequest request) { Map dashboardMap = applicationInfoService.getDashboardDataMap(request.getTeamId()); return RestResponseBody.success(SparkApplicationAssembler.toDashboardResponse(dashboardMap)); } @PostMapping("list") - @Permission(team = "#query.teamId") @RequiresPermissions("app:view") public RestResponseBody> list(@Valid SparkAppListQueryRequest query, RestRequest request) { SparkApplication appParam = SparkApplicationAssembler.toEntity(query); @@ -150,7 +143,6 @@ public RestResponseBody> list(@Valid SparkAppListQueryRe @AppChangeEvent @PostMapping("mapping") - @Permission(app = "#request.id") @RequiresPermissions("app:mapping") public RestResponseBody mapping(@Valid @FormOrJson SparkAppMappingRequest request) { boolean flag = applicationManageService.mapping(SparkApplicationAssembler.toEntity(request)); @@ -158,7 +150,6 @@ public RestResponseBody mapping(@Valid @FormOrJson SparkAppMappingReque } @AppChangeEvent - @Permission(app = "#request.id") @PostMapping("revoke") @RequiresPermissions("app:release") public RestResponseBody revoke(@Valid @FormOrJson SparkAppIdRequest request) { @@ -166,7 +157,6 @@ public RestResponseBody revoke(@Valid @FormOrJson SparkAppIdRequest reques return RestResponseBody.success(); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("check/start") @RequiresPermissions("app:start") public RestResponseBody checkStart(@Valid SparkAppIdRequest request) { @@ -174,7 +164,6 @@ public RestResponseBody checkStart(@Valid SparkAppIdRequest request) { return RestResponseBody.success(stateEnum.get()); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("start") @RequiresPermissions("app:start") public RestResponseBody start(@Valid @FormOrJson SparkAppStartRequest request) { @@ -186,7 +175,6 @@ public RestResponseBody start(@Valid @FormOrJson SparkAppStartRequest r } } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("cancel") @RequiresPermissions("app:cancel") public RestResponseBody cancel(@Valid @FormOrJson SparkAppCancelRequest request) throws Exception { @@ -195,7 +183,6 @@ public RestResponseBody cancel(@Valid @FormOrJson SparkAppCancelRequest re } @AppChangeEvent - @Permission(app = "#request.id") @PostMapping("clean") @RequiresPermissions("app:clean") public RestResponseBody clean(@Valid @FormOrJson SparkAppIdRequest request) { @@ -203,7 +190,6 @@ public RestResponseBody clean(@Valid @FormOrJson SparkAppIdRequest requ return RestResponseBody.success(true); } - @Permission(app = "#request.id") @PostMapping("forcedStop") @RequiresPermissions("app:cancel") public RestResponseBody forcedStop(@Valid @FormOrJson SparkAppIdRequest request) { @@ -217,14 +203,12 @@ public RestResponseBody yarn() { } @PostMapping("name") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody yarnName(SparkAppConfigRequest request) { String yarnName = applicationInfoService.getYarnName(request.getConfig()); return RestResponseBody.success(yarnName); } @PostMapping("check/name") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody checkName(@Valid SparkAppCheckNameRequest request) { AppExistsStateEnum exists = applicationInfoService.checkExists(SparkApplicationAssembler.toEntity(request)); return RestResponseBody.success(exists.get()); @@ -237,14 +221,12 @@ public RestResponseBody readConf(SparkAppConfigRequest request) throws I } @PostMapping("backups") - @Permission(app = "#query.appId", team = "#query.teamId") public RestResponseBody> backups(AppBackupQueryRequest query, RestRequest request) { return RestResponseBody.success( AppLogAssembler.toBackupPage(backUpService.getPage(AppLogAssembler.toEntity(query), request))); } @PostMapping("opt_log") - @Permission(app = "#query.appId", team = "#query.teamId") public RestResponseBody> optionlog(AppOptLogQueryRequest query, RestRequest request) { return RestResponseBody.success( AppLogAssembler.toOptLogPage(applicationLogService.getPage(AppLogAssembler.toEntity(query), request))); @@ -257,7 +239,6 @@ public RestResponseBody deleteOperationLog(@Valid @FormOrJson IdRequest return RestResponseBody.success(deleted); } - @Permission(app = "#request.id", team = "#request.teamId") @PostMapping("delete") @RequiresPermissions("app:delete") public RestResponseBody delete(@Valid @FormOrJson SparkAppIdRequest request) throws InternalException { @@ -265,7 +246,6 @@ public RestResponseBody delete(@Valid @FormOrJson SparkAppIdRequest req return RestResponseBody.success(deleted); } - @Permission(app = "#request.appId") @PostMapping("delete/bak") public RestResponseBody deleteBak(@Valid @FormOrJson AppBackupDeleteRequest request) throws InternalException { Boolean deleted = backUpService.removeById(request.getId()); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkPipelineController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkPipelineController.java index e9cc36192e..ccd7a98a98 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkPipelineController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkPipelineController.java @@ -19,7 +19,6 @@ import org.apache.streampark.console.base.domain.RestResponseBody; import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.SparkPipelineAssembler; import org.apache.streampark.console.core.entity.ApplicationBuildPipeline; import org.apache.streampark.console.core.request.spark.SparkPipelineBuildRequest; @@ -57,7 +56,6 @@ public class SparkPipelineController { */ @PostMapping("build") @RequiresPermissions("app:create") - @Permission(app = "#request.appId") public RestResponseBody buildApplication(@Valid @FormOrJson SparkPipelineBuildRequest request) { try { boolean actionResult = appBuildPipeService.buildApplication(request.getAppId(), request.isForceBuild()); @@ -75,7 +73,6 @@ public RestResponseBody buildApplication(@Valid @FormOrJson SparkPipeli */ @PostMapping("/detail") @RequiresPermissions("app:view") - @Permission(app = "#request.appId") public RestResponseBody getBuildProgressDetail(@Valid SparkPipelineDetailRequest request) { Optional pipeline = appBuildPipeService.getCurrentBuildPipeline(request.getAppId()); return RestResponseBody.success( diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkSqlController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkSqlController.java index 07126e32a1..324d15a0bf 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkSqlController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SparkSqlController.java @@ -22,7 +22,6 @@ import org.apache.streampark.console.base.exception.ApiAlertException; import org.apache.streampark.console.base.exception.InternalException; import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.assembler.SparkSqlAssembler; import org.apache.streampark.console.core.entity.SparkSql; import org.apache.streampark.console.core.request.spark.SparkSqlCompleteRequest; @@ -91,7 +90,6 @@ public RestResponseBody verify(@Valid SparkSqlVerifyRequest request) { } @PostMapping("list") - @Permission(app = "#request.appId", team = "#request.teamId") public RestResponseBody> list(@Valid SparkSqlListQueryRequest request, RestRequest restRequest) { IPage page = sparkSqlService.getPage(request.getAppId(), restRequest); @@ -100,7 +98,6 @@ public RestResponseBody> list(@Valid SparkSqlListQueryRe @PostMapping("delete") @RequiresPermissions("sql:delete") - @Permission(app = "#request.appId", team = "#request.teamId") public RestResponseBody delete(@Valid @FormOrJson SparkSqlDeleteRequest request) { SparkSql sparkSql = SparkSqlAssembler.toDeleteEntity(request); ApiAlertException.throwIfNull(sparkSql, "Spark SQL delete request cannot be null."); @@ -111,7 +108,6 @@ public RestResponseBody delete(@Valid @FormOrJson SparkSqlDeleteRequest /** {@code data} is {@link SparkSqlResponse} for one id, or {@link SparkSqlResponse}{@code []} for two ids (legacy compare). */ @SuppressWarnings("java:S1452") @PostMapping("get") - @Permission(app = "#request.appId", team = "#request.teamId") public RestResponseBody get(@Valid SparkSqlGetRequest request) throws InternalException { ApiAlertException.throwIfTrue( request.getAppId() == null || request.getTeamId() == null, @@ -130,7 +126,6 @@ public RestResponseBody get(@Valid SparkSqlGetRequest request) throws Interna } @PostMapping("history") - @Permission(app = "#request.id", team = "#request.teamId") public RestResponseBody> history(@Valid SparkSqlHistoryRequest request) { List sqlList = sparkSqlService.listSparkSqlHistory(request.getId()); return RestResponseBody.success(SparkSqlAssembler.toListResponse(sqlList)); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/UserTypeEnum.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/UserTypeEnum.java index df9e9fc408..dc24888d0e 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/UserTypeEnum.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/UserTypeEnum.java @@ -21,22 +21,41 @@ import lombok.Getter; import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; /** The user type. */ @Getter public enum UserTypeEnum { /** The admin of StreamPark. */ - ADMIN(1), + ADMIN(1, "admin", Collections.singleton("*")), - /** The user of StreamPark. */ - USER(2); + /** A StreamPark developer who can create and operate jobs and development resources. */ + EDITOR(2, "editor", new LinkedHashSet<>(Arrays.asList( + "app:*", + "backup:*", + "conf:*", + "externalLink:view", + "project:*", + "resource:*", + "savepoint:*", + "sql:*", + "token:*", + "variable:*"))); @EnumValue private final int code; - UserTypeEnum(int code) { + private final String roleName; + + private final Set permissions; + + UserTypeEnum(int code, String roleName, Set permissions) { this.code = code; + this.roleName = roleName; + this.permissions = Collections.unmodifiableSet(permissions); } public static UserTypeEnum of(Integer code) { diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/common/AppScopedIdRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/common/AppScopedIdRequest.java index e7ea57992e..c75828fdc5 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/common/AppScopedIdRequest.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/common/AppScopedIdRequest.java @@ -21,7 +21,7 @@ import lombok.Setter; /** - * Application id ({@code id}) scoped to a team ({@code teamId}) for {@code @Permission} checks. + * Application id ({@code id}) scoped to a team ({@code teamId}) carried by API requests. */ @Getter @Setter diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/util/ServiceHelper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/util/ServiceHelper.java index 400aaceaa5..f145696dd2 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/util/ServiceHelper.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/util/ServiceHelper.java @@ -22,6 +22,7 @@ import org.apache.streampark.console.base.util.WebUtils; import org.apache.streampark.console.core.entity.FlinkEnv; import org.apache.streampark.console.core.entity.SparkEnv; +import org.apache.streampark.console.core.enums.UserTypeEnum; import org.apache.streampark.console.system.authentication.JWTUtil; import org.apache.streampark.console.system.entity.User; import org.apache.streampark.console.system.service.UserService; @@ -58,6 +59,11 @@ public static Long getUserId() { return null; } + public static boolean isAdmin() { + User user = getLoginUser(); + return user != null && user.getUserType() == UserTypeEnum.ADMIN; + } + public static String getFlinkSqlClientJar(FlinkEnv flinkEnv) { if (flinkSqlClientJar == null) { File localClient = WebUtils.getAppClientDir(); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/MemberAssembler.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/MemberAssembler.java deleted file mode 100644 index 7e6bb3e44d..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/MemberAssembler.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.assembler; - -import org.apache.streampark.console.core.assembler.DtoAssembler; -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.request.member.MemberCreateRequest; -import org.apache.streampark.console.system.request.member.MemberListQueryRequest; -import org.apache.streampark.console.system.request.member.MemberUpdateRequest; -import org.apache.streampark.console.system.response.member.MemberResponse; - -import com.baomidou.mybatisplus.core.metadata.IPage; - -/** Converts between member entities and API request/response contracts. */ -public final class MemberAssembler { - - private MemberAssembler() { - } - - public static Member toEntity(MemberListQueryRequest request) { - return DtoAssembler.toDto(request, Member.class); - } - - public static Member toEntity(MemberCreateRequest request) { - return DtoAssembler.toDto(request, Member.class); - } - - public static Member toEntity(MemberUpdateRequest request) { - return DtoAssembler.toDto(request, Member.class); - } - - public static MemberResponse toResponse(Member member) { - return DtoAssembler.toDto(member, MemberResponse.class); - } - - public static IPage toPageResponse(IPage page) { - return DtoAssembler.toPage(page, MemberAssembler::toResponse); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/MenuAssembler.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/MenuAssembler.java deleted file mode 100644 index c5b1e57e02..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/MenuAssembler.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.assembler; - -import org.apache.streampark.console.core.assembler.DtoAssembler; -import org.apache.streampark.console.system.entity.Menu; -import org.apache.streampark.console.system.request.menu.MenuListQueryRequest; -import org.apache.streampark.console.system.response.menu.MenuListResponse; -import org.apache.streampark.console.system.service.impl.MenuServiceImpl; - -import java.util.List; -import java.util.Map; - -/** Converts between menu entities and API request/response contracts. */ -public final class MenuAssembler { - - private MenuAssembler() { - } - - public static Menu toEntity(MenuListQueryRequest request) { - return DtoAssembler.toDto(request, Menu.class); - } - - @SuppressWarnings("unchecked") - public static MenuListResponse toListResponse(Map menuMap) { - if (menuMap == null) { - return null; - } - MenuListResponse response = new MenuListResponse(); - response.setIds((List) menuMap.get(MenuServiceImpl.IDS)); - Object total = menuMap.get(MenuServiceImpl.TOTAL); - if (total instanceof Integer) { - response.setTotal((Integer) total); - } else if (total instanceof Long) { - response.setTotal(((Long) total).intValue()); - } - response.setRows( - (org.apache.streampark.console.base.domain.router.RouterTree) menuMap.get(MenuServiceImpl.ROWS)); - return response; - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/RoleAssembler.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/RoleAssembler.java deleted file mode 100644 index b188c51e8b..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/RoleAssembler.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.assembler; - -import org.apache.streampark.console.core.assembler.DtoAssembler; -import org.apache.streampark.console.system.entity.Role; -import org.apache.streampark.console.system.request.role.RoleCreateRequest; -import org.apache.streampark.console.system.request.role.RoleListQueryRequest; -import org.apache.streampark.console.system.request.role.RoleUpdateRequest; -import org.apache.streampark.console.system.response.role.RoleResponse; - -import com.baomidou.mybatisplus.core.metadata.IPage; - -/** Converts between role entities and API request/response contracts. */ -public final class RoleAssembler { - - private RoleAssembler() { - } - - public static Role toEntity(RoleListQueryRequest request) { - return DtoAssembler.toDto(request, Role.class); - } - - public static Role toEntity(RoleCreateRequest request) { - return DtoAssembler.toDto(request, Role.class); - } - - public static Role toEntity(RoleUpdateRequest request) { - return DtoAssembler.toDto(request, Role.class); - } - - public static RoleResponse toResponse(Role role) { - return DtoAssembler.toDto(role, RoleResponse.class); - } - - public static IPage toPageResponse(IPage page) { - return DtoAssembler.toPage(page, RoleAssembler::toResponse); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/TeamAssembler.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/TeamAssembler.java deleted file mode 100644 index fbb33dc3de..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/TeamAssembler.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.assembler; - -import org.apache.streampark.console.core.assembler.DtoAssembler; -import org.apache.streampark.console.system.entity.Team; -import org.apache.streampark.console.system.request.team.TeamCreateRequest; -import org.apache.streampark.console.system.request.team.TeamListQueryRequest; -import org.apache.streampark.console.system.request.team.TeamUpdateRequest; -import org.apache.streampark.console.system.response.team.TeamResponse; - -import com.baomidou.mybatisplus.core.metadata.IPage; - -/** Converts between team entities and API request/response contracts. */ -public final class TeamAssembler { - - private TeamAssembler() { - } - - public static Team toEntity(TeamListQueryRequest request) { - return DtoAssembler.toDto(request, Team.class); - } - - public static Team toEntity(TeamCreateRequest request) { - return DtoAssembler.toDto(request, Team.class); - } - - public static Team toEntity(TeamUpdateRequest request) { - return DtoAssembler.toDto(request, Team.class); - } - - public static TeamResponse toResponse(Team team) { - return DtoAssembler.toDto(team, TeamResponse.class); - } - - public static IPage toPageResponse(IPage page) { - return DtoAssembler.toPage(page, TeamAssembler::toResponse); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/UserAssembler.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/UserAssembler.java index bc116dc301..89478f6c4f 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/UserAssembler.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/assembler/UserAssembler.java @@ -99,6 +99,7 @@ public static UserBriefResponse toBriefResponse(User user) { response.setUsername(user.getUsername()); response.setNickName(user.getNickName()); response.setDescription(user.getDescription()); + response.setUserType(user.getUserType()); response.setLastTeamId(user.getLastTeamId()); response.setId(user.getId()); return response; @@ -116,9 +117,9 @@ public static UserSessionResponse toSessionResponse(Map userInfo if (userObj instanceof User) { response.setUser(toBriefResponse((User) userObj)); } - Object permissions = userInfo.get("permissions"); - if (permissions instanceof Set) { - response.setPermissions((Set) permissions); + Object roles = userInfo.get("roles"); + if (roles instanceof Set) { + response.setRoles((Set) roles); } return response; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java index 2d82a0e474..2299c01817 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroConfig.java @@ -54,9 +54,7 @@ public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityMan filterChainDefinitionMap.put("/passport/**", "anon"); filterChainDefinitionMap.put("/systemName", "anon"); - filterChainDefinitionMap.put("/member/teams", "anon"); filterChainDefinitionMap.put("/user/check/**", "anon"); - filterChainDefinitionMap.put("/user/initTeam", "anon"); filterChainDefinitionMap.put("/websocket/**", "anon"); filterChainDefinitionMap.put("/metrics/**", "anon"); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroRealm.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroRealm.java index 6c65334d4f..e6a9fefbda 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroRealm.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/authentication/ShiroRealm.java @@ -36,9 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; -import java.util.Set; - -/** Implementation of ShiroRealm, including two modules: authentication and authorization */ +/** Authentication and fixed-role authorization for StreamPark users. */ public class ShiroRealm extends AuthorizingRealm { @Autowired @@ -52,21 +50,16 @@ public boolean supports(AuthenticationToken token) { return token instanceof JWTToken; } - /** - * Authorization module to get user roles and permissions - * - * @param token token - * @return AuthorizationInfo permission information - */ + /** Resolve the single built-in role stored in {@code t_user.user_type}. */ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection token) { Long userId = JWTUtil.getUserId(token.toString()); - SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(); - - // Get user permission set - Set permissionSet = userService.listPermissions(userId, null); - simpleAuthorizationInfo.setStringPermissions(permissionSet); + User user = userService.getById(userId); + if (user != null && user.getUserType() != null) { + simpleAuthorizationInfo.addRole(user.getUserType().getRoleName()); + simpleAuthorizationInfo.setStringPermissions(user.getUserType().getPermissions()); + } return simpleAuthorizationInfo; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MemberController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MemberController.java deleted file mode 100644 index 9aaf14716c..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MemberController.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.controller; - -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.base.domain.RestResponseBody; -import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.core.annotation.Permission; -import org.apache.streampark.console.system.assembler.MemberAssembler; -import org.apache.streampark.console.system.assembler.TeamAssembler; -import org.apache.streampark.console.system.assembler.UserAssembler; -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.request.member.MemberCandidateUsersRequest; -import org.apache.streampark.console.system.request.member.MemberCheckUserRequest; -import org.apache.streampark.console.system.request.member.MemberCreateRequest; -import org.apache.streampark.console.system.request.member.MemberDeleteRequest; -import org.apache.streampark.console.system.request.member.MemberListQueryRequest; -import org.apache.streampark.console.system.request.member.MemberTeamsRequest; -import org.apache.streampark.console.system.request.member.MemberUpdateRequest; -import org.apache.streampark.console.system.response.member.MemberResponse; -import org.apache.streampark.console.system.response.team.TeamResponse; -import org.apache.streampark.console.system.response.user.UserResponse; -import org.apache.streampark.console.system.service.MemberService; - -import org.apache.shiro.authz.annotation.RequiresPermissions; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -import java.util.stream.Collectors; - -@Slf4j -@Validated -@RestController -@RequestMapping("member") -public class MemberController { - - @Autowired - private MemberService memberService; - - @PostMapping("list") - public RestResponseBody> memberList(RestRequest restRequest, MemberListQueryRequest query) { - IPage userList = memberService.getPage(MemberAssembler.toEntity(query), restRequest); - return RestResponseBody.success(MemberAssembler.toPageResponse(userList)); - } - - @PostMapping("candidateUsers") - public RestResponseBody> candidateUsers(@Valid MemberCandidateUsersRequest request) { - return RestResponseBody.success( - UserAssembler.toResponseList(memberService.listUsersNotInTeam(request.getTeamId()))); - } - - @PostMapping("teams") - public RestResponseBody> listTeams(@Valid MemberTeamsRequest request) { - return RestResponseBody.success( - memberService.listTeamsByUserId(request.getUserId()).stream() - .map(TeamAssembler::toResponse) - .collect(Collectors.toList())); - } - - @PostMapping("check/user") - public RestResponseBody check(@Valid MemberCheckUserRequest request) { - Member result = this.memberService.getByTeamIdUserName(request.getTeamId(), request.getUserName()); - return RestResponseBody.success(result == null); - } - - @PostMapping("post") - @Permission(team = "#request.teamId") - @RequiresPermissions("member:add") - public RestResponseBody create(@Valid @FormOrJson MemberCreateRequest request) { - this.memberService.createMember(MemberAssembler.toEntity(request)); - return RestResponseBody.success(); - } - - @DeleteMapping("delete") - @Permission(team = "#request.teamId") - @RequiresPermissions("member:delete") - public RestResponseBody delete(@Valid @FormOrJson MemberDeleteRequest request) { - this.memberService.remove(request.getId()); - return RestResponseBody.success(); - } - - @PutMapping("update") - @Permission(team = "#request.teamId") - @RequiresPermissions("member:update") - public RestResponseBody update(@Valid @FormOrJson MemberUpdateRequest request) { - this.memberService.updateMember(MemberAssembler.toEntity(request)); - return RestResponseBody.success(); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java index a87f1c6d12..3363925314 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/MenuController.java @@ -20,15 +20,10 @@ import org.apache.streampark.console.base.domain.RestResponseBody; import org.apache.streampark.console.base.domain.router.VueRouter; import org.apache.streampark.console.core.util.ServiceHelper; -import org.apache.streampark.console.system.assembler.MenuAssembler; import org.apache.streampark.console.system.entity.Menu; -import org.apache.streampark.console.system.request.menu.MenuListQueryRequest; import org.apache.streampark.console.system.request.menu.MenuRouterRequest; -import org.apache.streampark.console.system.response.menu.MenuListResponse; import org.apache.streampark.console.system.service.MenuService; -import org.apache.shiro.authz.annotation.RequiresPermissions; - import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; @@ -52,11 +47,4 @@ public RestResponseBody>> getUserRouters(MenuRouterRequest List> routers = this.menuService.listRouters(ServiceHelper.getUserId(), request.getTeamId()); return RestResponseBody.success(routers); } - - @PostMapping("list") - @RequiresPermissions("menu:view") - public RestResponseBody menuList(MenuListQueryRequest query) { - return RestResponseBody.success( - MenuAssembler.toListResponse(this.menuService.listMenuMap(MenuAssembler.toEntity(query)))); - } } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/RoleController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/RoleController.java deleted file mode 100644 index b292fdee1b..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/RoleController.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.controller; - -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.base.domain.RestResponseBody; -import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.system.assembler.RoleAssembler; -import org.apache.streampark.console.system.entity.Role; -import org.apache.streampark.console.system.entity.RoleMenu; -import org.apache.streampark.console.system.request.role.RoleCheckNameRequest; -import org.apache.streampark.console.system.request.role.RoleCreateRequest; -import org.apache.streampark.console.system.request.role.RoleDeleteRequest; -import org.apache.streampark.console.system.request.role.RoleListQueryRequest; -import org.apache.streampark.console.system.request.role.RoleMenuQueryRequest; -import org.apache.streampark.console.system.request.role.RoleUpdateRequest; -import org.apache.streampark.console.system.response.role.RoleResponse; -import org.apache.streampark.console.system.service.RoleMenuService; -import org.apache.streampark.console.system.service.RoleService; - -import org.apache.shiro.authz.annotation.RequiresPermissions; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -import java.util.List; -import java.util.stream.Collectors; - -@Slf4j -@Validated -@RestController -@RequestMapping("role") -public class RoleController { - - @Autowired - private RoleService roleService; - @Autowired - private RoleMenuService roleMenuService; - - @PostMapping("list") - @RequiresPermissions("role:view") - public RestResponseBody> roleList(RestRequest restRequest, RoleListQueryRequest query) { - IPage roleList = roleService.getPage(RoleAssembler.toEntity(query), restRequest); - return RestResponseBody.success(RoleAssembler.toPageResponse(roleList)); - } - - @PostMapping("check/name") - public RestResponseBody checkRoleName(@Valid RoleCheckNameRequest request) { - Role result = this.roleService.getByName(request.getRoleName()); - return RestResponseBody.success(result == null); - } - - @PostMapping("menu") - public RestResponseBody> getRoleMenus(@Valid RoleMenuQueryRequest request) { - List roleMenuList = this.roleMenuService.listByRoleId(request.getRoleId()); - List menuIdList = roleMenuList.stream() - .map(roleMenu -> String.valueOf(roleMenu.getMenuId())) - .collect(Collectors.toList()); - return RestResponseBody.success(menuIdList); - } - - @PostMapping("post") - @RequiresPermissions("role:add") - public RestResponseBody addRole(@Valid @FormOrJson RoleCreateRequest request) { - this.roleService.createRole(RoleAssembler.toEntity(request)); - return RestResponseBody.success(); - } - - @DeleteMapping("delete") - @RequiresPermissions("role:delete") - public RestResponseBody deleteRole(@Valid @FormOrJson RoleDeleteRequest request) { - this.roleService.removeById(request.getRoleId()); - return RestResponseBody.success(); - } - - @PutMapping("update") - @RequiresPermissions("role:update") - public RestResponseBody updateRole(@Valid @FormOrJson RoleUpdateRequest request) { - this.roleService.updateRole(RoleAssembler.toEntity(request)); - return RestResponseBody.success(); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/TeamController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/TeamController.java deleted file mode 100644 index e51d6c2d78..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/TeamController.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.controller; - -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.base.domain.RestResponseBody; -import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.system.assembler.TeamAssembler; -import org.apache.streampark.console.system.entity.Team; -import org.apache.streampark.console.system.request.team.TeamCheckNameRequest; -import org.apache.streampark.console.system.request.team.TeamCreateRequest; -import org.apache.streampark.console.system.request.team.TeamDeleteRequest; -import org.apache.streampark.console.system.request.team.TeamListQueryRequest; -import org.apache.streampark.console.system.request.team.TeamUpdateRequest; -import org.apache.streampark.console.system.response.team.TeamResponse; -import org.apache.streampark.console.system.service.TeamService; - -import org.apache.shiro.authz.annotation.RequiresPermissions; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -@Slf4j -@Validated -@RestController -@RequestMapping("team") -public class TeamController { - - @Autowired - private TeamService teamService; - - @PostMapping("list") - public RestResponseBody> teamList(RestRequest restRequest, TeamListQueryRequest query) { - IPage teamList = teamService.getPage(TeamAssembler.toEntity(query), restRequest); - return RestResponseBody.success(TeamAssembler.toPageResponse(teamList)); - } - - @PostMapping("check/name") - public RestResponseBody checkTeamName(@Valid TeamCheckNameRequest request) { - Team result = this.teamService.getByName(request.getTeamName()); - return RestResponseBody.success(result == null); - } - - @PostMapping("post") - @RequiresPermissions("team:add") - public RestResponseBody addTeam(@Valid @FormOrJson TeamCreateRequest request) { - this.teamService.createTeam(TeamAssembler.toEntity(request)); - return RestResponseBody.success(); - } - - @DeleteMapping("delete") - @RequiresPermissions("team:delete") - public RestResponseBody deleteTeam(@Valid @FormOrJson TeamDeleteRequest request) { - this.teamService.removeById(request.getId()); - return RestResponseBody.success(); - } - - @PutMapping("update") - @RequiresPermissions("team:update") - public RestResponseBody updateTeam(@Valid @FormOrJson TeamUpdateRequest request) { - this.teamService.updateTeam(TeamAssembler.toEntity(request)); - return RestResponseBody.success(); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java index 88a738031c..c23db9ae38 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/UserController.java @@ -17,16 +17,12 @@ package org.apache.streampark.console.system.controller; -import org.apache.streampark.console.base.domain.ResponseCode; import org.apache.streampark.console.base.domain.RestRequest; import org.apache.streampark.console.base.domain.RestResponseBody; import org.apache.streampark.console.base.exception.ApiAlertException; import org.apache.streampark.console.base.web.FormOrJson; -import org.apache.streampark.console.core.annotation.Permission; import org.apache.streampark.console.core.enums.LoginTypeEnum; -import org.apache.streampark.console.core.util.ServiceHelper; import org.apache.streampark.console.system.assembler.UserAssembler; -import org.apache.streampark.console.system.entity.Team; import org.apache.streampark.console.system.entity.User; import org.apache.streampark.console.system.request.user.UserCheckNameRequest; import org.apache.streampark.console.system.request.user.UserCreateRequest; @@ -38,9 +34,7 @@ import org.apache.streampark.console.system.request.user.UserTransferResourceRequest; import org.apache.streampark.console.system.request.user.UserUpdateRequest; import org.apache.streampark.console.system.response.user.UserResponse; -import org.apache.streampark.console.system.response.user.UserSessionResponse; import org.apache.streampark.console.system.response.user.UserUpdateResponse; -import org.apache.streampark.console.system.service.TeamService; import org.apache.streampark.console.system.service.UserService; import org.apache.shiro.authz.annotation.Logical; @@ -69,9 +63,6 @@ public class UserController { @Autowired private UserService userService; - @Autowired - private TeamService teamService; - @PostMapping("list") @RequiresPermissions(value = {"user:view", "app:view"}, logical = Logical.OR) public RestResponseBody> userList(RestRequest restRequest, UserListQueryRequest query) { @@ -90,7 +81,6 @@ public RestResponseBody addUser(@Valid @FormOrJson UserCreateRequest reque } @PutMapping("update") - @Permission(user = "#request.userId") @RequiresPermissions("user:update") public RestResponseBody updateUser(@Valid @FormOrJson UserUpdateRequest request) throws Exception { return RestResponseBody.success( @@ -105,7 +95,6 @@ public RestResponseBody transferResource(@Valid @FormOrJson UserTransferRe } @DeleteMapping("delete") - @Permission(user = "#request.userId") @RequiresPermissions("user:delete") public RestResponseBody deleteUser(@Valid @FormOrJson UserDeleteRequest request) throws Exception { this.userService.deleteUser(request.getUserId()); @@ -124,7 +113,6 @@ public RestResponseBody checkUserName(@Valid UserCheckNameRequest reque } @PutMapping("password") - @Permission(user = "#request.userId") public RestResponseBody updatePassword(@Valid @FormOrJson UserPasswordUpdateRequest request) throws Exception { userService.updatePassword(UserAssembler.toEntity(request)); return RestResponseBody.success(); @@ -137,23 +125,6 @@ public RestResponseBody resetPassword(@Valid @FormOrJson UserResetPasswo return RestResponseBody.success(newPass); } - @PostMapping("set_team") - public RestResponseBody setTeam(@Valid UserTeamIdRequest request) { - Team team = teamService.getById(request.getTeamId()); - if (team == null) { - return RestResponseBody.fail(ResponseCode.CODE_FAIL_ALERT, "TeamId is invalid, set team failed."); - } - User user = ServiceHelper.getLoginUser(); - ApiAlertException.throwIfNull(user, "Current login user is null, set team failed."); - userService.setLastTeam(request.getTeamId(), user.getUserId()); - - user.dataMasking(); - user.setLastTeamId(request.getTeamId()); - - return RestResponseBody.success(UserAssembler.toSessionResponse( - userService.generateFrontendUserInfo(user, null))); - } - @PostMapping("appOwners") public RestResponseBody> appOwners(@Valid UserTeamIdRequest request) { List userList = userService.listByTeamId(request.getTeamId()); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Member.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Member.java deleted file mode 100644 index f6d975fa4c..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Member.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.entity; - -import org.apache.streampark.console.base.mybatis.entity.BaseEntity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -@TableName("t_member") -@Getter -@Setter -@EqualsAndHashCode(callSuper = true) -public class Member extends BaseEntity { - - @TableId(type = IdType.AUTO) - private Long id; - - private Long teamId; - - private Long userId; - - private Long roleId; - - private transient String userName; - - private transient String roleName; - - private transient String createTimeFrom; - - private transient String createTimeTo; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Role.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Role.java deleted file mode 100644 index 88c2f3161e..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Role.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.entity; - -import org.apache.streampark.console.base.mybatis.entity.BaseEntity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; - -@Getter -@Setter -@EqualsAndHashCode(callSuper = true) -@TableName("t_role") -public class Role extends BaseEntity { - - @TableId(type = IdType.AUTO) - private Long roleId; - - @NotBlank(message = "{required}") - @Size(max = 10, message = "{noMoreThan}") - private String roleName; - - @Size(max = 255, message = "{noMoreThan}") - private String description; - - private transient String createTimeFrom; - private transient String createTimeTo; - private transient String menuId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/RoleMenu.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/RoleMenu.java deleted file mode 100644 index f9a0ef18f2..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/RoleMenu.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -@TableName("t_role_menu") -@Getter -@Setter -public class RoleMenu implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(type = IdType.AUTO) - private Long id; - - private Long roleId; - - private Long menuId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/MenuMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/MenuMapper.java index b0f14a0f4a..3fc475425c 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/MenuMapper.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/MenuMapper.java @@ -19,23 +19,7 @@ import org.apache.streampark.console.system.entity.Menu; -import org.apache.ibatis.annotations.Param; - import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import java.util.List; - public interface MenuMapper extends BaseMapper { - - List selectPermissions(@Param("userId") Long userId, @Param("teamId") Long teamId); - - List selectMenus(@Param("userId") Long userId, @Param("teamId") Long teamId); - - /** - * Find the user ID associated with the current menu or button - * - * @param menuId menuId - * @return user id list - */ - List selectUserIdsByMenuId(String menuId); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/RoleMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/RoleMapper.java deleted file mode 100644 index 0e6aab877f..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/RoleMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.mapper; - -import org.apache.streampark.console.system.entity.Role; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -public interface RoleMapper extends BaseMapper { -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/RoleMenuMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/RoleMenuMapper.java deleted file mode 100644 index f2dd0f9587..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/RoleMenuMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.mapper; - -import org.apache.streampark.console.system.entity.RoleMenu; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -public interface RoleMenuMapper extends BaseMapper { -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMapper.java index 16a5722606..fd5e533fca 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMapper.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMapper.java @@ -21,9 +21,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import java.util.List; - public interface TeamMapper extends BaseMapper { - - List selectTeamsByUserId(Long userId); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCandidateUsersRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCandidateUsersRequest.java deleted file mode 100644 index 950123e301..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCandidateUsersRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.member; - -import org.apache.streampark.console.core.request.common.TeamIdRequest; - -import lombok.Getter; -import lombok.Setter; - -/** Request body for {@code POST /member/candidateUsers}. */ -@Getter -@Setter -public class MemberCandidateUsersRequest extends TeamIdRequest { - - private static final long serialVersionUID = 1L; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCheckUserRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCheckUserRequest.java deleted file mode 100644 index 44c518d290..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCheckUserRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.member; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotNull; - -import java.io.Serializable; - -/** Request body for {@code POST /member/check/user}. */ -@Getter -@Setter -public class MemberCheckUserRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotNull(message = "{required}") - private Long teamId; - - private String userName; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCreateRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCreateRequest.java deleted file mode 100644 index 462596927f..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberCreateRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.member; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -import java.io.Serializable; - -/** Request body for {@code POST /member/post}. */ -@Getter -@Setter -public class MemberCreateRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotNull - private Long teamId; - - @NotBlank - private String userName; - - @NotNull - private Long roleId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberDeleteRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberDeleteRequest.java deleted file mode 100644 index 9e49becd14..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberDeleteRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.member; - -import org.apache.streampark.console.core.request.common.TeamScopedIdRequest; - -import lombok.Getter; -import lombok.Setter; - -/** Request body for {@code DELETE /member/delete}. */ -@Getter -@Setter -public class MemberDeleteRequest extends TeamScopedIdRequest { - - private static final long serialVersionUID = 1L; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberListQueryRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberListQueryRequest.java deleted file mode 100644 index 81a56746fc..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberListQueryRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.member; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -/** Query filters for {@code POST /member/list}. */ -@Getter -@Setter -public class MemberListQueryRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - private Long teamId; - - private String userName; - - private String roleName; - - private String createTimeFrom; - - private String createTimeTo; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberTeamsRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberTeamsRequest.java deleted file mode 100644 index 9bba9ca5f5..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberTeamsRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.member; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotNull; - -import java.io.Serializable; - -/** Request body for {@code POST /member/teams}. */ -@Getter -@Setter -public class MemberTeamsRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotNull - private Long userId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberUpdateRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberUpdateRequest.java deleted file mode 100644 index 826de7da2c..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/member/MemberUpdateRequest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.member; - -import org.apache.streampark.console.core.request.common.TeamScopedIdRequest; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotNull; - -/** Request body for {@code PUT /member/update}. */ -@Getter -@Setter -public class MemberUpdateRequest extends TeamScopedIdRequest { - - private static final long serialVersionUID = 1L; - - private Long userId; - - @NotNull - private Long roleId; - - private String userName; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/menu/MenuListQueryRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/menu/MenuListQueryRequest.java deleted file mode 100644 index c3f0aaefd8..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/menu/MenuListQueryRequest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.menu; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -/** Query filters for {@code POST /menu/list}. */ -@Getter -@Setter -public class MenuListQueryRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - private String menuName; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleCheckNameRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleCheckNameRequest.java deleted file mode 100644 index 3b8ffb722c..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleCheckNameRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.role; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; - -import java.io.Serializable; - -/** Request body for {@code POST /role/check/name}. */ -@Getter -@Setter -public class RoleCheckNameRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotBlank(message = "{required}") - private String roleName; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleCreateRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleCreateRequest.java deleted file mode 100644 index 734a90e631..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleCreateRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.role; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; - -import java.io.Serializable; - -/** Request body for {@code POST /role/post}. */ -@Getter -@Setter -public class RoleCreateRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotBlank(message = "{required}") - @Size(max = 10, message = "{noMoreThan}") - private String roleName; - - @Size(max = 255, message = "{noMoreThan}") - private String description; - - /** Comma-separated menu ids, aligned with webapp {@code RoleParam.menuId}. */ - private String menuId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleDeleteRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleDeleteRequest.java deleted file mode 100644 index 9442b9fd17..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleDeleteRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.role; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotNull; - -import java.io.Serializable; - -/** Request body for {@code DELETE /role/delete}. */ -@Getter -@Setter -public class RoleDeleteRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotNull - private Long roleId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleListQueryRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleListQueryRequest.java deleted file mode 100644 index 47e800732c..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleListQueryRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.role; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -/** Query filters for {@code POST /role/list}. */ -@Getter -@Setter -public class RoleListQueryRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - private String roleName; - - private String createTimeFrom; - - private String createTimeTo; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleMenuQueryRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleMenuQueryRequest.java deleted file mode 100644 index fbb06d6944..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleMenuQueryRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.role; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; - -import java.io.Serializable; - -/** Request body for {@code POST /role/menu}. */ -@Getter -@Setter -public class RoleMenuQueryRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotBlank(message = "{required}") - private String roleId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleUpdateRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleUpdateRequest.java deleted file mode 100644 index f3f68528e8..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/role/RoleUpdateRequest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.role; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import java.io.Serializable; - -/** Request body for {@code PUT /role/update}. */ -@Getter -@Setter -public class RoleUpdateRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotNull - private Long roleId; - - @Size(max = 10, message = "{noMoreThan}") - private String roleName; - - @Size(max = 255, message = "{noMoreThan}") - private String description; - - /** Comma-separated menu ids. */ - private String menuId; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamCheckNameRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamCheckNameRequest.java deleted file mode 100644 index feadb9fbcd..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamCheckNameRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.team; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; - -import java.io.Serializable; - -/** Request body for {@code POST /team/check/name}. */ -@Getter -@Setter -public class TeamCheckNameRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotBlank(message = "{required}") - private String teamName; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamCreateRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamCreateRequest.java deleted file mode 100644 index 58c8ae1b90..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamCreateRequest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.team; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; - -import java.io.Serializable; - -/** Request body for {@code POST /team/post}. */ -@Getter -@Setter -public class TeamCreateRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotBlank(message = "{required}") - @Size(min = 4, max = 20, message = "{range}") - private String teamName; - - private String description; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamDeleteRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamDeleteRequest.java deleted file mode 100644 index f63657526f..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamDeleteRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.team; - -import org.apache.streampark.console.core.request.common.IdRequest; - -import lombok.Getter; -import lombok.Setter; - -/** Request body for {@code DELETE /team/delete}. */ -@Getter -@Setter -public class TeamDeleteRequest extends IdRequest { - - private static final long serialVersionUID = 1L; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamListQueryRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamListQueryRequest.java deleted file mode 100644 index cf68abea7d..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamListQueryRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.team; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -/** Query filters for {@code POST /team/list}. */ -@Getter -@Setter -public class TeamListQueryRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - private String teamName; - - private String createTimeFrom; - - private String createTimeTo; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamUpdateRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamUpdateRequest.java deleted file mode 100644 index b8b9088eee..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/team/TeamUpdateRequest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.request.team; - -import org.apache.streampark.console.core.request.common.IdRequest; - -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; - -/** Request body for {@code PUT /team/update}. */ -@Getter -@Setter -public class TeamUpdateRequest extends IdRequest { - - private static final long serialVersionUID = 1L; - - @NotBlank(message = "{required}") - @Size(min = 4, max = 20, message = "{range}") - private String teamName; - - private String description; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/user/UserTeamIdRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/user/UserTeamIdRequest.java index c61dbdfd3e..17b39663c8 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/user/UserTeamIdRequest.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/request/user/UserTeamIdRequest.java @@ -22,7 +22,7 @@ import lombok.Getter; import lombok.Setter; -/** Request body for {@code POST /user/set_team} and {@code POST /user/appOwners}. */ +/** Request body for {@code POST /user/appOwners}. */ @Getter @Setter public class UserTeamIdRequest extends TeamIdRequest { diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/member/MemberResponse.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/member/MemberResponse.java deleted file mode 100644 index 5972989e4b..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/member/MemberResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.response.member; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; -import java.util.Date; - -/** - * API response for a team member record, aligned with webapp {@code MemberListRecord}. - */ -@Getter -@Setter -public class MemberResponse implements Serializable { - - private static final long serialVersionUID = 1L; - - private Long id; - - private Long teamId; - - private Long userId; - - private Long roleId; - - private Date createTime; - - private Date modifyTime; - - private String userName; - - private String roleName; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/menu/MenuListResponse.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/menu/MenuListResponse.java deleted file mode 100644 index 18144a3a53..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/menu/MenuListResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.response.menu; - -import org.apache.streampark.console.base.domain.router.RouterTree; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; -import java.util.List; - -/** Response for {@code POST /menu/list}. */ -@Getter -@Setter -@SuppressWarnings("java:S1948") -public class MenuListResponse implements Serializable { - - private static final long serialVersionUID = 1L; - - private List ids; - - private Integer total; - - private RouterTree rows; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/role/RoleResponse.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/role/RoleResponse.java deleted file mode 100644 index ff2b442c01..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/role/RoleResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.response.role; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; -import java.util.Date; - -/** - * API response for a role record, aligned with webapp {@code RoleListRecord}. - */ -@Getter -@Setter -public class RoleResponse implements Serializable { - - private static final long serialVersionUID = 1L; - - private Long roleId; - - private String roleName; - - private String description; - - private Date createTime; - - private Date modifyTime; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/team/TeamResponse.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/team/TeamResponse.java deleted file mode 100644 index aa86e9aabf..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/team/TeamResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.response.team; - -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; -import java.util.Date; - -/** - * API response for a team record, aligned with webapp {@code TeamListRecord}. - */ -@Getter -@Setter -public class TeamResponse implements Serializable { - - private static final long serialVersionUID = 1L; - - private Long id; - - private String teamName; - - private String description; - - private Date createTime; - - private Date modifyTime; -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserBriefResponse.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserBriefResponse.java index 0bc36847cd..6fecfe382b 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserBriefResponse.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserBriefResponse.java @@ -17,6 +17,8 @@ package org.apache.streampark.console.system.response.user; +import org.apache.streampark.console.core.enums.UserTypeEnum; + import lombok.Getter; import lombok.Setter; @@ -39,6 +41,8 @@ public class UserBriefResponse implements Serializable { private String description; + private UserTypeEnum userType; + private Long lastTeamId; private String id; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserSessionResponse.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserSessionResponse.java index bd8f1d410e..8349f7e95d 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserSessionResponse.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/response/user/UserSessionResponse.java @@ -39,5 +39,5 @@ public class UserSessionResponse implements Serializable { private UserBriefResponse user; - private Set permissions; + private Set roles; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java index 8b61003d5a..8d3d72db8d 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java @@ -116,7 +116,7 @@ private User newUserCreate(LoginTypeEnum loginTypeEnum, String username) throws newUser.setUsername(username); newUser.setNickName(username); newUser.setLoginType(loginTypeEnum); - newUser.setUserType(UserTypeEnum.USER); + newUser.setUserType(UserTypeEnum.EDITOR); newUser.setStatus(User.STATUS_VALID); newUser.setSex(User.SEX_UNKNOWN); newUser.setPassword(User.DEFAULT_SECRET); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/MemberService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/MemberService.java deleted file mode 100644 index c17092f57a..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/MemberService.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.service; - -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.entity.Team; -import org.apache.streampark.console.system.entity.User; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.List; - -public interface MemberService extends IService { - - /** - * Remove Member by role ids - * - * @param roleIds List of role id - */ - void removeByRoleIds(String[] roleIds); - - /** - * Remove Member by user id - * - * @param userId user id - */ - void removeByUserId(Long userId); - - /** - * Remove Member by team Id - * - * @param teamId team Id - */ - void removeByTeamId(Long teamId); - - /** - * Retrieves a page of {@link Member} objects based on the provided parameters. - * - * @param member The {@link Member} object containing the search criteria. - * @param request The {@link RestRequest} object used for pagination and sorting. - * @return An {@link IPage} containing the retrieved {@link Member} objects. - */ - IPage getPage(Member member, RestRequest request); - - /** - * List all users who are not in the team with the passed team id - * - * @param teamId team id - * @return List of User - */ - List listUsersNotInTeam(Long teamId); - - /** - * List all Teams, those containing the passed user id - * - * @param userId User id - * @return List of Team - */ - List listTeamsByUserId(Long userId); - - /** - * Get Member by team id and username - * - * @param teamId team id - * @param userName username - * @return Member - */ - Member getByTeamIdUserName(Long teamId, String userName); - - /** - * List all User ids based on Role id as a condition - * - * @param roleId - * @return List of User ids - */ - List listUserIdsByRoleId(Long roleId); - - /** - * Create a new Member instance - * - * @param member Member - */ - void createMember(Member member); - - /** - * Remove a member - * - * @param id Member id to be removed - */ - void remove(Long id); - - /** - * Update Member - * - * @param member Member which one contains the information to be updated - */ - void updateMember(Member member); -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/MenuService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/MenuService.java index 9e9e997587..04faac6e92 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/MenuService.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/MenuService.java @@ -23,37 +23,19 @@ import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; -import java.util.Map; /** This interface is used to control the menu of the page */ public interface MenuService extends IService { /** - * Get the permissions of current userId. - * - * @param userId the user Id - * @param teamId team id. If it's null, will find permissions from all teams. - * @return permissions - */ - List listPermissions(Long userId, Long teamId); - - /** - * * List menus based on user id and team id + * List menus for one of the two built-in user roles. * * @param userId user id - * @param teamId team id + * @param teamId ignored legacy parameter * @return List of Menu */ List listMenus(Long userId, Long teamId); - /** - * List menus map based on menu - * - * @param menu Menu - * @return Menus Map - */ - Map listMenuMap(Menu menu); - /** * List Menu Routers based on user id and team id * diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleMenuService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleMenuService.java deleted file mode 100644 index 13c041b03c..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleMenuService.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.service; - -import org.apache.streampark.console.system.entity.RoleMenu; - -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.List; - -/** This interface is used to handle the relationship between permissions and menus */ -public interface RoleMenuService extends IService { - - /** - * Remove the association of RoleMenu by role id - * - * @param roleId role id - */ - void removeByRoleId(Long roleId); - - /** - * Remove the association of RoleMenu by menu Ids - * - * @param menuIds list of menu id - */ - void removeByMenuIds(String[] menuIds); - - /** - * List the association of RoleMenu by role id - * - * @param roleId role id - * @return - */ - List listByRoleId(String roleId); -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleService.java deleted file mode 100644 index 1ad8eca0b0..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleService.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.service; - -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.system.entity.Role; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; - -public interface RoleService extends IService { - - /** - * Retrieves a page of {@link Role} objects based on the provided parameters. - * - * @param role The {@link Role} object containing the search criteria. - * @param request The {@link RestRequest} object used for pagination and sorting. - * @return An {@link IPage} containing the retrieved {@link Role} objects. - */ - IPage getPage(Role role, RestRequest request); - - /** - * Get the Role by role name - * - * @param roleName role name - * @return Role - */ - Role getByName(String roleName); - - /** - * Create role instance - * - * @param role Role - */ - void createRole(Role role); - - /** - * Remove Role by role id - * - * @param roleId role id - */ - void removeById(Long roleId); - - /** - * Update Role with incoming information - * - * @param role Role - */ - void updateRole(Role role); - - /** - * Get the Default Role - * - */ - Role getSysDefaultRole(); -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamService.java index 7dcd3209f7..6afa5fadd2 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamService.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamService.java @@ -17,66 +17,16 @@ package org.apache.streampark.console.system.service; -import org.apache.streampark.console.base.domain.RestRequest; import org.apache.streampark.console.system.entity.Team; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; -import java.util.List; - public interface TeamService extends IService { /** - * Retrieves a page of {@link Team} objects based on the provided parameters. - * - * @param team The {@link Team} object containing the search criteria. - * @param request The {@link RestRequest} object used for pagination and sorting. - * @return An {@link IPage} containing the retrieved {@link Team} objects. - */ - IPage getPage(Team team, RestRequest request); - - /** - * Get the Team by team name - * - * @param teamName team name - * @return Team - */ - Team getByName(String teamName); - - /** - * Create a Team instance - * - * @param team Team - */ - void createTeam(Team team); - - /** - * Remove the Team by team id + * Get the internal default workspace used by legacy team_id columns. * - * @param teamId team id + * @return default workspace */ - void removeById(Long teamId); - - /** - * Update Team information carried by the incoming Team - * - * @param team Team - */ - void updateTeam(Team team); - - /** - * List All team by user id - * - * @param userId user id - * @return List of Team - */ - List listByUserId(Long userId); - - /** - * get system default team - * @return - */ - Team getSysDefaultTeam(); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserService.java index 71b517bb90..224a36eebe 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserService.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserService.java @@ -26,11 +26,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; -import javax.annotation.Nullable; - import java.util.List; import java.util.Map; -import java.util.Set; public interface UserService extends IService { @@ -88,15 +85,6 @@ public interface UserService extends IService { */ String resetPassword(String username) throws Exception; - /** - * Get the permissions of current userId. - * - * @param userId the user Id - * @param teamId team id. If it's null, will find permissions from all teams. - * @return permissions - */ - Set listPermissions(Long userId, @Nullable Long teamId); - /** * List all users without tokens * @@ -104,29 +92,6 @@ public interface UserService extends IService { */ List listNoTokenUser(); - /** - * Populate the LastTeam field in User - * - * @param teamId team id - * @param userId user id - */ - void setLastTeam(Long teamId, Long userId); - - /** - * Clean the LastTeam field in User - * - * @param userId user id - * @param teamId team id - */ - void clearLastTeam(Long userId, Long teamId); - - /** - * Clean the LastTeam field in User - * - * @param teamId team id - */ - void clearLastTeam(Long teamId); - /** * List all Users by team id * diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MemberServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MemberServiceImpl.java deleted file mode 100644 index e7ea0de901..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MemberServiceImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.service.impl; - -import org.apache.streampark.common.util.AssertUtils; -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.base.exception.ApiAlertException; -import org.apache.streampark.console.base.mybatis.pager.MybatisPager; -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.entity.Team; -import org.apache.streampark.console.system.entity.User; -import org.apache.streampark.console.system.mapper.MemberMapper; -import org.apache.streampark.console.system.service.MemberService; -import org.apache.streampark.console.system.service.RoleService; -import org.apache.streampark.console.system.service.TeamService; -import org.apache.streampark.console.system.service.UserService; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -@Service -@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) -public class MemberServiceImpl extends ServiceImpl implements MemberService { - - @Autowired - private UserService userService; - - @Autowired - private RoleService roleService; - - @Autowired - private TeamService teamService; - - @Override - @Transactional - public void removeByRoleIds(String[] roleIds) { - this.lambdaUpdate().in(Member::getRoleId, Arrays.asList(roleIds)).remove(); - } - - @Override - @Transactional - public void removeByUserId(Long userId) { - this.lambdaUpdate().eq(Member::getUserId, userId).remove(); - } - - @Override - public void removeByTeamId(Long teamId) { - this.lambdaUpdate().eq(Member::getTeamId, teamId).remove(); - } - - @Override - public IPage getPage(Member member, RestRequest request) { - ApiAlertException.throwIfNull(member.getTeamId(), "The team id is required."); - Page page = MybatisPager.getPage(request); - return baseMapper.selectPage(page, member); - } - - @Override - public List listUsersNotInTeam(Long teamId) { - return baseMapper.selectUsersNotInTeam(teamId); - } - - @Override - public List listTeamsByUserId(Long userId) { - return teamService.listByUserId(userId); - } - - @Override - public Member getByTeamIdUserName(Long teamId, String userName) { - User user = userService.getByUsername(userName); - if (user == null) { - return null; - } - return findByUserId(teamId, user.getUserId()); - } - - private Member findByUserId(Long teamId, Long userId) { - ApiAlertException.throwIfNull(teamId, "The team id is required."); - return this.lambdaQuery() - .eq(Member::getTeamId, teamId) - .eq(Member::getUserId, userId) - .one(); - } - - @Override - public List listUserIdsByRoleId(Long roleId) { - List memberList = this.lambdaQuery().eq(Member::getRoleId, roleId).list(); - return memberList.stream().map(Member::getUserId).collect(Collectors.toList()); - } - - @Override - public void createMember(Member member) { - User user = userService.getByUsername(member.getUserName()); - ApiAlertException.throwIfNull(user, "The username [%s] not found", member.getUserName()); - - ApiAlertException.throwIfNull( - roleService.getById(member.getRoleId()), "The roleId [%s] not found", member.getRoleId()); - Team team = teamService.getById(member.getTeamId()); - ApiAlertException.throwIfNull(team, "The teamId [%s] not found", member.getTeamId()); - ApiAlertException.throwIfNotNull( - findByUserId(member.getTeamId(), user.getUserId()), - "The user [%s] has been added the team [%s], please don't add it again.", - member.getUserName(), - team.getTeamName()); - - member.setId(null); - member.setUserId(user.getUserId()); - - this.save(member); - } - - @Override - public void remove(Long id) { - Member member = this.getById(id); - ApiAlertException.throwIfNull(member, "The member [id=%s] not found", id); - this.removeById(member); - userService.clearLastTeam(member.getUserId(), member.getTeamId()); - } - - @Override - public void updateMember(Member member) { - Member oldMember = this.getById(member.getId()); - ApiAlertException.throwIfNull(oldMember, "The member [id=%s] not found", member.getId()); - AssertUtils.state( - oldMember.getTeamId().equals(member.getTeamId()), "Team id cannot be changed."); - AssertUtils.state( - oldMember.getUserId().equals(member.getUserId()), "User id cannot be changed."); - ApiAlertException.throwIfNull( - roleService.getById(member.getRoleId()), "The roleId [%s] not found", member.getRoleId()); - oldMember.setRoleId(member.getRoleId()); - updateById(oldMember); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MenuServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MenuServiceImpl.java index 5a8b551a89..1a55c43509 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MenuServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MenuServiceImpl.java @@ -18,7 +18,6 @@ package org.apache.streampark.console.system.service.impl; import org.apache.streampark.console.base.domain.router.RouterMeta; -import org.apache.streampark.console.base.domain.router.RouterTree; import org.apache.streampark.console.base.domain.router.VueRouter; import org.apache.streampark.console.base.util.VueRouterUtils; import org.apache.streampark.console.core.enums.UserTypeEnum; @@ -28,87 +27,45 @@ import org.apache.streampark.console.system.service.MenuService; import org.apache.streampark.console.system.service.UserService; -import org.apache.commons.lang3.StringUtils; - import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; +import java.util.Set; -@Slf4j @Service @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class MenuServiceImpl extends ServiceImpl implements MenuService { - public static final String IDS = "ids"; - public static final String ROWS = "rows"; - public static final String TOTAL = "total"; + private static final Set REMOVED_PERMISSION_MENU_PATHS = new HashSet<>(Arrays.asList( + "/system/member", "/system/menu", "/system/role", "/system/team", "/system/token")); + + private static final Set ADMIN_MENU_PATHS = new HashSet<>(Arrays.asList( + "/setting/system", "/system", "/system/user")); @Autowired private UserService userService; - @Override - public List listPermissions(Long userId, Long teamId) { - User user = Optional.ofNullable(userService.getById(userId)) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("The userId [%s] not found", userId))); - // Admin has the permission for all menus. - if (UserTypeEnum.ADMIN == user.getUserType()) { - return this.list().stream().map(Menu::getPerms).collect(Collectors.toList()); - } - return this.baseMapper.selectPermissions(userId, teamId); - } - @Override public List listMenus(Long userId, Long teamId) { User user = Optional.ofNullable(userService.getById(userId)) .orElseThrow( () -> new IllegalArgumentException( String.format("The userId:[%s] not found", userId))); - // Admin has the permission for all menus. - if (UserTypeEnum.ADMIN == user.getUserType()) { - return this.lambdaQuery().eq(Menu::getType, "0") - .orderByAsc(Menu::getOrderNum).list(); - } - return this.baseMapper.selectMenus(userId, teamId); - } - - @Override - public Map listMenuMap(Menu menu) { - Map result = new HashMap<>(16); - try { - List menus = this.lambdaQuery() - .eq(StringUtils.isNotBlank(menu.getMenuName()), Menu::getMenuName, menu.getMenuName()) - .list(); - - List> trees = new ArrayList<>(); - List ids = new ArrayList<>(); - - menus.forEach( - m -> { - ids.add(m.getMenuId().toString()); - trees.add(new RouterTree<>(m)); - }); - result.put(IDS, ids); - result.put(TOTAL, menus.size()); - RouterTree routerTree = VueRouterUtils.buildRouterTree(trees); - result.put(ROWS, routerTree); - } catch (Exception e) { - log.error("Failed to query menu", e); - result.put(ROWS, null); - result.put(TOTAL, 0); + List menus = this.lambdaQuery().eq(Menu::getType, "0") + .orderByAsc(Menu::getOrderNum).list(); + menus.removeIf(menu -> REMOVED_PERMISSION_MENU_PATHS.contains(menu.getPath())); + if (UserTypeEnum.ADMIN != user.getUserType()) { + menus.removeIf(menu -> ADMIN_MENU_PATHS.contains(menu.getPath())); } - return result; + return menus; } @Override diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleMenuServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleMenuServiceImpl.java deleted file mode 100644 index d1c3eb9d7e..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleMenuServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.service.impl; - -import org.apache.streampark.console.system.entity.RoleMenu; -import org.apache.streampark.console.system.mapper.RoleMenuMapper; -import org.apache.streampark.console.system.service.RoleMenuService; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Arrays; -import java.util.List; - -@Service -@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) -public class RoleMenuServiceImpl extends ServiceImpl - implements - RoleMenuService { - - @Override - @Transactional - public void removeByRoleId(Long roleId) { - this.lambdaUpdate().eq(RoleMenu::getRoleId, roleId).remove(); - } - - @Override - @Transactional - public void removeByMenuIds(String[] menuIds) { - this.lambdaUpdate().in(RoleMenu::getRoleId, Arrays.asList(menuIds)).remove(); - } - - @Override - public List listByRoleId(String roleId) { - return this.lambdaQuery().eq(RoleMenu::getRoleId, roleId).list(); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java deleted file mode 100644 index eefb80b8a5..0000000000 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.service.impl; - -import org.apache.streampark.console.base.domain.Constant; -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.base.exception.ApiAlertException; -import org.apache.streampark.console.base.mybatis.pager.MybatisPager; -import org.apache.streampark.console.system.entity.Role; -import org.apache.streampark.console.system.entity.RoleMenu; -import org.apache.streampark.console.system.mapper.RoleMapper; -import org.apache.streampark.console.system.mapper.RoleMenuMapper; -import org.apache.streampark.console.system.service.MemberService; -import org.apache.streampark.console.system.service.RoleMenuService; -import org.apache.streampark.console.system.service.RoleService; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -@Slf4j -@Service -@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) -public class RoleServiceImpl extends ServiceImpl implements RoleService { - - @Autowired - private RoleMenuMapper roleMenuMapper; - - @Autowired - private MemberService memberService; - - @Autowired - private RoleMenuService roleMenuService; - - @Override - public IPage getPage(Role role, RestRequest request) { - Page page = MybatisPager.getPage(request); - return this.lambdaQuery() - .like(StringUtils.isNotBlank(role.getRoleName()), Role::getRoleName, role.getRoleName()) - .page(page); - } - - @Override - public Role getByName(String roleName) { - return this.lambdaQuery().eq(Role::getRoleName, roleName).one(); - } - - @Override - public void createRole(Role role) { - this.save(role); - - String[] menuIds = role.getMenuId().split(StringPool.COMMA); - updateRoleMenus(role, menuIds); - } - - @Override - public void removeById(Long roleId) { - Role role = Optional.ofNullable(this.getById(roleId)) - .orElseThrow( - () -> new ApiAlertException( - String.format("Role id [%s] not found. Delete role failed.", - roleId))); - List userIdsByRoleId = memberService.listUserIdsByRoleId(roleId); - ApiAlertException.throwIfFalse( - CollectionUtils.isEmpty(userIdsByRoleId), - String.format( - "There are some users of role %s, delete role failed, please unbind it first.", - role.getRoleName())); - super.removeById(roleId); - this.roleMenuService.removeByRoleId(roleId); - } - - @Override - public void updateRole(Role role) { - baseMapper.updateById(role); - roleMenuService.removeByRoleId(role.getRoleId()); - String menuId = role.getMenuId(); - if (StringUtils.contains(menuId, Constant.APP_DETAIL_MENU_ID) - && !StringUtils.contains(menuId, Constant.APP_MENU_ID)) { - menuId = menuId + StringPool.COMMA + Constant.APP_MENU_ID; - } - String[] menuIds = menuId.split(StringPool.COMMA); - updateRoleMenus(role, menuIds); - } - - private void updateRoleMenus(Role role, String[] menuIds) { - List roleMenus = new ArrayList<>(); - for (String menuId : menuIds) { - RoleMenu rm = new RoleMenu(); - rm.setMenuId(Long.valueOf(menuId)); - rm.setRoleId(role.getRoleId()); - roleMenus.add(rm); - } - roleMenuService.saveBatch(roleMenus); - } - - @Override - public Role getSysDefaultRole() { - return this.lambdaQuery().eq(Role::getRoleId, Constant.DEFAULT_ROLE_ID).one(); - } -} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java index 0820c5ba9a..cbcec37208 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java @@ -18,133 +18,19 @@ package org.apache.streampark.console.system.service.impl; import org.apache.streampark.console.base.domain.Constant; -import org.apache.streampark.console.base.domain.RestRequest; -import org.apache.streampark.console.base.exception.ApiAlertException; -import org.apache.streampark.console.base.mybatis.pager.MybatisPager; -import org.apache.streampark.console.core.enums.UserTypeEnum; -import org.apache.streampark.console.core.service.ProjectService; -import org.apache.streampark.console.core.service.VariableService; -import org.apache.streampark.console.core.service.application.FlinkApplicationInfoService; -import org.apache.streampark.console.core.util.ServiceHelper; import org.apache.streampark.console.system.entity.Team; -import org.apache.streampark.console.system.entity.User; import org.apache.streampark.console.system.mapper.TeamMapper; -import org.apache.streampark.console.system.service.MemberService; import org.apache.streampark.console.system.service.TeamService; -import org.apache.streampark.console.system.service.UserService; -import org.apache.commons.lang3.StringUtils; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import java.util.List; -import java.util.Optional; - -@Slf4j @Service @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class TeamServiceImpl extends ServiceImpl implements TeamService { - @Autowired - private UserService userService; - - @Autowired - private FlinkApplicationInfoService applicationInfoService; - - @Autowired - private ProjectService projectService; - - @Autowired - private MemberService memberService; - - @Autowired - private VariableService variableService; - - @Override - public IPage getPage(Team team, RestRequest request) { - Page page = MybatisPager.getPage(request); - return this.lambdaQuery() - .like(StringUtils.isNotBlank(team.getTeamName()), Team::getTeamName, team.getTeamName()) - .page(page); - } - - @Override - public Team getByName(String teamName) { - return this.lambdaQuery().eq(Team::getTeamName, teamName).one(); - } - - @Override - public void createTeam(Team team) { - Team existedTeam = getByName(team.getTeamName()); - ApiAlertException.throwIfFalse( - existedTeam == null, - String.format( - "Team name [%s] exists already. Create team failed. Please rename and try again.", - team.getTeamName())); - team.setId(null); - this.save(team); - } - - @Override - public void removeById(Long teamId) { - log.info("{} Proceed delete team[Id={}]", ServiceHelper.getLoginUser().getUsername(), teamId); - Team team = this.getById(teamId); - - ApiAlertException.throwIfNull(team, "The team[Id=%s] doesn't exist.", teamId); - - ApiAlertException.throwIfTrue( - applicationInfoService.existsByTeamId(teamId), - "Please delete the applications under the team[name=%s] first!", - team.getTeamName()); - - ApiAlertException.throwIfTrue( - projectService.existsByTeamId(teamId), - "Please delete the projects under the team[name=%s] first!", - team.getTeamName()); - - ApiAlertException.throwIfTrue( - variableService.existsByTeamId(teamId), - "Please delete the variables under the team[name=%s] first!", - team.getTeamName()); - - memberService.removeByTeamId(teamId); - userService.clearLastTeam(teamId); - super.removeById(teamId); - } - - @Override - public void updateTeam(Team team) { - Team oldTeam = Optional.ofNullable(this.getById(team.getId())) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("Team id [id=%s] not found", team.getId()))); - ApiAlertException.throwIfFalse( - oldTeam.getTeamName().equals(team.getTeamName()), - "Team name can't be changed. Update team failed."); - oldTeam.setDescription(team.getDescription()); - updateById(oldTeam); - } - - @Override - public List listByUserId(Long userId) { - User user = Optional.ofNullable(userService.getById(userId)) - .orElseThrow( - () -> new ApiAlertException( - String.format("The userId [%s] not found.", userId))); - // Admin has the permission for all teams. - if (UserTypeEnum.ADMIN == user.getUserType()) { - return this.list(); - } - return baseMapper.selectTeamsByUserId(userId); - } - @Override public Team getSysDefaultTeam() { return getById(Constant.DEFAULT_TEAM_ID); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java index 6012950f85..ab583c476f 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java @@ -25,19 +25,15 @@ import org.apache.streampark.console.base.util.ShaHashUtils; import org.apache.streampark.console.core.enums.AuthenticationType; import org.apache.streampark.console.core.enums.LoginTypeEnum; +import org.apache.streampark.console.core.enums.UserTypeEnum; import org.apache.streampark.console.core.service.ResourceService; import org.apache.streampark.console.core.service.application.FlinkApplicationInfoService; import org.apache.streampark.console.core.service.application.FlinkApplicationManageService; +import org.apache.streampark.console.core.util.ServiceHelper; import org.apache.streampark.console.system.authentication.JWTToken; import org.apache.streampark.console.system.authentication.JWTUtil; -import org.apache.streampark.console.system.entity.Member; -import org.apache.streampark.console.system.entity.Role; -import org.apache.streampark.console.system.entity.Team; import org.apache.streampark.console.system.entity.User; import org.apache.streampark.console.system.mapper.UserMapper; -import org.apache.streampark.console.system.service.MemberService; -import org.apache.streampark.console.system.service.MenuService; -import org.apache.streampark.console.system.service.RoleService; import org.apache.streampark.console.system.service.TeamService; import org.apache.streampark.console.system.service.UserService; import org.apache.streampark.console.system.service.result.UserLoginResult; @@ -55,28 +51,18 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import javax.annotation.Nullable; - import java.time.LocalDateTime; import java.util.Collections; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; @Slf4j @Service @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class UserServiceImpl extends ServiceImpl implements UserService { - @Autowired - private MemberService memberService; - - @Autowired - private MenuService menuService; - @Autowired private FlinkApplicationManageService applicationManageService; @@ -89,9 +75,6 @@ public class UserServiceImpl extends ServiceImpl implements Us @Autowired private TeamService teamService; - @Autowired - private RoleService roleService; - @Override public User getByUsername(String username) { return this.lambdaQuery().eq(User::getUsername, username).one(); @@ -115,23 +98,17 @@ public void updateLoginTime(String username) { @Override public void createUser(User user) { + if (user.getUserType() == null) { + user.setUserType(UserTypeEnum.EDITOR); + } + user.setLastTeamId(teamService.getSysDefaultTeam().getId()); if (StringUtils.isNoneBlank(user.getPassword())) { String salt = ShaHashUtils.getRandomSalt(); String password = ShaHashUtils.encrypt(salt, user.getPassword()); user.setSalt(salt); - // default team - user.setLastTeamId(teamService.getSysDefaultTeam().getId()); user.setPassword(password); } save(user); - // set team member - Member member = new Member(); - member.setUserName(user.getUsername()); - member.setTeamId(teamService.getSysDefaultTeam().getId()); - Role role = roleService.getSysDefaultRole(); - member.setRoleId(role.getRoleId()); - member.setRoleName(role.getRoleName()); - memberService.createMember(member); } @Override @@ -159,6 +136,12 @@ private boolean needTransferResource(User existsUser, User user) { @Override public void updatePassword(User userParam) { + User currentUser = ServiceHelper.getLoginUser(); + ApiAlertException.throwIfTrue( + currentUser.getUserType() != UserTypeEnum.ADMIN + && !currentUser.getUserId().equals(userParam.getUserId()), + "Permission denied, you can only change your own password."); + User user = getById(userParam.getUserId()); ApiAlertException.throwIfNull(user, "User is null. Update password failed."); ApiAlertException.throwIfFalse( @@ -189,12 +172,6 @@ public String resetPassword(String username) { return newPassword; } - @Override - public Set listPermissions(Long userId, @Nullable Long teamId) { - List userPermissions = this.menuService.listPermissions(userId, teamId); - return new HashSet<>(userPermissions); - } - @Override public List listNoTokenUser() { List users = this.baseMapper.selectNoTokenUsers(); @@ -204,34 +181,6 @@ public List listNoTokenUser() { return users; } - @Override - public void setLastTeam(Long teamId, Long userId) { - User user = getById(userId); - AssertUtils.notNull(user); - user.setLastTeamId(teamId); - this.baseMapper.updateById(user); - } - - @Override - public void clearLastTeam(Long userId, Long teamId) { - User user = getById(userId); - AssertUtils.notNull(user); - if (!teamId.equals(user.getLastTeamId())) { - return; - } - this.lambdaUpdate() - .eq(User::getUserId, userId) - .set(User::getLastTeamId, null) - .update(); - } - - @Override - public void clearLastTeam(Long teamId) { - this.lambdaUpdate().eq(User::getLastTeamId, teamId) - .set(User::getLastTeamId, null) - .update(); - } - @Override public List listByTeamId(Long teamId) { return baseMapper.selectUsersByAppOwner(teamId); @@ -273,12 +222,10 @@ public UserLoginResult getLoginUserInfo(User user) throws Exception { @Transactional(rollbackFor = Exception.class) public void deleteUser(Long userId) { removeById(userId); - this.memberService.removeByUserId(userId); } /** - * generate user info, contains: 1.token, 2.vue router, 3.role, 4.permission, 5.personalized - * config info of frontend + * Generate frontend user information with a fixed role. * * @param user user * @return UserInfo @@ -298,15 +245,11 @@ public Map generateFrontendUserInfo(User user, JWTToken token) { userInfo.put("user", user); if (user.getLastTeamId() == null) { - List teams = this.teamService.listByUserId(user.getUserId()); - if (!teams.isEmpty()) { - user.setLastTeamId(teams.get(0).getId()); - } + user.setLastTeamId(teamService.getSysDefaultTeam().getId()); } - // 3) permissions - Set permissions = this.listPermissions(user.getUserId(), user.getLastTeamId()); - userInfo.put("permissions", permissions); + // 3) one fixed role; roles are not editable permission collections + userInfo.put("roles", Collections.singleton(user.getUserType().getRoleName())); return userInfo; } diff --git a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql index 7dac02fb6b..87831bd886 100644 --- a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql +++ b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql @@ -187,130 +187,13 @@ insert into `t_menu` values (150502, 150500, 'member add', null, null, 'member:a insert into `t_menu` values (150503, 150500, 'member update', null, null, 'member:update', null, '1', 1, null, now(), now()); insert into `t_menu` values (150504, 150500, 'member delete', null, null, 'member:delete', null, '1', 1, null, now(), now()); --- ---------------------------- --- Records of t_role --- ---------------------------- -insert into `t_role` values (100001, 'developer', now(), now(), 'developer'); -insert into `t_role` values (100002, 'team admin', now(), now(), 'Team Admin has all permissions inside the team.'); - --- ---------------------------- --- Records of t_role_menu --- ---------------------------- -insert into `t_role_menu` values (100000, 100001, 110000); -insert into `t_role_menu` values (100001, 100001, 110100); -insert into `t_role_menu` values (100002, 100001, 110101); -insert into `t_role_menu` values (100003, 100001, 110102); -insert into `t_role_menu` values (100004, 100001, 110103); -insert into `t_role_menu` values (100005, 100001, 110104); -insert into `t_role_menu` values (100006, 100001, 110105); -insert into `t_role_menu` values (100007, 100001, 110106); -insert into `t_role_menu` values (100008, 100001, 110107); -insert into `t_role_menu` values (100009, 100001, 110108); -insert into `t_role_menu` values (100010, 100001, 110109); -insert into `t_role_menu` values (100011, 100001, 110110); -insert into `t_role_menu` values (100012, 100001, 110111); -insert into `t_role_menu` values (100013, 100001, 110112); -insert into `t_role_menu` values (100014, 100001, 110113); -insert into `t_role_menu` values (100015, 100001, 110114); -insert into `t_role_menu` values (100016, 100001, 110115); -insert into `t_role_menu` values (100017, 100001, 110116); -insert into `t_role_menu` values (100018, 100001, 110117); -insert into `t_role_menu` values (100019, 100001, 110118); -insert into `t_role_menu` values (100020, 100001, 110200); -insert into `t_role_menu` values (100021, 100001, 110300); -insert into `t_role_menu` values (100022, 100001, 110301); -insert into `t_role_menu` values (100023, 100001, 110302); -insert into `t_role_menu` values (100024, 100001, 120000); -insert into `t_role_menu` values (100025, 100001, 130000); -insert into `t_role_menu` values (100026, 100001, 130100); -insert into `t_role_menu` values (100027, 100001, 130101); -insert into `t_role_menu` values (100028, 100001, 130102); -insert into `t_role_menu` values (100029, 100001, 130103); -insert into `t_role_menu` values (100030, 100001, 130104); -insert into `t_role_menu` values (100031, 100001, 130105); -insert into `t_role_menu` values (100032, 100001, 130200); -insert into `t_role_menu` values (100033, 100001, 130201); -insert into `t_role_menu` values (100034, 100001, 130202); -insert into `t_role_menu` values (100035, 100001, 130203); -insert into `t_role_menu` values (100036, 100001, 130204); -insert into `t_role_menu` values (100037, 100001, 130205); -insert into `t_role_menu` values (100038, 100001, 130206); -insert into `t_role_menu` values (100039, 100001, 130207); -insert into `t_role_menu` values (100040, 100001, 130300); -insert into `t_role_menu` values (100041, 100001, 130301); -insert into `t_role_menu` values (100042, 100001, 130302); -insert into `t_role_menu` values (100043, 100001, 130303); -insert into `t_role_menu` values (100044, 100001, 140000); -insert into `t_role_menu` values (100045, 100001, 140100); -insert into `t_role_menu` values (100046, 100001, 140101); -insert into `t_role_menu` values (100047, 100002, 110000); -insert into `t_role_menu` values (100048, 100002, 110100); -insert into `t_role_menu` values (100049, 100002, 110101); -insert into `t_role_menu` values (100050, 100002, 110102); -insert into `t_role_menu` values (100051, 100002, 110103); -insert into `t_role_menu` values (100052, 100002, 110104); -insert into `t_role_menu` values (100053, 100002, 110105); -insert into `t_role_menu` values (100054, 100002, 110106); -insert into `t_role_menu` values (100055, 100002, 110107); -insert into `t_role_menu` values (100056, 100002, 110108); -insert into `t_role_menu` values (100057, 100002, 110109); -insert into `t_role_menu` values (100058, 100002, 110110); -insert into `t_role_menu` values (100059, 100002, 110111); -insert into `t_role_menu` values (100060, 100002, 110112); -insert into `t_role_menu` values (100061, 100002, 110113); -insert into `t_role_menu` values (100062, 100002, 110114); -insert into `t_role_menu` values (100063, 100002, 110115); -insert into `t_role_menu` values (100064, 100002, 110116); -insert into `t_role_menu` values (100065, 100002, 110117); -insert into `t_role_menu` values (100066, 100002, 110118); -insert into `t_role_menu` values (100067, 100002, 110200); -insert into `t_role_menu` values (100068, 100002, 110300); -insert into `t_role_menu` values (100069, 100002, 110301); -insert into `t_role_menu` values (100070, 100002, 110302); -insert into `t_role_menu` values (100071, 100002, 120000); -insert into `t_role_menu` values (100072, 100002, 130000); -insert into `t_role_menu` values (100073, 100002, 130100); -insert into `t_role_menu` values (100074, 100002, 130101); -insert into `t_role_menu` values (100075, 100002, 130102); -insert into `t_role_menu` values (100076, 100002, 130103); -insert into `t_role_menu` values (100077, 100002, 130104); -insert into `t_role_menu` values (100078, 100002, 130105); -insert into `t_role_menu` values (100079, 100002, 130200); -insert into `t_role_menu` values (100080, 100002, 130201); -insert into `t_role_menu` values (100081, 100002, 130202); -insert into `t_role_menu` values (100082, 100002, 130203); -insert into `t_role_menu` values (100083, 100002, 130204); -insert into `t_role_menu` values (100084, 100002, 130205); -insert into `t_role_menu` values (100085, 100002, 130206); -insert into `t_role_menu` values (100086, 100002, 130207); -insert into `t_role_menu` values (100087, 100002, 130300); -insert into `t_role_menu` values (100088, 100002, 130301); -insert into `t_role_menu` values (100089, 100002, 130302); -insert into `t_role_menu` values (100090, 100002, 130303); -insert into `t_role_menu` values (100091, 100002, 140000); -insert into `t_role_menu` values (100092, 100002, 140100); -insert into `t_role_menu` values (100093, 100002, 140101); -insert into `t_role_menu` values (100094, 100002, 140102); -insert into `t_role_menu` values (100095, 100002, 140200); -insert into `t_role_menu` values (100096, 100002, 140300); -insert into `t_role_menu` values (100097, 100002, 140301); -insert into `t_role_menu` values (100098, 100002, 140302); -insert into `t_role_menu` values (100099, 100002, 140303); -insert into `t_role_menu` values (100100, 100002, 140304); -insert into `t_role_menu` values (100101, 100002, 140400); -insert into `t_role_menu` values (100102, 100002, 140401); -insert into `t_role_menu` values (100103, 100002, 140402); -insert into `t_role_menu` values (100104, 100002, 140403); -insert into `t_role_menu` values (100105, 100002, 150000); -insert into `t_role_menu` values (100106, 100002, 150500); -insert into `t_role_menu` values (100107, 100002, 150501); -insert into `t_role_menu` values (100108, 100002, 150502); -insert into `t_role_menu` values (100109, 100002, 150503); -insert into `t_role_menu` values (100110, 100002, 150504); - -- ---------------------------- -- Records of t_setting -- ---------------------------- +delete from `t_menu` +where `type` = '1' + or `path` in ('/system/menu', '/system/role', '/system/team', '/system/member', '/system/token'); + insert into `t_setting` values (1, 'streampark.maven.settings', null, 'Maven Settings File Path', 'Maven Settings.xml full path', 1); insert into `t_setting` values (2, 'streampark.maven.central.repository', null, 'Maven Central Repository', 'Maven private server address', 1); insert into `t_setting` values (3, 'streampark.maven.auth.user', null, 'Maven Central Repository Auth User', 'Maven private server authentication username', 1); @@ -334,12 +217,3 @@ insert into `t_user` values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', insert into `t_user` values (100001, 'test1', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 2, 0, 100000, '1', now(), now(),null,'0',null,null); insert into `t_user` values (100002, 'test2', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 2, 0, 100000, '1', now(), now(),null,'0',null,null); insert into `t_user` values (100003, 'test3', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 2, 0, 100001, '1', now(), now(),null,'0',null,null); - --- ---------------------------- --- Records of t_member --- ---------------------------- -insert into `t_member` values (100000, 100000, 100001, 100001, now(), now()); -- test_user1 is the developer of the default team -insert into `t_member` values (100001, 100001, 100001, 100002, now(), now()); -- test_user1 is the team admin of the test team -insert into `t_member` values (100002, 100000, 100002, 100001, now(), now()); -- test_user2 is the developer of the test team -insert into `t_member` values (100003, 100001, 100003, 100001, now(), now()); -- test_user3 is the developer of the test team -insert into `t_member` values (100004, 100000, 100000, 100001, now(), now()); -- admin is the developer of the default team diff --git a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql index 3197caf56c..5a99c1adee 100644 --- a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql +++ b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql @@ -329,29 +329,6 @@ create table if not exists `t_variable` ( unique (`team_id`, `variable_code`) ); --- ---------------------------- --- Table structure for t_role --- ---------------------------- -create table if not exists `t_role` ( - `role_id` bigint generated by default as identity not null comment 'user id', - `role_name` varchar(64) not null comment 'user name', - `create_time` datetime default null comment 'create time', - `modify_time` datetime default null comment 'modify time', - `description` varchar(255) default null comment 'description', - primary key(`role_id`) -); - --- ---------------------------- --- Table structure for t_role_menu --- ---------------------------- -create table if not exists `t_role_menu` ( - `id` bigint generated by default as identity not null, - `role_id` bigint not null, - `menu_id` bigint not null, - primary key(`id`), - unique (`role_id`,`menu_id`) -); - -- ---------------------------- -- Table structure for t_setting -- ---------------------------- @@ -374,7 +351,7 @@ create table if not exists `t_user` ( `salt` varchar(26) default null comment 'salt', `password` varchar(64) default null comment 'password', `email` varchar(64) default null comment 'email', - `user_type` int not null comment 'user type 1:admin 2:user', + `user_type` int not null comment 'user role 1:admin 2:editor', `login_type` tinyint default 0 comment 'login type 0:password 1:ldap 2:sso', `last_team_id` bigint default null comment 'last team id', `status` char(1) not null comment 'status 0:locked 1:active', @@ -388,20 +365,6 @@ create table if not exists `t_user` ( unique (`username`) ); --- ---------------------------- --- Table structure for t_member --- ---------------------------- -create table if not exists `t_member` ( - `id` bigint generated by default as identity not null, - `team_id` bigint not null comment 'team id', - `user_id` bigint not null comment 'user id', - `role_id` bigint not null comment 'role id', - `create_time` datetime default null comment 'create time', - `modify_time` datetime default null comment 'modify time', - primary key(`id`), - unique (`team_id`, `user_id`,`role_id`) -); - -- ---------------------------- -- Table of t_app_build_pipe -- ---------------------------- diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/system/MemberMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/system/MemberMapper.xml deleted file mode 100644 index 03aba47f31..0000000000 --- a/streampark-console/streampark-console-service/src/main/resources/mapper/system/MemberMapper.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/system/MenuMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/system/MenuMapper.xml index e6a31b8002..e085f35817 100644 --- a/streampark-console/streampark-console-service/src/main/resources/mapper/system/MenuMapper.xml +++ b/streampark-console/streampark-console-service/src/main/resources/mapper/system/MenuMapper.xml @@ -32,35 +32,4 @@ - - - - - - diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/system/RoleMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/system/RoleMapper.xml deleted file mode 100644 index 1b307870cb..0000000000 --- a/streampark-console/streampark-console-service/src/main/resources/mapper/system/RoleMapper.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMapper.xml index 38cb61997f..7973267d7b 100644 --- a/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMapper.xml +++ b/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMapper.xml @@ -17,10 +17,4 @@ --> - diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/web/FormOrJsonArgumentResolverTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/web/FormOrJsonArgumentResolverTest.java index 48c27a1619..b1f988331e 100644 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/web/FormOrJsonArgumentResolverTest.java +++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/web/FormOrJsonArgumentResolverTest.java @@ -17,7 +17,7 @@ package org.apache.streampark.console.base.web; -import org.apache.streampark.console.system.request.team.TeamCreateRequest; +import org.apache.streampark.console.system.request.user.UserCreateRequest; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; @@ -44,37 +44,38 @@ void setUp() { void shouldBindFromJsonBody() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setContentType("application/json"); - request.setContent("{\"teamName\":\"demo\",\"description\":\"test\"}".getBytes()); + request.setContent("{\"username\":\"editor\",\"status\":\"1\",\"sex\":\"2\"}".getBytes()); org.springframework.core.MethodParameter parameter = new org.springframework.core.MethodParameter(FormOrJsonArgumentResolverTest.class.getDeclaredMethod( - "sample", TeamCreateRequest.class), 0); + "sample", UserCreateRequest.class), 0); Object target = resolver.resolveArgument( parameter, null, new ServletWebRequest(request), null); - TeamCreateRequest dto = (TeamCreateRequest) target; - assertEquals("demo", dto.getTeamName()); + UserCreateRequest dto = (UserCreateRequest) target; + assertEquals("editor", dto.getUsername()); } @Test void shouldBindFromFormFields() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setContentType("application/x-www-form-urlencoded"); - request.addParameter("teamName", "demo"); - request.addParameter("description", "test"); + request.addParameter("username", "editor"); + request.addParameter("status", "1"); + request.addParameter("sex", "2"); org.springframework.core.MethodParameter parameter = new org.springframework.core.MethodParameter(FormOrJsonArgumentResolverTest.class.getDeclaredMethod( - "sample", TeamCreateRequest.class), 0); + "sample", UserCreateRequest.class), 0); Object target = resolver.resolveArgument( parameter, null, new ServletWebRequest(request), null); - TeamCreateRequest dto = (TeamCreateRequest) target; - assertEquals("demo", dto.getTeamName()); + UserCreateRequest dto = (UserCreateRequest) target; + assertEquals("editor", dto.getUsername()); } @SuppressWarnings({"java:S1144", "java:S1172"}) - private void sample(@FormOrJson TeamCreateRequest request) { + private void sample(@FormOrJson UserCreateRequest request) { // referenced reflectively by resolveArgument tests } } diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/aspect/PermissionAspectTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/aspect/PermissionAspectTest.java deleted file mode 100644 index 04a4ad75c6..0000000000 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/aspect/PermissionAspectTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.core.aspect; - -import org.apache.streampark.console.base.domain.RestResponseBody; -import org.apache.streampark.console.core.controller.FlinkApplicationController; -import org.apache.streampark.console.core.request.flink.FlinkAppIdRequest; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.lang.reflect.Method; - -/** Verifies {@link PermissionAspect} signature accepts {@link RestResponseBody} returns. */ -class PermissionAspectTest { - - @Test - void permissionAspectShouldDeclareObjectReturnType() throws NoSuchMethodException { - Method aspectMethod = PermissionAspect.class.getDeclaredMethod( - "permissionAction", org.aspectj.lang.ProceedingJoinPoint.class); - Assertions.assertEquals(Object.class, aspectMethod.getReturnType()); - } - - @Test - void permissionProtectedControllerShouldReturnRestResponseBody() throws NoSuchMethodException { - Method getMethod = FlinkApplicationController.class.getMethod("get", FlinkAppIdRequest.class); - Assertions.assertTrue( - RestResponseBody.class.isAssignableFrom(getMethod.getReturnType())); - } -} diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/component/ApiTypeScriptGeneratorTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/component/ApiTypeScriptGeneratorTest.java index d0926fb383..38e2b065b8 100644 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/component/ApiTypeScriptGeneratorTest.java +++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/component/ApiTypeScriptGeneratorTest.java @@ -21,7 +21,7 @@ import org.apache.streampark.console.core.bean.ApiContractDocument.ApiEndpointDescriptor; import org.apache.streampark.console.core.bean.OpenAPISchema; import org.apache.streampark.console.core.request.common.IdRequest; -import org.apache.streampark.console.system.request.team.TeamCreateRequest; +import org.apache.streampark.console.system.request.user.UserCreateRequest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -37,16 +37,16 @@ class ApiTypeScriptGeneratorTest { void shouldGenerateInterfacesFromContractDocument() { ApiContractDocument document = new ApiContractDocument(); ApiEndpointDescriptor endpoint = new ApiEndpointDescriptor(); - endpoint.setController("TeamController"); - endpoint.setHandler("addTeam"); - endpoint.setPath("/team/post"); + endpoint.setController("UserController"); + endpoint.setHandler("addUser"); + endpoint.setPath("/user/post"); endpoint.setHttpMethod("POST"); - endpoint.setRequestType("TeamCreateRequest"); + endpoint.setRequestType("UserCreateRequest"); endpoint.setResponseDataType("Void"); document.setEndpoints(Collections.singletonList(endpoint)); Map> dtoSchemas = new LinkedHashMap<>(); - dtoSchemas.put("TeamCreateRequest", RequestDtoSchemaBuilder.build(TeamCreateRequest.class, null, + dtoSchemas.put("UserCreateRequest", RequestDtoSchemaBuilder.build(UserCreateRequest.class, null, RequestDtoSchemaBuilder.defaultTypeNames())); dtoSchemas.put("IdRequest", RequestDtoSchemaBuilder.build(IdRequest.class, null, RequestDtoSchemaBuilder.defaultTypeNames())); @@ -54,7 +54,7 @@ void shouldGenerateInterfacesFromContractDocument() { String typescript = ApiTypeScriptGenerator.generate(document); - Assertions.assertTrue(typescript.contains("export interface TeamCreateRequest")); + Assertions.assertTrue(typescript.contains("export interface UserCreateRequest")); Assertions.assertTrue(typescript.contains("export interface RestResponseBody")); Assertions.assertTrue(typescript.contains("export const apiEndpoints")); } diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/UserServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/UserServiceTest.java index d9f00f4bf8..d2de306041 100644 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/UserServiceTest.java +++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/UserServiceTest.java @@ -53,7 +53,7 @@ void testLockUser() throws Exception { user.setUsername("test"); user.setNickName("test"); user.setPassword("test"); - user.setUserType(UserTypeEnum.USER); + user.setUserType(UserTypeEnum.EDITOR); user.setStatus(User.STATUS_VALID); userService.createUser(user); // lock user @@ -84,7 +84,7 @@ void testTransferResource() { user.setUsername("test"); user.setNickName("test"); user.setPassword("test"); - user.setUserType(UserTypeEnum.USER); + user.setUserType(UserTypeEnum.EDITOR); user.setStatus(User.STATUS_VALID); userService.save(user); @@ -105,7 +105,7 @@ void testTransferResource() { targetUser.setUsername("test0"); targetUser.setNickName("test0"); targetUser.setPassword("test0"); - targetUser.setUserType(UserTypeEnum.USER); + targetUser.setUserType(UserTypeEnum.EDITOR); targetUser.setStatus(User.STATUS_VALID); userService.save(targetUser); diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/assembler/UserAssemblerTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/assembler/UserAssemblerTest.java index fc735b3a0d..96e58a41dd 100644 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/assembler/UserAssemblerTest.java +++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/assembler/UserAssemblerTest.java @@ -21,11 +21,15 @@ import org.apache.streampark.console.core.enums.UserTypeEnum; import org.apache.streampark.console.system.entity.User; import org.apache.streampark.console.system.response.user.UserResponse; +import org.apache.streampark.console.system.response.user.UserSessionResponse; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.stream.Collectors; class UserAssemblerTest { @@ -38,7 +42,7 @@ void shouldExcludeSensitiveFieldsFromResponse() { user.setPassword("secret"); user.setSalt("salt"); user.setEmail("admin@example.com"); - user.setUserType(UserTypeEnum.USER); + user.setUserType(UserTypeEnum.EDITOR); user.setLoginType(LoginTypeEnum.PASSWORD); UserResponse response = UserAssembler.toResponse(user); @@ -52,4 +56,21 @@ void shouldExcludeSensitiveFieldsFromResponse() { Assertions.assertFalse(fieldNames.contains("password")); Assertions.assertFalse(fieldNames.contains("salt")); } + + @Test + void shouldExposeOnlyTheFixedRoleInSessionResponse() { + User user = new User(); + user.setUserId(1L); + user.setUsername("developer"); + user.setUserType(UserTypeEnum.EDITOR); + + Map session = new HashMap<>(); + session.put("user", user); + session.put("roles", Collections.singleton("editor")); + + UserSessionResponse response = UserAssembler.toSessionResponse(session); + + Assertions.assertEquals(Collections.singleton("editor"), response.getRoles()); + Assertions.assertEquals(UserTypeEnum.EDITOR, response.getUser().getUserType()); + } } diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/RoleControllerMvcTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/RoleControllerMvcTest.java deleted file mode 100644 index 6c8575d734..0000000000 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/RoleControllerMvcTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.controller; - -import org.apache.streampark.console.base.handler.GlobalExceptionHandler; -import org.apache.streampark.console.system.service.RoleMenuService; -import org.apache.streampark.console.system.service.RoleService; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@WebMvcTest(RoleController.class) -@AutoConfigureMockMvc(addFilters = false) -@Import(GlobalExceptionHandler.class) -class RoleControllerMvcTest { - - @Autowired - private MockMvc mockMvc; - - @MockBean - private RoleService roleService; - - @MockBean - private RoleMenuService roleMenuService; - - @Test - void checkRoleNameShouldRejectBlankName() throws Exception { - mockMvc.perform( - post("/role/check/name") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .param("roleName", "")) - .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.status").value("error")); - } -} diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/TeamControllerMvcTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/TeamControllerMvcTest.java deleted file mode 100644 index e5ac19fe9b..0000000000 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/TeamControllerMvcTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.streampark.console.system.controller; - -import org.apache.streampark.console.base.handler.GlobalExceptionHandler; -import org.apache.streampark.console.base.web.FormOrJsonArgumentResolver; -import org.apache.streampark.console.system.service.TeamService; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@WebMvcTest(TeamController.class) -@AutoConfigureMockMvc(addFilters = false) -@Import({GlobalExceptionHandler.class, FormOrJsonArgumentResolver.class, TeamControllerMvcTest.MvcTestConfig.class}) -class TeamControllerMvcTest { - - @Autowired - private MockMvc mockMvc; - - @MockBean - private TeamService teamService; - - @org.springframework.boot.test.context.TestConfiguration - static class MvcTestConfig implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer { - - @Autowired - private FormOrJsonArgumentResolver formOrJsonArgumentResolver; - - @Override - public void addArgumentResolvers( - java.util.List resolvers) { - resolvers.add(formOrJsonArgumentResolver); - } - } - - @Test - void addTeamShouldAcceptFormUrlEncodedBody() throws Exception { - doNothing().when(teamService).createTeam(any()); - - mockMvc.perform( - post("/team/post") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .param("teamName", "demo") - .param("description", "test")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")); - } - - @Test - void addTeamShouldAcceptJsonBody() throws Exception { - doNothing().when(teamService).createTeam(any()); - - mockMvc.perform( - post("/team/post") - .contentType(MediaType.APPLICATION_JSON) - .content("{\"teamName\":\"demo\",\"description\":\"test\"}")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")); - } - - @Test - void addTeamShouldRejectBlankTeamNameJson() throws Exception { - mockMvc.perform( - post("/team/post") - .contentType(MediaType.APPLICATION_JSON) - .content("{\"teamName\":\"\",\"description\":\"test\"}")) - .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.status").value("error")); - } -} diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/UserControllerMvcTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/UserControllerMvcTest.java index 990d970351..9c5fd5dbe0 100644 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/UserControllerMvcTest.java +++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/controller/UserControllerMvcTest.java @@ -18,7 +18,6 @@ package org.apache.streampark.console.system.controller; import org.apache.streampark.console.base.handler.GlobalExceptionHandler; -import org.apache.streampark.console.system.service.TeamService; import org.apache.streampark.console.system.service.UserService; import org.junit.jupiter.api.Test; @@ -45,9 +44,6 @@ class UserControllerMvcTest { @MockBean private UserService userService; - @MockBean - private TeamService teamService; - @Test void checkUserNameShouldRejectBlankUsername() throws Exception { mockMvc.perform( diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/request/SystemRequestValidationTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/request/SystemRequestValidationTest.java index 0ec1a2acfe..f15437b51b 100644 --- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/request/SystemRequestValidationTest.java +++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/request/SystemRequestValidationTest.java @@ -17,8 +17,7 @@ package org.apache.streampark.console.system.request; -import org.apache.streampark.console.system.request.member.MemberCreateRequest; -import org.apache.streampark.console.system.request.team.TeamCreateRequest; +import org.apache.streampark.console.system.request.user.UserCreateRequest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -34,14 +33,9 @@ class SystemRequestValidationTest { private final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); @Test - void teamCreateRequestShouldRequireTeamName() { - Set> violations = validator.validate(new TeamCreateRequest()); + void userCreateRequestShouldRequireStatusAndSex() { + Set> violations = validator.validate(new UserCreateRequest()); Assertions.assertFalse(violations.isEmpty()); } - @Test - void memberCreateRequestShouldRequireCoreFields() { - Set> violations = validator.validate(new MemberCreateRequest()); - Assertions.assertTrue(violations.size() >= 3); - } } diff --git a/streampark-console/streampark-console-webapp/src/api/base/model/systemModel.ts b/streampark-console/streampark-console-webapp/src/api/base/model/systemModel.ts deleted file mode 100644 index 0395f35270..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/base/model/systemModel.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel'; - -export type RoleParams = { - roleName?: string; - status?: string; -}; - -export type RolePageParams = BasicPageParams & RoleParams; - -export type MenuParams = { - menuName?: string; - status?: string; - roleId?: number; - type?: string; -}; - -export interface UserListItem { - userId: string; - username: string; - nickName: string; - createTime: string; - status: number; - lastTeamId: number; -} - -export interface RoleListItem { - id: string; - roleName: string; - roleValue: string; - status: number; - orderNo: string; - createTime: string; -} - -export type UserListGetResultModel = BasicFetchResult; - -export type RolePageListGetResultModel = BasicFetchResult; - -export interface MenuListModel { - ids: Array; - rows: any; - total: number; -} diff --git a/streampark-console/streampark-console-webapp/src/api/base/system.ts b/streampark-console/streampark-console-webapp/src/api/base/system.ts deleted file mode 100644 index 29ce5fecc0..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/base/system.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { - MenuParams, - RolePageParams, - RolePageListGetResultModel, - MenuListModel, - UserListGetResultModel, -} from './model/systemModel'; -import { defHttp } from '/@/utils/http/axios'; -import { BasicPageParams } from '/@/api/model/baseModel'; - -enum Api { - MenuList = '/menu/list', - RoleMenu = '/role/menu', - RolePageList = '/role/list', - UserList = '/user/list', -} - -export const getMenuList = (params?: MenuParams): Promise => { - return defHttp.post({ url: Api.MenuList, params }); -}; - -export const getRoleMenu = (params?: MenuParams) => - defHttp.post>({ - url: Api.RoleMenu, - params, - }); -/** - * get role list - * @param {RolePageParams} params - * @returns {Promise} - */ -export const getRoleListByPage = (params?: RolePageParams) => - defHttp.post({ url: Api.RolePageList, params }); - -export const getUserListByPage = (params?: BasicPageParams) => - defHttp.post({ url: Api.UserList, params }); diff --git a/streampark-console/streampark-console-webapp/src/api/system/member.ts b/streampark-console/streampark-console-webapp/src/api/system/member.ts deleted file mode 100644 index 9cb2dd7c21..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/system/member.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { BasicTableParams } from './../model/baseModel'; -import { defHttp } from '/@/utils/http/axios'; -import { Result } from '/#/axios'; -import { AxiosResponse } from 'axios'; -import { AddMemberParams, MemberListRecord, UpdateMemberParams } from './model/memberModel'; -import { UserListItem } from '/@/api/base/model/systemModel'; - -enum MEMBER_API { - POST = '/member/post', - UPDATE = '/member/update', - LIST = '/member/list', - TEAMS = '/member/teams', - CHECK_NAME = '/user/check/name', - DELETE = '/member/delete', - CANDIDATE_USERS = '/member/candidateUsers', -} - -/** - * get candidate users add to the target team - * @param params - * @returns - */ -export function fetchCandidateUsers(params?: { - teamId: string | number; -}): Promise> { - return defHttp.post({ url: MEMBER_API.CANDIDATE_USERS, params }); -} - -/** - * get member list - * @param params - * @returns - */ -export function fetchMemberList(data: BasicTableParams): Promise { - return defHttp.post({ url: MEMBER_API.LIST, data }); -} - -/** - * add member - * @param {String} userName username - * @param {Number} roleId role id - * @returns {Promise} - */ -export function fetchAddMember(data: AddMemberParams) { - return defHttp.post({ url: MEMBER_API.POST, data }); -} -/** - * update member - * @param {UpdateMemberParams} data - * @returns {Promise} - */ -export function fetchUpdateMember(data: UpdateMemberParams): Promise { - return defHttp.put({ url: MEMBER_API.UPDATE, data }); -} -/** - * Find user team - * @param {Object} data - * @returns {Promise>} - */ -export function fetchUserTeam(data: { - userId: number | string; -}): Promise> { - return defHttp.post({ url: MEMBER_API.TEAMS, data }); -} -/** - * name check - * @param {Object} data username - * @returns {Promise} - */ -export function fetchCheckUserName(data: { username: string }): Promise { - return defHttp.post({ url: MEMBER_API.CHECK_NAME, data }); -} - -/** - * delete - * @param {String} data memeber Id - * @returns {Promise>} - */ -export function fetchMemberDelete(data: { id: string }): Promise> { - return defHttp.delete({ url: MEMBER_API.DELETE, data }, { isReturnNativeResponse: true }); -} diff --git a/streampark-console/streampark-console-webapp/src/api/system/model/memberModel.ts b/streampark-console/streampark-console-webapp/src/api/system/model/memberModel.ts deleted file mode 100644 index 19a762d08b..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/system/model/memberModel.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export interface MemberListRecord { - id: string; - teamId: string; - userId: string; - roleId: string; - createTime: string; - modifyTime: string; - userName: string; - roleName: string; - sortField?: string; - sortOrder?: string; - createTimeFrom?: string; - createTimeTo?: string; -} -export interface AddMemberParams { - userName: string; - roleId: number; -} - -export interface UpdateMemberParams extends AddMemberParams { - id: string; - userId: string; -} diff --git a/streampark-console/streampark-console-webapp/src/api/system/model/roleModel.ts b/streampark-console/streampark-console-webapp/src/api/system/model/roleModel.ts deleted file mode 100644 index e91b93ad8c..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/system/model/roleModel.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export interface RoleParam { - roleId?: number; - roleName: string; - description: string; - menuId: string[]; -} - -export interface RoleListRecord { - roleId: string; - roleName: string; - roleCode?: any; - description: string; - createTime: string; - modifyTime: string; - sortField?: any; - sortOrder?: any; - createTimeFrom?: any; - createTimeTo?: any; - menuId?: any; -} diff --git a/streampark-console/streampark-console-webapp/src/api/system/model/teamModel.ts b/streampark-console/streampark-console-webapp/src/api/system/model/teamModel.ts deleted file mode 100644 index 5b786894f8..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/system/model/teamModel.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export interface TeamListRecord { - id: string; - teamName: string; - description: string; - createTime: string; - modifyTime: string; - sortField?: any; - sortOrder?: any; - createTimeFrom?: any; - createTimeTo?: any; -} - -export interface TeamParam { - id?: string; - teamName: string; - description: string; -} diff --git a/streampark-console/streampark-console-webapp/src/api/system/model/userModel.ts b/streampark-console/streampark-console-webapp/src/api/system/model/userModel.ts index 67a4f2ec70..2d393e295b 100644 --- a/streampark-console/streampark-console-webapp/src/api/system/model/userModel.ts +++ b/streampark-console/streampark-console-webapp/src/api/system/model/userModel.ts @@ -23,17 +23,11 @@ export interface LoginParams { loginType: string; } -export interface RoleInfo { - roleName: string; - value: string; -} - /** * @description: Login interface return value */ export interface LoginResultModel { expire?: string; - permissions: string[]; roles: string[]; token: string; user: GetUserInfoModel; @@ -43,20 +37,14 @@ export interface LoginResultModel { * @description: Get user information return value */ export interface GetUserInfoModel { - roles: RoleInfo[]; userId: string | number; username: string; nickName: string; avatar: string; desc?: string; lastTeamId?: string; + userType: 'ADMIN' | 'EDITOR'; } -export interface TeamSetResponse { - permissions: string[]; - roles: string[]; - user: GetUserInfoModel; -} - // user list api response export interface UserListRecord { userId: string; diff --git a/streampark-console/streampark-console-webapp/src/api/system/role.ts b/streampark-console/streampark-console-webapp/src/api/system/role.ts deleted file mode 100644 index a361e9d81b..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/system/role.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { defHttp } from '/@/utils/http/axios'; -import { RoleParam } from './model/roleModel'; - -enum Api { - AddRole = '/role/post', - UpdateRole = '/role/update', - DeleteRole = '/role/delete', - CHECK_NAME = '/role/check/name', -} - -/** - * - * @param {RoleParam} data role param - * @returns {Promise} - */ -export function fetchRoleCreate(data: RoleParam): Promise { - return defHttp.post({ url: Api.AddRole, data }); -} - -/** - * role update - * @param {RoleParam} data role param - * @returns {Promise} - */ -export function fetchRoleUpdate(data: RoleParam): Promise { - return defHttp.put({ url: Api.UpdateRole, data }); -} - -/** - * delete role - * @param {String} roleId role id - * @returns {Promise} - */ -export function fetchRoleDelete({ roleId }: { roleId: string }): Promise { - return defHttp.delete({ url: Api.DeleteRole, data: { roleId } }); -} -/** - * Check if the role name exists - * @returns {Promise} - * @param data - */ -export function fetchCheckName(data: { roleName: string }): Promise { - return defHttp.post({ url: Api.CHECK_NAME, data }); -} diff --git a/streampark-console/streampark-console-webapp/src/api/system/team.ts b/streampark-console/streampark-console-webapp/src/api/system/team.ts deleted file mode 100644 index b43b3fb1fa..0000000000 --- a/streampark-console/streampark-console-webapp/src/api/system/team.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { defHttp } from '/@/utils/http/axios'; -import { Result } from '/#/axios'; -import { AxiosResponse } from 'axios'; -import { BasicTableParams } from '../model/baseModel'; -import { TeamListRecord, TeamParam } from './model/teamModel'; - -enum Api { - POST = '/team/post', - UPDATE = '/team/update', - LIST = '/team/list', - DELETE = '/team/delete', -} - -/** - * get team list - * @param {BasicTableParams} data - * @returns {Promise<>} - */ -export function fetTeamList(data: BasicTableParams): Promise { - return defHttp.post({ url: Api.LIST, data }); -} -/** - * Create an organization - * @param {TeamParam} data - * @returns {Promise} - */ -export function fetchTeamCreate(data: TeamParam): Promise { - return defHttp.post({ url: Api.POST, data }); -} - -/** - * update organization - * @param {TeamParam} data - * @returns {Promise} - */ -export function fetchTeamUpdate(data: TeamParam): Promise { - return defHttp.put({ url: Api.UPDATE, data }); -} -/** - * delete organization - * @returns {Promise>} - * @param params - */ -export function fetchTeamDelete(params: { id: string }): Promise> { - return defHttp.delete( - { url: Api.DELETE, params }, - { isReturnNativeResponse: true, errorMessageMode: 'none' }, - ); -} diff --git a/streampark-console/streampark-console-webapp/src/api/system/user.ts b/streampark-console/streampark-console-webapp/src/api/system/user.ts index 4c47db9c89..b8fb51c56a 100644 --- a/streampark-console/streampark-console-webapp/src/api/system/user.ts +++ b/streampark-console/streampark-console-webapp/src/api/system/user.ts @@ -17,14 +17,13 @@ import { UserInfo } from '/#/store'; import { AxiosResponse } from 'axios'; import { defHttp } from '/@/utils/http/axios'; -import { GetUserInfoModel, TeamSetResponse, UserListRecord } from './model/userModel'; +import { GetUserInfoModel, UserListRecord } from './model/userModel'; import { Result } from '/#/axios'; import { BasicTableParams } from '../model/baseModel'; enum Api { Login = '/passport/signin', - GetPermCode = '/getPermCode', UserList = '/user/list', NoTokenUsers = '/user/getNoTokenUser', UserUpdate = '/user/update', @@ -33,19 +32,10 @@ enum Api { ResetPassword = '/user/password/reset', Password = '/user/password', CheckName = '/user/check/name', - SET_TEAM = '/user/set_team', APP_OWNERS = '/user/appOwners', TransferUserResource = '/user/transferResource', } -/** - * get user permission code list - * @returns {Promise} - */ -export function getPermCode(): Promise { - return defHttp.get({ url: Api.GetPermCode }); -} - /** * get user list * @param {BasicTableParams} data @@ -104,16 +94,9 @@ export function fetchAppOwners(data: Recordable): Promise> { }); } -export function fetchSetUserTeam(data: { teamId: string }): Promise { - return defHttp.post({ - url: Api.SET_TEAM, - data, - }); -} - export function transferUserResource(data: { userId: string; targetUserId: string; -}): Promise { +}): Promise { return defHttp.put({ url: Api.TransferUserResource, data }); } diff --git a/streampark-console/streampark-console-webapp/src/enums/cacheEnum.ts b/streampark-console/streampark-console-webapp/src/enums/cacheEnum.ts index 3a441a98a6..5c02d4da04 100644 --- a/streampark-console/streampark-console-webapp/src/enums/cacheEnum.ts +++ b/streampark-console/streampark-console-webapp/src/enums/cacheEnum.ts @@ -1,7 +1,6 @@ // token key export const TOKEN_KEY = 'TOKEN__'; -export const PERMISSION_KEY = 'PERMISSION__'; // expire key export const EXPIRE_KEY = 'EXPIRE__'; diff --git a/streampark-console/streampark-console-webapp/src/enums/roleEnum.ts b/streampark-console/streampark-console-webapp/src/enums/roleEnum.ts index 857868d59a..fcf2b4385f 100644 --- a/streampark-console/streampark-console-webapp/src/enums/roleEnum.ts +++ b/streampark-console/streampark-console-webapp/src/enums/roleEnum.ts @@ -1,7 +1,5 @@ export enum RoleEnum { - // super admin - SUPER = 'super', + ADMIN = 'admin', - // tester - TEST = 'test', + EDITOR = 'editor', } diff --git a/streampark-console/streampark-console-webapp/src/hooks/web/usePermission.ts b/streampark-console/streampark-console-webapp/src/hooks/web/usePermission.ts index 8f4c20985d..6d01103c82 100644 --- a/streampark-console/streampark-console-webapp/src/hooks/web/usePermission.ts +++ b/streampark-console/streampark-console-webapp/src/hooks/web/usePermission.ts @@ -1,126 +1,46 @@ -import type { RouteRecordRaw } from 'vue-router'; - -import { useAppStore } from '/@/store/modules/app'; -import { usePermissionStore } from '/@/store/modules/permission'; import { useUserStore } from '/@/store/modules/user'; - -// import { useTabs } from './useTabs'; - -import { router, resetRouter } from '/@/router'; - -import projectSetting from '/@/settings/projectSetting'; -import { AuthUserName, PermissionModeEnum } from '/@/enums/appEnum'; import { RoleEnum } from '/@/enums/roleEnum'; import { isArray } from '/@/utils/is'; -import { useMultipleTabStore } from '/@/store/modules/multipleTab'; -import { intersection } from 'lodash-es'; -import { PageEnum } from '/@/enums/pageEnum'; -import { useRedo } from './usePage'; -import { menuMap } from '/@/router/constant'; -// User permissions related operations +const ADMIN_ONLY_ACTIONS = new Set([ + 'cluster:create', + 'cluster:update', + 'externalLink:create', + 'externalLink:delete', + 'externalLink:update', + 'setting:update', + 'setting:view', + 'user:add', + 'user:delete', + 'user:reset', + 'user:types', + 'user:update', + 'yarnQueue:create', + 'yarnQueue:delete', + 'yarnQueue:update', +]); + +// Fixed role checks for actions that are visible in the UI. export function usePermission() { const userStore = useUserStore(); - const appStore = useAppStore(); - const permissionStore = usePermissionStore(); - // const { closeAll } = useTabs(router); - - /** - * Change permission mode - */ - async function togglePermissionMode() { - appStore.setProjectConfig({ - permissionMode: - projectSetting.permissionMode === PermissionModeEnum.BACK - ? PermissionModeEnum.ROUTE_MAPPING - : PermissionModeEnum.BACK, - }); - location.reload(); - } - - /** - * Reset and regain authority resource information - * @param id - */ - async function resume(nextPath?: string) { - const tabStore = useMultipleTabStore(); - tabStore.clearCacheTabs(); - - const redo = useRedo(router); - - resetRouter(); - const [routes, hasAuth] = await permissionStore.buildRoutesAction(nextPath); - routes.forEach((route) => { - router.addRoute(route as unknown as RouteRecordRaw); - }); - permissionStore.setLastBuildMenuTime(); - const currentPath = router.currentRoute.value?.path; - if (Object.keys(menuMap).includes(currentPath)) { - router.replace(menuMap[currentPath]); - } else { - if (!hasAuth) { - router.push({ path: PageEnum.BASE_HOME }); - } else { - await redo(); - } - } - - // closeAll(); - } /** * Determine whether there is permission */ function hasPermission(value?: RoleEnum | RoleEnum[] | string | string[], def = true): boolean { // Visible by default - if (!value || userStore.getUserInfo?.username === AuthUserName.ADMIN) { + if (!value || userStore.getRoleList?.includes(RoleEnum.ADMIN)) { return def; } - const permMode = projectSetting.permissionMode; - - if ([PermissionModeEnum.ROUTE_MAPPING, PermissionModeEnum.ROLE].includes(permMode)) { - if (!isArray(value)) { - return userStore.getRoleList?.includes(value as RoleEnum); - } - return (intersection(value, userStore.getRoleList) as RoleEnum[]).length > 0; - } - - if (PermissionModeEnum.BACK === permMode) { - const allCodeList = userStore.getPermissions as string[]; - if (!isArray(value)) { - return allCodeList.includes(value); - } - return (intersection(value, allCodeList) as string[]).length > 0; - } - return true; - } - - /** - * Change roles - * @param roles - */ - async function changeRole(roles: RoleEnum | RoleEnum[]): Promise { - if (projectSetting.permissionMode !== PermissionModeEnum.ROUTE_MAPPING) { - throw new Error( - 'Please switch PermissionModeEnum to ROUTE_MAPPING mode in the configuration to operate!', - ); - } - - if (!isArray(roles)) { - roles = [roles]; + const actions = isArray(value) ? value : [value]; + if (userStore.getRoleList?.includes(RoleEnum.EDITOR)) { + return actions.some((action) => !ADMIN_ONLY_ACTIONS.has(action as string)); } - userStore.setRoleList(roles); - await resume(); - } - /** - * refresh menu data - */ - async function refreshMenu(nextPath?: string) { - resume(nextPath); + return false; } - return { changeRole, hasPermission, togglePermissionMode, refreshMenu }; + return { hasPermission }; } diff --git a/streampark-console/streampark-console-webapp/src/layouts/default/header/components/UserTeam.vue b/streampark-console/streampark-console-webapp/src/layouts/default/header/components/UserTeam.vue deleted file mode 100644 index 3b385d7481..0000000000 --- a/streampark-console/streampark-console-webapp/src/layouts/default/header/components/UserTeam.vue +++ /dev/null @@ -1,46 +0,0 @@ - - - - diff --git a/streampark-console/streampark-console-webapp/src/layouts/default/header/components/index.ts b/streampark-console/streampark-console-webapp/src/layouts/default/header/components/index.ts index bf0c841c86..faa38a864e 100755 --- a/streampark-console/streampark-console-webapp/src/layouts/default/header/components/index.ts +++ b/streampark-console/streampark-console-webapp/src/layouts/default/header/components/index.ts @@ -12,8 +12,6 @@ export const Notify = createAsyncComponent(() => import('./notify/index.vue')); export const Github = createAsyncComponent(() => import('./Github.vue')); /* Slogan */ export const Slogan = createAsyncComponent(() => import('./Slogan.vue')); -/* User Team */ -export const UserTeam = createAsyncComponent(() => import('./UserTeam.vue')); export const LockScreen = createAsyncComponent(() => import('./LockScreen.vue')); export const ErrorAction = createAsyncComponent(() => import('./ErrorAction.vue')); diff --git a/streampark-console/streampark-console-webapp/src/layouts/default/header/index.vue b/streampark-console/streampark-console-webapp/src/layouts/default/header/index.vue index b565788289..0aa8aedbc3 100755 --- a/streampark-console/streampark-console-webapp/src/layouts/default/header/index.vue +++ b/streampark-console/streampark-console-webapp/src/layouts/default/header/index.vue @@ -60,7 +60,6 @@ :showText="false" :class="`${prefixCls}-action__item`" /> - @@ -85,7 +84,6 @@ import { AppLocalePicker } from '/@/components/Application'; import { - UserTeam, UserDropDown, LayoutBreadcrumb, FullScreen, @@ -111,7 +109,6 @@ LayoutBreadcrumb, LayoutMenu, UserDropDown, - UserTeam, AppLocalePicker, FullScreen, Notify, diff --git a/streampark-console/streampark-console-webapp/src/store/modules/permission.ts b/streampark-console/streampark-console-webapp/src/store/modules/permission.ts index fd7054ed1e..dbbe17eef7 100644 --- a/streampark-console/streampark-console-webapp/src/store/modules/permission.ts +++ b/streampark-console/streampark-console-webapp/src/store/modules/permission.ts @@ -19,19 +19,10 @@ import { ERROR_LOG_ROUTE, PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic'; import { filter } from '/@/utils/helper/treeHelper'; import { getMenuRouter } from '/@/api/system/menu'; -import { getPermCode } from '/@/api/system/user'; - import { useMessage } from '/@/hooks/web/useMessage'; import { PageEnum } from '/@/enums/pageEnum'; -import { fetchUserTeam } from '/@/api/system/member'; -// import { Persistent } from '/@/utils/cache/persistent'; -import { USER_INFO_KEY } from '/@/enums/cacheEnum'; -import { UserInfo } from '/#/store'; -import { getAuthCache } from '/@/utils/auth'; interface PermissionState { - // Permission code list - permCodeList: string[] | number[]; // Whether the route has been dynamically added isDynamicAddedRoute: boolean; // To trigger a menu update @@ -45,8 +36,6 @@ interface PermissionState { export const usePermissionStore = defineStore({ id: 'app-permission', state: (): PermissionState => ({ - // List of permission codes - permCodeList: [], // Whether the route has been dynamically added isDynamicAddedRoute: false, // To trigger a menu update @@ -57,9 +46,6 @@ export const usePermissionStore = defineStore({ frontMenuList: [], }), getters: { - getPermCodeList(): string[] | number[] { - return this.permCodeList; - }, getBackMenuList(): Menu[] { return this.backMenuList; }, @@ -74,10 +60,6 @@ export const usePermissionStore = defineStore({ }, }, actions: { - setPermCodeList(codeList: string[]) { - this.permCodeList = codeList; - }, - setBackMenuList(list: Menu[]) { this.backMenuList = list; list?.length > 0 && this.setLastBuildMenuTime(); @@ -96,28 +78,15 @@ export const usePermissionStore = defineStore({ }, resetState(): void { this.isDynamicAddedRoute = false; - this.permCodeList = []; this.backMenuList = []; this.lastBuildMenuTime = 0; }, - async changePermissionCode() { - const codeList = await getPermCode(); - this.setPermCodeList(codeList); - }, - // Build routing async buildRoutesAction(nextPath = ''): Promise<[AppRouteRecordRaw[], boolean]> { const { t } = useI18n(); const userStore = useUserStore(); const appStore = useAppStoreWithOut(); - // get teamList - const { userId } = getAuthCache(USER_INFO_KEY) as UserInfo; let hasAuth = false; - // Get the team list when building a route to ensure data consistency - if (userId) { - const teamList = await fetchUserTeam({ userId }); - userStore.setTeamList(teamList.map((i) => ({ label: i.teamName, value: i.id }))); - } let routes: AppRouteRecordRaw[] = []; const roleList = toRaw(userStore.getRoleList) || []; const { permissionMode = projectSetting.permissionMode } = appStore.getProjectConfig; diff --git a/streampark-console/streampark-console-webapp/src/store/modules/user.ts b/streampark-console/streampark-console-webapp/src/store/modules/user.ts index 8cbc54f448..5010b43a0a 100644 --- a/streampark-console/streampark-console-webapp/src/store/modules/user.ts +++ b/streampark-console/streampark-console-webapp/src/store/modules/user.ts @@ -6,14 +6,12 @@ import { PageEnum } from '/@/enums/pageEnum'; import { APP_TEAMID_KEY_, EXPIRE_KEY, - PERMISSION_KEY, ROLES_KEY, TOKEN_KEY, USER_INFO_KEY, } from '/@/enums/cacheEnum'; import { getAuthCache, setAuthCache } from '/@/utils/auth'; import { signout } from '/@/api/system/passport'; -import { fetchSetUserTeam } from '/@/api/system/user'; import { useI18n } from '/@/hooks/web/useI18n'; import { useMessage } from '/@/hooks/web/useMessage'; @@ -21,24 +19,17 @@ import { router } from '/@/router'; import { usePermissionStore } from '/@/store/modules/permission'; import { RouteRecordRaw } from 'vue-router'; import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic'; -import { h, unref } from 'vue'; +import { h } from 'vue'; import { getUserTeamId } from '/@/utils'; -import { usePermission } from '/@/hooks/web/usePermission'; -interface TeamListType { - label: string; - value: string; -} interface UserState { userInfo: Nullable; token?: string; expire?: string; roleList: RoleEnum[]; - permissions: string[]; sessionTimeout?: boolean; lastUpdateTime: number; teamId: string; - teamList: Array; } export const useUserStore = defineStore({ @@ -51,15 +42,12 @@ export const useUserStore = defineStore({ expire: undefined, // roleList roleList: [], - permissions: [], // Whether the login expired sessionTimeout: false, // Last fetch time lastUpdateTime: 0, // user Team teamId: getUserTeamId(), - // Maintain teamlist data - teamList: [], }), getters: { getUserInfo(): UserInfo { @@ -80,17 +68,9 @@ export const useUserStore = defineStore({ getLastUpdateTime(): number { return this.lastUpdateTime; }, - getPermissions(): string[] { - return this.permissions?.length > 0 - ? this.permissions - : getAuthCache(PERMISSION_KEY); - }, getTeamId(): string | undefined { return this.teamId; }, - getTeamList(): TeamListType[] { - return this.teamList; - }, }, actions: { setToken(info: string | undefined) { @@ -119,41 +99,13 @@ export const useUserStore = defineStore({ this.roleList = []; this.sessionTimeout = false; }, - setPermissions(permissions: string[] = []) { - this.permissions = permissions; - setAuthCache(PERMISSION_KEY, permissions); - }, setData(data: Recordable) { - const { token, expire, user, permissions, roles = [] } = data; + const { token, expire, user, roles = [] } = data; this.setToken(token); this.setExpire(expire); this.setUserInfo(user); this.setRoleList(roles); - this.setPermissions(permissions); - }, - // set team - async setTeamId(data: { teamId: string; userId?: string | number }): Promise { - try { - const { refreshMenu } = usePermission(); - // The userId passed in is the binding operation at login - const { permissions, roles = [], user } = await fetchSetUserTeam(data); - this.setUserInfo(user as UserInfo); - this.setRoleList(roles as RoleEnum[]); - this.setPermissions(permissions); - - // If it returns success, it will be stored in the local cache - this.teamId = data.teamId; - sessionStorage.setItem(APP_TEAMID_KEY_, data.teamId); - localStorage.setItem(APP_TEAMID_KEY_, data.teamId); - await refreshMenu(unref(router.currentRoute)?.path); - return Promise.resolve(true); - } catch (error) { - return Promise.reject(error); - } - }, - setTeamList(teamList: Array) { - this.teamList = teamList; }, async afterLoginAction(goHome?: boolean): Promise { if (!this.getToken) return false; diff --git a/streampark-console/streampark-console-webapp/src/utils/cache/persistent.ts b/streampark-console/streampark-console-webapp/src/utils/cache/persistent.ts index c48aac2a3b..6ec3362983 100644 --- a/streampark-console/streampark-console-webapp/src/utils/cache/persistent.ts +++ b/streampark-console/streampark-console-webapp/src/utils/cache/persistent.ts @@ -14,7 +14,6 @@ import { APP_SESSION_CACHE_KEY, MULTIPLE_TABS_KEY, EXPIRE_KEY, - PERMISSION_KEY, } from '/@/enums/cacheEnum'; import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting'; import { toRaw } from 'vue'; @@ -28,7 +27,6 @@ interface BasicStore { [LOCK_INFO_KEY]: LockInfo; [PROJ_CFG_KEY]: ProjectConfig; [MULTIPLE_TABS_KEY]: RouteLocationNormalized[]; - [PERMISSION_KEY]: string[]; } type LocalStore = BasicStore; diff --git a/streampark-console/streampark-console-webapp/src/views/base/login/LoginForm.vue b/streampark-console/streampark-console-webapp/src/views/base/login/LoginForm.vue index f000444e93..20d8c09b35 100644 --- a/streampark-console/streampark-console-webapp/src/views/base/login/LoginForm.vue +++ b/streampark-console/streampark-console-webapp/src/views/base/login/LoginForm.vue @@ -76,7 +76,6 @@ - - - diff --git a/streampark-console/streampark-console-webapp/src/views/setting/alarm/View.vue b/streampark-console/streampark-console-webapp/src/views/setting/alarm/View.vue index cc43a43e52..5d41ecd624 100644 --- a/streampark-console/streampark-console-webapp/src/views/setting/alarm/View.vue +++ b/streampark-console/streampark-console-webapp/src/views/setting/alarm/View.vue @@ -167,7 +167,7 @@
{{ t('setting.alarm.alertSetting') }} -
+
{{ t('common.add') }} @@ -206,6 +206,7 @@