You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2022/10/07 02:09:02 UTC
[incubator-streampark] branch dev updated: [Feature] Support the team management (#1733)
This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 039f0857e [Feature] Support the team management (#1733)
039f0857e is described below
commit 039f0857eb5762b52f6a019d82aa9516801681be
Author: 1996fanrui <19...@gmail.com>
AuthorDate: Fri Oct 7 10:08:53 2022 +0800
[Feature] Support the team management (#1733)
---
.../src/assembly/script/data/mysql-data.sql | 72 ++---
.../src/assembly/script/data/pgsql-data.sql | 71 ++---
.../src/assembly/script/schema/mysql-schema.sql | 34 ++-
.../src/assembly/script/schema/pgsql-schema.sql | 44 ++-
.../core/controller/ApplicationController.java | 6 +
.../console/core/controller/ProjectController.java | 6 +
.../console/core/entity/Application.java | 2 +
.../streampark/console/core/entity/Project.java | 2 +
.../enums/UserType.java} | 40 ++-
.../core/service/impl/ProjectServiceImpl.java | 2 +
.../console/system/controller/TeamController.java | 81 ++++++
.../system/controller/TeamMemberController.java | 91 ++++++
.../console/system/controller/UserController.java | 7 +
.../system/entity/{UserRole.java => Team.java} | 27 +-
.../entity/{UserRole.java => TeamMember.java} | 21 +-
.../streampark/console/system/entity/User.java | 9 +-
.../{UserRoleMapper.java => TeamMapper.java} | 28 +-
.../{UserRoleMapper.java => TeamMemberMapper.java} | 8 +-
.../security/impl/ldap/LdapAuthenticator.java | 1 -
...UserRoleService.java => TeamMemberService.java} | 18 +-
.../{UserRoleService.java => TeamService.java} | 18 +-
.../system/service/impl/MenuServiceImpl.java | 19 ++
.../system/service/impl/RoleServiceImpl.java | 6 +-
.../system/service/impl/TeamMemberServiceImpl.java | 145 ++++++++++
.../system/service/impl/TeamServiceImpl.java | 102 +++++++
.../system/service/impl/UserRoleServiceImpl.java | 60 ----
.../system/service/impl/UserServiceImpl.java | 31 +-
.../src/main/resources/db/data-h2.sql | 76 ++---
.../src/main/resources/db/schema-h2.sql | 25 +-
.../resources/mapper/core/ApplicationMapper.xml | 2 +
.../main/resources/mapper/core/ProjectMapper.xml | 2 +
.../ProjectMapper.xml => system/TeamMapper.xml} | 43 +--
.../resources/mapper/system/TeamMemberMapper.xml | 73 +++++
.../resources/mapper/system/UserRoleMapper.xml | 46 ---
.../streampark-console-webapp/src/api/index.js | 16 ++
.../src/api/member.js} | 34 ++-
.../src/api/team.js} | 27 +-
.../streampark-console-webapp/src/api/user.js | 4 +
.../src/components/tools/UserMenu.vue | 38 ++-
.../src/store/modules/user.js | 3 +-
.../src/store/mutation-types.js | 1 +
.../src/views/flink/app/Add.vue | 3 +
.../src/views/flink/app/View.vue | 12 +-
.../src/views/flink/project/Add.vue | 3 +
.../src/views/flink/project/View.vue | 5 +-
.../system/{user/User.vue => member/Member.vue} | 317 +++++++++------------
.../{user/UserAdd.vue => member/MemberAdd.vue} | 122 ++------
.../src/views/system/member/MemberEdit.vue | 157 ++++++++++
.../src/views/system/role/Role.vue | 7 -
.../views/system/{user/User.vue => team/Team.vue} | 276 +++++++-----------
.../src/views/system/team/TeamAdd.vue | 152 ++++++++++
.../src/views/system/team/TeamEdit.vue | 135 +++++++++
.../src/views/system/user/User.vue | 3 +
.../src/views/system/user/UserAdd.vue | 30 +-
.../src/views/system/user/UserEdit.vue | 39 +--
.../src/views/system/user/UserInfo.vue | 5 +-
56 files changed, 1705 insertions(+), 902 deletions(-)
diff --git a/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql b/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
index 0935cb396..30c16a36a 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
@@ -20,10 +20,17 @@ use streampark;
set names utf8mb4;
set foreign_key_checks = 0;
+
+-- ----------------------------
+-- Records of t_team
+-- ----------------------------
+insert into `t_team` values (100000, 'default', null, now(), now());
+
+
-- ----------------------------
-- Records of t_flink_app
-- ----------------------------
-insert into `t_flink_app` values (100000, 2, 4, null, null, 'Flink SQL Demo', null, null, null, null, null, null , null, 100000, null, 1, null, null, null, null, null, null, null, 0, 0, null, null, null, null, null, null, 'Flink SQL Demo', 0, null, 0, null, null, null, null, null, null, 0, 0, now(), now(), null, 1, 1, null, null, null, null, null, null, 0, null, null, null, 'streampark,test');
+insert into `t_flink_app` values (100000, 100000, 2, 4, null, null, 'Flink SQL Demo', null, null, null, null, null, null , null, 100000, null, 1, null, null, null, null, null, null, null, 0, 0, null, null, null, null, null, null, 'Flink SQL Demo', 0, null, 0, null, null, null, null, null, null, 0, 0, now(), now(), null, 1, 1, null, null, null, null, null, null, 0, null, null, null, 'streampark,test');
-- ----------------------------
-- Records of t_flink_effective
@@ -33,7 +40,7 @@ insert into `t_flink_effective` values (100000, 100000, 2, 100000, now());
-- ----------------------------
-- Records of t_flink_project
-- ----------------------------
-insert into `t_flink_project` values (100000, 'streampark-quickstart', 'https://github.com/streamxhub/streampark-quickstart.git', 'main', null, null, null, null, 1, 1, null, 'streampark-quickstart', 1, now(), now());
+insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', 'https://github.com/streamxhub/streampark-quickstart.git', 'main', null, null, null, null, 1, 1, null, 'streampark-quickstart', 1, now(), now());
-- ----------------------------
-- Records of t_flink_sql
@@ -87,57 +94,26 @@ insert into `t_menu` values (100040, 100038, 'delete', null, null, 'token:delete
insert into `t_menu` values (100041, 100013, 'Add Cluster', '/flink/setting/add_cluster', 'flink/setting/AddCluster', 'cluster:create', '', 0, 0, null, now(), now());
insert into `t_menu` values (100042, 100013, 'Edit Cluster', '/flink/setting/edit_cluster', 'flink/setting/EditCluster', 'cluster:update', '', 0, 0, null, now(), now());
insert into `t_menu` values (100043, 100015, 'copy', null, null, 'app:copy', null, 1, 1, null, now(), now());
+insert into `t_menu` values (100044, 100000, 'Team Management', '/system/team', 'system/team/Team', 'team:view', 'team', '0', 1, 2, now(), now());
+insert into `t_menu` values (100045, 100044, 'add', null, null, 'team:add', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100046, 100044, 'update', null, null, 'team:update', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100047, 100044, 'delete', null, null, 'team:delete', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100048, 100000, 'Member Management', '/system/member', 'system/member/Member', 'member:view', 'usergroup-add', '0', 1, 2, now(), now());
+insert into `t_menu` values (100049, 100048, 'add', null, null, 'member:add', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100050, 100048, 'update', null, null, 'member:update', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100051, 100048, 'delete', null, null, 'member:delete', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100052, 100048, 'role view', null, null, 'role:view', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100053, 100001, 'types', null, null, 'user:types', null, '1', 1, null, now(), now());
+
-- ----------------------------
-- Records of t_role
-- ----------------------------
-insert into `t_role` values (100000, 'admin', 'admin', now(), now(), null);
insert into `t_role` values (100001, 'developer', 'developer', now(), now(), null);
-- ----------------------------
-- Records of t_role_menu
-- ----------------------------
-insert into `t_role_menu` values (100000, 100000, 100000);
-insert into `t_role_menu` values (100001, 100000, 100001);
-insert into `t_role_menu` values (100002, 100000, 100002);
-insert into `t_role_menu` values (100003, 100000, 100003);
-insert into `t_role_menu` values (100004, 100000, 100004);
-insert into `t_role_menu` values (100005, 100000, 100005);
-insert into `t_role_menu` values (100006, 100000, 100006);
-insert into `t_role_menu` values (100007, 100000, 100007);
-insert into `t_role_menu` values (100008, 100000, 100008);
-insert into `t_role_menu` values (100009, 100000, 100009);
-insert into `t_role_menu` values (100010, 100000, 100010);
-insert into `t_role_menu` values (100011, 100000, 100011);
-insert into `t_role_menu` values (100012, 100000, 100012);
-insert into `t_role_menu` values (100013, 100000, 100013);
-insert into `t_role_menu` values (100014, 100000, 100014);
-insert into `t_role_menu` values (100015, 100000, 100015);
-insert into `t_role_menu` values (100016, 100000, 100016);
-insert into `t_role_menu` values (100017, 100000, 100017);
-insert into `t_role_menu` values (100018, 100000, 100018);
-insert into `t_role_menu` values (100019, 100000, 100019);
-insert into `t_role_menu` values (100020, 100000, 100020);
-insert into `t_role_menu` values (100021, 100000, 100021);
-insert into `t_role_menu` values (100022, 100000, 100022);
-insert into `t_role_menu` values (100023, 100000, 100023);
-insert into `t_role_menu` values (100024, 100000, 100024);
-insert into `t_role_menu` values (100025, 100000, 100025);
-insert into `t_role_menu` values (100026, 100000, 100026);
-insert into `t_role_menu` values (100027, 100000, 100027);
-insert into `t_role_menu` values (100028, 100000, 100028);
-insert into `t_role_menu` values (100029, 100000, 100029);
-insert into `t_role_menu` values (100030, 100000, 100030);
-insert into `t_role_menu` values (100031, 100000, 100031);
-insert into `t_role_menu` values (100032, 100000, 100032);
-insert into `t_role_menu` values (100033, 100000, 100033);
-insert into `t_role_menu` values (100034, 100000, 100034);
-insert into `t_role_menu` values (100035, 100000, 100035);
-insert into `t_role_menu` values (100036, 100000, 100036);
-insert into `t_role_menu` values (100037, 100000, 100037);
-insert into `t_role_menu` values (100038, 100000, 100038);
-insert into `t_role_menu` values (100039, 100000, 100039);
-insert into `t_role_menu` values (100040, 100000, 100040);
insert into `t_role_menu` values (100041, 100001, 100014);
insert into `t_role_menu` values (100042, 100001, 100016);
insert into `t_role_menu` values (100043, 100001, 100017);
@@ -157,9 +133,7 @@ insert into `t_role_menu` values (100056, 100001, 100032);
insert into `t_role_menu` values (100057, 100001, 100033);
insert into `t_role_menu` values (100058, 100001, 100013);
insert into `t_role_menu` values (100059, 100001, 100015);
-insert into `t_role_menu` values (100060, 100000, 100041);
-insert into `t_role_menu` values (100061, 100000, 100042);
-insert into `t_role_menu` values (100062, 100000, 100043);
+
-- ----------------------------
-- Records of t_setting
@@ -183,11 +157,11 @@ insert into `t_setting` values (15, 'docker.register.namespace', null, 'Namespac
-- ----------------------------
-- Records of t_user
-- ----------------------------
-insert into `t_user` values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, now(), now(),null,0,null,null );
+insert into `t_user` values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, '1', now(), now(),null,0,null,null );
-- ----------------------------
-- Records of t_user_role
-- ----------------------------
-insert into `t_user_role` values (100000, 100000, 100000);
+insert into `t_user_role` values (100000, 100000, 100000, 100001, now(), now());
set foreign_key_checks = 1;
diff --git a/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql b/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
index b47225b09..88ba165ee 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
@@ -15,10 +15,17 @@
* limitations under the License.
*/
+
+-- ----------------------------
+-- Records of t_team
+-- ----------------------------
+insert into "public"."t_team" values (100000, 'default', null, now(), now());
+
+
-- ----------------------------
-- Records of t_flink_app
-- ----------------------------
-insert into "public"."t_flink_app" values (100000, 2, 4, null, null, 'Flink SQL Demo', null, null, null, null, null, null , null, 100000, null, 1, null, null, null, null, null, null, null, 0, 0, null, null, null, null, null, null, 'Flink SQL Demo', 0, null, false, null, null, null, null, null, null, 0, 0, now(), now(), null, 1, true, null, null, null, null, null, null, false, null, null, null, 'streampark,test');
+insert into "public"."t_flink_app" values (100000, 100000, 2, 4, null, null, 'Flink SQL Demo', null, null, null, null, null, null , null, 100000, null, 1, null, null, null, null, null, null, null, 0, 0, null, null, null, null, null, null, 'Flink SQL Demo', 0, null, false, null, null, null, null, null, null, 0, 0, now(), now(), null, 1, true, null, null, null, null, null, null, false, null, null, null, 'streampark,test');
-- ----------------------------
-- Records of t_flink_effective
@@ -28,7 +35,7 @@ insert into "public"."t_flink_effective" values (100000, 100000, 2, 100000, now(
-- ----------------------------
-- Records of t_flink_project
-- ----------------------------
-insert into "public"."t_flink_project" values (100000, 'streampark-quickstart', 'https://github.com/streamxhub/streampark-quickstart.git', 'main', null, null, null, null, 1, 1, null, 'streampark-quickstart', 1, now(), now());
+insert into "public"."t_flink_project" values (100000, 100000, 'streampark-quickstart', 'https://github.com/streamxhub/streampark-quickstart.git', 'main', null, null, null, null, 1, 1, null, 'streampark-quickstart', 1, now(), now());
-- ----------------------------
@@ -83,58 +90,26 @@ insert into "public"."t_menu" values (100040, 100038, 'delete', null, null, 'tok
insert into "public"."t_menu" values (100041, 100013, 'Add Cluster', '/flink/setting/add_cluster', 'flink/setting/AddCluster', 'cluster:create', '', 0, false, null, now(), now());
insert into "public"."t_menu" values (100042, 100013, 'Edit Cluster', '/flink/setting/edit_cluster', 'flink/setting/EditCluster', 'cluster:update', '', 0, false, null, now(), now());
insert into "public"."t_menu" values (100043, 100015, 'copy', null, null, 'app:copy', null, 1, true, null, now(), now());
+insert into "public"."t_menu" values (100044, 100000, 'Team Management', '/system/team', 'system/team/Team', 'team:view', 'team', '0', 1, 2, now(), now());
+insert into "public"."t_menu" values (100045, 100044, 'add', null, null, 'team:add', null, '1', 1, null, now(), now());
+insert into "public"."t_menu" values (100046, 100044, 'update', null, null, 'team:update', null, '1', 1, null, now(), now());
+insert into "public"."t_menu" values (100047, 100044, 'delete', null, null, 'team:delete', null, '1', 1, null, now(), now());
+insert into "public"."t_menu" values (100048, 100000, 'Member Management', '/system/member', 'system/member/Member', 'member:view', 'usergroup-add', '0', 1, 2, now(), now());
+insert into "public"."t_menu" values (100049, 100048, 'add', null, null, 'member:add', null, '1', 1, null, now(), now());
+insert into "public"."t_menu" values (100050, 100048, 'update', null, null, 'member:update', null, '1', 1, null, now(), now());
+insert into "public"."t_menu" values (100051, 100048, 'delete', null, null, 'member:delete', null, '1', 1, null, now(), now());
+insert into "public"."t_menu" values (100052, 100048, 'role view', null, null, 'role:view', null, '1', 1, null, now(), now());
+insert into "public"."t_menu" values (100053, 100001, 'types', null, null, 'user:types', null, '1', 1, null, now(), now());
-- ----------------------------
-- Records of t_role
-- ----------------------------
-insert into "public"."t_role" values (100000, 'admin', 'admin', now(), now(), null);
insert into "public"."t_role" values (100001, 'developer', 'developer', now(), now(), null);
-- ----------------------------
-- Records of t_role_menu
-- ----------------------------
-insert into "public"."t_role_menu" values (100000, 100000, 100000);
-insert into "public"."t_role_menu" values (100001, 100000, 100001);
-insert into "public"."t_role_menu" values (100002, 100000, 100002);
-insert into "public"."t_role_menu" values (100003, 100000, 100003);
-insert into "public"."t_role_menu" values (100004, 100000, 100004);
-insert into "public"."t_role_menu" values (100005, 100000, 100005);
-insert into "public"."t_role_menu" values (100006, 100000, 100006);
-insert into "public"."t_role_menu" values (100007, 100000, 100007);
-insert into "public"."t_role_menu" values (100008, 100000, 100008);
-insert into "public"."t_role_menu" values (100009, 100000, 100009);
-insert into "public"."t_role_menu" values (100010, 100000, 100010);
-insert into "public"."t_role_menu" values (100011, 100000, 100011);
-insert into "public"."t_role_menu" values (100012, 100000, 100012);
-insert into "public"."t_role_menu" values (100013, 100000, 100013);
-insert into "public"."t_role_menu" values (100014, 100000, 100014);
-insert into "public"."t_role_menu" values (100015, 100000, 100015);
-insert into "public"."t_role_menu" values (100016, 100000, 100016);
-insert into "public"."t_role_menu" values (100017, 100000, 100017);
-insert into "public"."t_role_menu" values (100018, 100000, 100018);
-insert into "public"."t_role_menu" values (100019, 100000, 100019);
-insert into "public"."t_role_menu" values (100020, 100000, 100020);
-insert into "public"."t_role_menu" values (100021, 100000, 100021);
-insert into "public"."t_role_menu" values (100022, 100000, 100022);
-insert into "public"."t_role_menu" values (100023, 100000, 100023);
-insert into "public"."t_role_menu" values (100024, 100000, 100024);
-insert into "public"."t_role_menu" values (100025, 100000, 100025);
-insert into "public"."t_role_menu" values (100026, 100000, 100026);
-insert into "public"."t_role_menu" values (100027, 100000, 100027);
-insert into "public"."t_role_menu" values (100028, 100000, 100028);
-insert into "public"."t_role_menu" values (100029, 100000, 100029);
-insert into "public"."t_role_menu" values (100030, 100000, 100030);
-insert into "public"."t_role_menu" values (100031, 100000, 100031);
-insert into "public"."t_role_menu" values (100032, 100000, 100032);
-insert into "public"."t_role_menu" values (100033, 100000, 100033);
-insert into "public"."t_role_menu" values (100034, 100000, 100034);
-insert into "public"."t_role_menu" values (100035, 100000, 100035);
-insert into "public"."t_role_menu" values (100036, 100000, 100036);
-insert into "public"."t_role_menu" values (100037, 100000, 100037);
-insert into "public"."t_role_menu" values (100038, 100000, 100038);
-insert into "public"."t_role_menu" values (100039, 100000, 100039);
-insert into "public"."t_role_menu" values (100040, 100000, 100040);
insert into "public"."t_role_menu" values (100041, 100001, 100014);
insert into "public"."t_role_menu" values (100042, 100001, 100016);
insert into "public"."t_role_menu" values (100043, 100001, 100017);
@@ -154,9 +129,7 @@ insert into "public"."t_role_menu" values (100056, 100001, 100032);
insert into "public"."t_role_menu" values (100057, 100001, 100033);
insert into "public"."t_role_menu" values (100058, 100001, 100013);
insert into "public"."t_role_menu" values (100059, 100001, 100015);
-insert into "public"."t_role_menu" values (100060, 100000, 100041);
-insert into "public"."t_role_menu" values (100061, 100000, 100042);
-insert into "public"."t_role_menu" values (100062, 100000, 100043);
+
-- ----------------------------
-- Records of t_setting
@@ -181,9 +154,9 @@ insert into "public"."t_setting" values (15, 'docker.register.namespace', null,
-- ----------------------------
-- Records of t_user
-- ----------------------------
-insert into "public"."t_user" values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, now(), now(), null, 0, null, null);
+insert into "public"."t_user" values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, '1', now(), now(), null, 0, null, null);
-- ----------------------------
-- Records of t_user_role
-- ----------------------------
-insert into "public"."t_user_role" values (100000, 100000, 100000);
+insert into "public"."t_user_role" values (100000, 100000, 100000, 100001, now(), now());
diff --git a/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql b/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql
index b42d1b5a8..8cab0867e 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql
@@ -60,6 +60,7 @@ create table `t_flame_graph` (
drop table if exists `t_flink_app`;
create table `t_flink_app` (
`id` bigint not null auto_increment,
+ `team_id` bigint not null,
`job_type` tinyint default null,
`execution_mode` tinyint default null,
`resource_from` tinyint default null,
@@ -121,7 +122,8 @@ create table `t_flink_app` (
primary key (`id`) using btree,
key `inx_state` (`state`) using btree,
key `inx_job_type` (`job_type`) using btree,
- key `inx_track` (`tracking`) using btree
+ key `inx_track` (`tracking`) using btree,
+ index `inx_team` (`team_id`) using btree
) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci;
@@ -197,6 +199,7 @@ create table `t_flink_log` (
drop table if exists `t_flink_project`;
create table `t_flink_project` (
`id` bigint not null auto_increment,
+ `team_id` bigint not null,
`name` varchar(255) collate utf8mb4_general_ci default null,
`url` varchar(1000) collate utf8mb4_general_ci default null,
`branches` varchar(1000) collate utf8mb4_general_ci default null,
@@ -211,7 +214,8 @@ create table `t_flink_project` (
`build_state` tinyint default -1,
`create_time` datetime not null default current_timestamp comment 'create time',
`modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
- primary key (`id`) using btree
+ primary key (`id`) using btree,
+ index `inx_team` (`team_id`) using btree
) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci;
@@ -301,6 +305,21 @@ create table `t_message` (
) engine=innodb auto_increment=100000 default charset=utf8mb4 collate=utf8mb4_general_ci;
+-- ----------------------------
+-- Table of t_team
+-- ----------------------------
+drop table if exists `t_team`;
+create table `t_team` (
+ `id` bigint not null auto_increment comment 'team id',
+ `team_name` varchar(50) collate utf8mb4_general_ci not null comment 'team name',
+ `description` varchar(255) collate utf8mb4_general_ci default null,
+ `create_time` datetime not null default current_timestamp comment 'create time',
+ `modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
+ primary key (`id`) using btree,
+ unique key `team_name_idx` (`team_name`) using btree
+) engine = innodb default charset = utf8mb4 collate = utf8mb4_general_ci;
+
+
-- ----------------------------
-- Table structure for t_role
-- ----------------------------
@@ -355,6 +374,7 @@ create table `t_user` (
`salt` varchar(255) collate utf8mb4_general_ci default null comment 'salt',
`password` varchar(128) collate utf8mb4_general_ci not null comment 'password',
`email` varchar(128) collate utf8mb4_general_ci default null comment 'email',
+ `user_type` int not null comment 'user type 1:admin 2:user',
`status` char(1) collate utf8mb4_general_ci not null comment 'status 0:locked 1:active',
`create_time` datetime not null default current_timestamp comment 'create time',
`modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
@@ -373,10 +393,13 @@ create table `t_user` (
drop table if exists `t_user_role`;
create table `t_user_role` (
`id` bigint not null auto_increment,
- `user_id` bigint default null comment 'user id',
- `role_id` bigint default null comment 'role id',
+ `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 not null default current_timestamp comment 'create time',
+ `modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
primary key (`id`) using btree,
- unique key `un_user_role_inx` (`user_id`,`role_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;
@@ -468,4 +491,5 @@ create table `t_alert_config` (
index `inx_alert_user` (`user_id`) using btree
) engine = innodb default charset = utf8mb4 collate = utf8mb4_general_ci;
+
set foreign_key_checks = 1;
diff --git a/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql b/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql
index 11f658a15..e13ec3687 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql
@@ -41,6 +41,7 @@ drop table if exists "public"."t_app_backup";
drop table if exists "public"."t_alert_config";
drop table if exists "public"."t_access_token";
drop table if exists "public"."t_flink_log";
+drop table if exists "public"."t_team";
-- ----------------------------
-- drop sequence if exists
@@ -64,6 +65,7 @@ drop sequence if exists "public"."streampark_t_app_backup_id_seq";
drop sequence if exists "public"."streampark_t_alert_config_id_seq";
drop sequence if exists "public"."streampark_t_access_token_id_seq";
drop sequence if exists "public"."streampark_t_flink_log_id_seq";
+drop sequence if exists "public"."streampark_t_team_id_seq";
-- ----------------------------
-- drop trigger if exists
@@ -209,6 +211,7 @@ create sequence "public"."streampark_t_flink_app_id_seq"
create table "public"."t_flink_app" (
"id" int8 not null default nextval('streampark_t_flink_app_id_seq'::regclass),
+ "team_id" int8,
"job_type" int2,
"execution_mode" int2,
"resource_from" int2,
@@ -279,6 +282,9 @@ create index "inx_state" on "public"."t_flink_app" using btree (
create index "inx_track" on "public"."t_flink_app" using btree (
"tracking" "pg_catalog"."int2_ops" asc nulls last
);
+create index "inx_team" on "public"."t_flink_app" using btree (
+ "team_id" "pg_catalog"."int8_ops" asc nulls last
+);
-- ----------------------------
-- table structure for t_flink_cluster
@@ -437,6 +443,7 @@ create sequence "public"."streampark_t_flink_project_id_seq"
create table "public"."t_flink_project" (
"id" int8 not null default nextval('streampark_t_flink_project_id_seq'::regclass),
+ "team_id" int8,
"name" varchar(255) collate "pg_catalog"."default",
"url" varchar(1000) collate "pg_catalog"."default",
"branches" varchar(1000) collate "pg_catalog"."default",
@@ -454,6 +461,9 @@ create table "public"."t_flink_project" (
)
;
alter table "public"."t_flink_project" add constraint "t_flink_project_pkey" primary key ("id");
+create index "inx_team" on "public"."t_flink_project" using btree (
+ "team_id" "pg_catalog"."int8_ops" asc nulls last
+);
-- ----------------------------
@@ -568,6 +578,31 @@ create index "inx_mes_user" on "public"."t_message" using btree (
"user_id" "pg_catalog"."int8_ops" asc nulls last
);
+
+-- ----------------------------
+-- Table of t_team
+-- ----------------------------
+
+create sequence "public"."streampark_t_team_id_seq"
+ increment 1 start 10000 cache 1 minvalue 10000 maxvalue 9223372036854775807;
+
+create table "public"."t_team" (
+ "id" int8 not null default nextval('streampark_t_team_id_seq'::regclass),
+ "team_name" varchar(50) collate "pg_catalog"."default" not null,
+ "description" varchar(255) collate "pg_catalog"."default" default null,
+ "create_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+ "modify_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
+)
+;
+comment on column "public"."t_team"."id" is 'team id';
+comment on column "public"."t_team"."team_name" is 'team name';
+comment on column "public"."t_team"."create_time" is 'creation time';
+comment on column "public"."t_team"."modify_time" is 'modify time';
+create index "un_team_name" on "public"."t_team" using btree (
+ "team_name" collate "pg_catalog"."default" "pg_catalog"."text_ops" asc nulls last
+);
+
+
-- ----------------------------
-- table structure for t_role
-- ----------------------------
@@ -639,6 +674,7 @@ create table "public"."t_user" (
"salt" varchar(255) collate "pg_catalog"."default",
"password" varchar(128) collate "pg_catalog"."default" not null,
"email" varchar(128) collate "pg_catalog"."default",
+ "user_type" int4,
"status" int2,
"create_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
"modify_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
@@ -654,6 +690,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"."status" is 'status 0:locked 1:active';
comment on column "public"."t_user"."create_time" is 'creation time';
comment on column "public"."t_user"."modify_time" is 'change time';
@@ -675,14 +712,19 @@ create sequence "public"."streampark_t_user_role_id_seq"
create table "public"."t_user_role" (
"id" int8 not null default nextval('streampark_t_user_role_id_seq'::regclass),
+ "team_id" int8,
"user_id" int8,
- "role_id" int8
+ "role_id" int8,
+ "create_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+ "modify_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
)
;
+comment on column "public"."t_user_role"."team_id" is 'team id';
comment on column "public"."t_user_role"."user_id" is 'user id';
comment on column "public"."t_user_role"."role_id" is 'role id';
alter table "public"."t_user_role" add constraint "t_user_role_pkey" primary key ("id");
create index "un_user_role_inx" on "public"."t_user_role" 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
);
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
index e8ebb1f0f..de04b08f6 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
@@ -17,6 +17,7 @@
package org.apache.streampark.console.core.controller;
+import org.apache.streampark.common.util.AssertUtils;
import org.apache.streampark.common.util.Utils;
import org.apache.streampark.common.util.YarnUtils;
import org.apache.streampark.console.base.domain.ApiDocConstant;
@@ -58,6 +59,7 @@ import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -96,6 +98,7 @@ public class ApplicationController {
@PostMapping("create")
@RequiresPermissions("app:create")
public RestResponse create(Application app) throws IOException {
+ AssertUtils.checkArgument(app.getTeamId() != null, "The teamId cannot be null");
boolean saved = applicationService.create(app);
return RestResponse.success(saved);
}
@@ -132,6 +135,9 @@ public class ApplicationController {
@PostMapping("list")
@RequiresPermissions("app:view")
public RestResponse list(Application app, RestRequest request) {
+ if (app.getTeamId() == null) {
+ return RestResponse.success(Collections.emptyList());
+ }
IPage<Application> applicationList = applicationService.page(app, request);
List<Application> appRecords = applicationList.getRecords();
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 f0f56945c..42978cc01 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
@@ -17,6 +17,7 @@
package org.apache.streampark.console.core.controller;
+import org.apache.streampark.common.util.AssertUtils;
import org.apache.streampark.console.base.domain.RestRequest;
import org.apache.streampark.console.base.domain.RestResponse;
import org.apache.streampark.console.core.entity.Project;
@@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -48,6 +50,7 @@ public class ProjectController {
@PostMapping("create")
@RequiresPermissions("project:create")
public RestResponse create(Project project) {
+ AssertUtils.checkArgument(project.getTeamId() != null, "The teamId cannot be null");
return projectService.create(project);
}
@@ -81,6 +84,9 @@ public class ProjectController {
@PostMapping("list")
@RequiresPermissions("project:view")
public RestResponse list(Project project, RestRequest restRequest) {
+ if (project.getTeamId() == null) {
+ return RestResponse.success(Collections.emptyList());
+ }
IPage<Project> page = projectService.page(project, restRequest);
return RestResponse.success().data(page);
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
index b8d281a08..7064a80e9 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
@@ -76,6 +76,8 @@ public class Application implements Serializable {
@TableId(type = IdType.AUTO)
private Long id;
+ private Long teamId;
+
/**
* 1) custom code
* 2) flink SQL
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index 3265a10b3..98c72b55c 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -54,6 +54,8 @@ public class Project implements Serializable {
@TableId(type = IdType.AUTO)
private Long id;
+ private Long teamId;
+
private String name;
private String url;
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/UserType.java
similarity index 59%
copy from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java
copy to streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/UserType.java
index de6a02272..35db3634a 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/UserType.java
@@ -15,29 +15,39 @@
* limitations under the License.
*/
-package org.apache.streampark.console.system.mapper;
+package org.apache.streampark.console.core.enums;
-import org.apache.streampark.console.system.entity.UserRole;
+import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Param;
+import java.util.Arrays;
-public interface UserRoleMapper extends BaseMapper<UserRole> {
+/**
+ * The user type.
+ */
+public enum UserType {
/**
- * delete role by user id
- *
- * @param userId user id
- * @return boolean
+ * The admin of StreamPark.
*/
- Boolean deleteByUserId(@Param("userId") Long userId);
+ ADMIN(1),
/**
- * delete user by role id
- *
- * @param roleId role id
- * @return boolean
+ * The user of StreamPark.
*/
- Boolean deleteByRoleId(@Param("roleId") Long roleId);
+ USER(2);
+
+ @EnumValue
+ private final int code;
+
+ UserType(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+ public static UserType of(Integer code) {
+ return Arrays.stream(values()).filter((x) -> x.code == code).findFirst().orElse(null);
+ }
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
index 655cf71ed..7af22dce1 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
@@ -112,6 +112,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project>
try {
Project project = getById(projectParam.getId());
AssertUtils.state(project != null);
+ AssertUtils.checkArgument(project.getTeamId().equals(projectParam.getTeamId()),
+ "TeamId cannot be changed.");
project.setName(projectParam.getName());
project.setUrl(projectParam.getUrl());
project.setBranches(projectParam.getBranches());
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
new file mode 100644
index 000000000..55dbae54a
--- /dev/null
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/TeamController.java
@@ -0,0 +1,81 @@
+/*
+ * 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.RestResponse;
+import org.apache.streampark.console.system.entity.Team;
+import org.apache.streampark.console.system.service.TeamService;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+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 javax.validation.constraints.NotBlank;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("team")
+public class TeamController {
+
+ @Autowired
+ private TeamService teamService;
+
+ @PostMapping("list")
+ public RestResponse teamList(RestRequest restRequest, Team team) {
+ IPage<Team> teamList = teamService.findTeams(team, restRequest);
+ return RestResponse.success(teamList);
+ }
+
+ @PostMapping("check/name")
+ public RestResponse checkTeamName(@NotBlank(message = "{required}") String teamName) {
+ Team result = this.teamService.findByName(teamName);
+ return RestResponse.success(result == null);
+ }
+
+ @PostMapping("post")
+ @RequiresPermissions("team:add")
+ public RestResponse addTeam(@Valid Team team) {
+ this.teamService.createTeam(team);
+ return RestResponse.success();
+ }
+
+ @DeleteMapping("delete")
+ @RequiresPermissions("team:delete")
+ public RestResponse deleteTeam(Team team) {
+ this.teamService.deleteTeam(team);
+ return RestResponse.success();
+ }
+
+ @PutMapping("update")
+ @RequiresPermissions("team:update")
+ public RestResponse updateTeam(Team team) {
+ this.teamService.updateTeam(team);
+ return RestResponse.success();
+ }
+
+}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/TeamMemberController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/TeamMemberController.java
new file mode 100644
index 000000000..c870bf49f
--- /dev/null
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/controller/TeamMemberController.java
@@ -0,0 +1,91 @@
+/*
+ * 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.RestResponse;
+import org.apache.streampark.console.system.entity.Team;
+import org.apache.streampark.console.system.entity.TeamMember;
+import org.apache.streampark.console.system.service.TeamMemberService;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+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 javax.validation.constraints.NotBlank;
+
+import java.util.List;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("member")
+public class TeamMemberController {
+
+ @Autowired
+ private TeamMemberService teamMemberService;
+
+ @PostMapping("list")
+ public RestResponse memberList(RestRequest restRequest, TeamMember teamMember) {
+ IPage<TeamMember> userList = teamMemberService.findUsers(teamMember, restRequest);
+ return RestResponse.success(userList);
+ }
+
+ @PostMapping("teams")
+ public RestResponse listTeams(Long userId) {
+ List<Team> teamList = teamMemberService.findUserTeams(userId);
+ return RestResponse.success(teamList);
+ }
+
+ @PostMapping("check/user")
+ public RestResponse checkTeamUser(@NotBlank(message = "{required}") Long teamId,
+ @NotBlank(message = "{required}") String userName) {
+ TeamMember result = this.teamMemberService.findByTeamAndUserName(teamId, userName);
+ return RestResponse.success(result == null);
+ }
+
+ @PostMapping("post")
+ @RequiresPermissions("member:add")
+ public RestResponse addUserTeamRole(@Valid TeamMember teamMember) {
+ this.teamMemberService.createTeamMember(teamMember);
+ return RestResponse.success();
+ }
+
+ @DeleteMapping("delete")
+ @RequiresPermissions("member:delete")
+ public RestResponse deleteUserTeamRole(TeamMember teamMember) {
+ this.teamMemberService.deleteTeamMember(teamMember);
+ return RestResponse.success();
+ }
+
+ @PutMapping("update")
+ @RequiresPermissions("member:update")
+ public RestResponse updateUserTeamRole(TeamMember teamMember) {
+ this.teamMemberService.updateTeamMember(teamMember);
+ return RestResponse.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 388fbd747..5edf1e3ed 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
@@ -20,6 +20,7 @@ package org.apache.streampark.console.system.controller;
import org.apache.streampark.console.base.domain.RestRequest;
import org.apache.streampark.console.base.domain.RestResponse;
import org.apache.streampark.console.base.util.ShaHashUtils;
+import org.apache.streampark.console.core.enums.UserType;
import org.apache.streampark.console.system.entity.User;
import org.apache.streampark.console.system.service.UserService;
@@ -142,4 +143,10 @@ public class UserController {
return RestResponse.success();
}
+ @PostMapping("types")
+ @RequiresPermissions("user:types")
+ public RestResponse userTypes() {
+ return RestResponse.success(UserType.values());
+ }
+
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Team.java
similarity index 67%
copy from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java
copy to streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Team.java
index 32d672e4e..bb78b4868 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Team.java
@@ -22,18 +22,35 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
+import javax.validation.constraints.Size;
+
import java.io.Serializable;
+import java.util.Date;
-@TableName("t_user_role")
@Data
-public class UserRole implements Serializable {
+@TableName("t_team")
+public class Team implements Serializable {
- private static final long serialVersionUID = -3166012934498268403L;
+ private static final long serialVersionUID = -1714476694755654924L;
@TableId(type = IdType.AUTO)
private Long id;
- private Long userId;
+ @Size(min = 4, max = 20, message = "{range}")
+ private String teamName;
+
+ private String description;
+
+ private Date createTime;
+
+ private Date modifyTime;
+
+ private transient String sortField;
+
+ private transient String sortOrder;
+
+ private transient String createTimeFrom;
+
+ private transient String createTimeTo;
- private Long roleId;
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/TeamMember.java
similarity index 75%
copy from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java
copy to streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/TeamMember.java
index 32d672e4e..6c185546f 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/TeamMember.java
@@ -23,17 +23,36 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
+import java.util.Date;
@TableName("t_user_role")
@Data
-public class UserRole implements Serializable {
+public class TeamMember implements Serializable {
private static final long serialVersionUID = -3166012934498268403L;
@TableId(type = IdType.AUTO)
private Long id;
+ private Long teamId;
+
private Long userId;
private Long roleId;
+
+ private Date createTime;
+
+ private Date modifyTime;
+
+ private transient String userName;
+
+ private transient String roleName;
+
+ private transient String sortField;
+
+ private transient String sortOrder;
+
+ 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/User.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/User.java
index 537d4e79d..4e0047602 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/User.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/User.java
@@ -17,6 +17,8 @@
package org.apache.streampark.console.system.entity;
+import org.apache.streampark.console.core.enums.UserType;
+
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -63,6 +65,8 @@ public class User implements Serializable {
@Email(message = "{email}")
private String email;
+ private UserType userType;
+
@NotBlank(message = "{required}")
private String status;
@@ -80,11 +84,6 @@ public class User implements Serializable {
private String avatar;
- @NotBlank(message = "{required}")
- private transient String roleId;
-
- private transient String roleName;
-
private transient String sortField;
private transient String sortOrder;
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMapper.java
similarity index 68%
copy from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java
copy to streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMapper.java
index de6a02272..091801b71 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMapper.java
@@ -17,27 +17,19 @@
package org.apache.streampark.console.system.mapper;
-import org.apache.streampark.console.system.entity.UserRole;
+import org.apache.streampark.console.system.entity.Team;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
-public interface UserRoleMapper extends BaseMapper<UserRole> {
-
- /**
- * delete role by user id
- *
- * @param userId user id
- * @return boolean
- */
- Boolean deleteByUserId(@Param("userId") Long userId);
-
- /**
- * delete user by role id
- *
- * @param roleId role id
- * @return boolean
- */
- Boolean deleteByRoleId(@Param("roleId") Long roleId);
+import java.util.List;
+
+public interface TeamMapper extends BaseMapper<Team> {
+
+ IPage<Team> findTeam(Page<Team> page, @Param("team") Team team);
+
+ List<Team> findUserTeams(Long userId);
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMemberMapper.java
similarity index 78%
rename from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java
rename to streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMemberMapper.java
index de6a02272..6c2bd7ed3 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/UserRoleMapper.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/mapper/TeamMemberMapper.java
@@ -17,12 +17,14 @@
package org.apache.streampark.console.system.mapper;
-import org.apache.streampark.console.system.entity.UserRole;
+import org.apache.streampark.console.system.entity.TeamMember;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
-public interface UserRoleMapper extends BaseMapper<UserRole> {
+public interface TeamMemberMapper extends BaseMapper<TeamMember> {
/**
* delete role by user id
@@ -40,4 +42,6 @@ public interface UserRoleMapper extends BaseMapper<UserRole> {
*/
Boolean deleteByRoleId(@Param("roleId") Long roleId);
+ IPage<TeamMember> findUsers(Page<TeamMember> page, @Param("teamMember") TeamMember teamMember);
+
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/ldap/LdapAuthenticator.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/ldap/LdapAuthenticator.java
index 1853ab966..69e68d56b 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/ldap/LdapAuthenticator.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/ldap/LdapAuthenticator.java
@@ -56,7 +56,6 @@ public class LdapAuthenticator extends AbstractAuthenticator {
User newUser = new User();
newUser.setCreateTime(new Date());
newUser.setUsername(userId);
- newUser.setRoleId("100001");
newUser.setNickName(userId);
newUser.setStatus("1");
newUser.setSex("1");
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamMemberService.java
similarity index 63%
copy from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java
copy to streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamMemberService.java
index 9f5a756c6..c4f057f31 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamMemberService.java
@@ -17,18 +17,32 @@
package org.apache.streampark.console.system.service;
-import org.apache.streampark.console.system.entity.UserRole;
+import org.apache.streampark.console.base.domain.RestRequest;
+import org.apache.streampark.console.system.entity.Team;
+import org.apache.streampark.console.system.entity.TeamMember;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
-public interface UserRoleService extends IService<UserRole> {
+public interface TeamMemberService extends IService<TeamMember> {
void deleteUserRolesByRoleId(String[] roleIds);
void deleteUserRolesByUserId(String[] userIds);
+ IPage<TeamMember> findUsers(TeamMember teamMember, RestRequest request);
+
+ List<Team> findUserTeams(Long userId);
+
+ TeamMember findByTeamAndUserName(Long teamId, String userName);
+
List<Long> findUserIdsByRoleId(Long roleId);
+ void createTeamMember(TeamMember teamMember);
+
+ void deleteTeamMember(TeamMember teamMember);
+
+ void updateTeamMember(TeamMember teamMember);
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamService.java
similarity index 67%
copy from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java
copy to streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamService.java
index 9f5a756c6..592095503 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/TeamService.java
@@ -17,18 +17,26 @@
package org.apache.streampark.console.system.service;
-import org.apache.streampark.console.system.entity.UserRole;
+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 UserRoleService extends IService<UserRole> {
+public interface TeamService extends IService<Team> {
- void deleteUserRolesByRoleId(String[] roleIds);
+ IPage<Team> findTeams(Team team, RestRequest request);
- void deleteUserRolesByUserId(String[] userIds);
+ Team findByName(String teamName);
- List<Long> findUserIdsByRoleId(Long roleId);
+ void createTeam(Team team);
+
+ void deleteTeam(Team team);
+
+ void updateTeam(Team team);
+
+ List<Team> findUserTeams(Long userId);
}
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 93eb814c4..ac92129d5 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
@@ -22,15 +22,18 @@ 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.TreeUtils;
+import org.apache.streampark.console.core.enums.UserType;
import org.apache.streampark.console.system.entity.Menu;
import org.apache.streampark.console.system.entity.User;
import org.apache.streampark.console.system.mapper.MenuMapper;
import org.apache.streampark.console.system.service.MenuService;
+import org.apache.streampark.console.system.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -40,19 +43,35 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
+ @Autowired
+ private UserService userService;
+
@Override
public List<Menu> findUserPermissions(String username) {
+ User user = Optional.ofNullable(userService.findByName(username))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The username [%s] not found", username)));
+ // Admin has the permission for all menus.
+ if (UserType.ADMIN.equals(user.getUserType())) {
+ return this.list();
+ }
return this.baseMapper.findUserPermissions(username);
}
@Override
public List<Menu> findUserMenus(String username) {
+ User user = Optional.ofNullable(userService.findByName(username))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The username [%s] not found", username)));
+ // Admin has the permission for all menus.
+ if (UserType.ADMIN.equals(user.getUserType())) {
+ return this.list(new LambdaQueryWrapper<Menu>().eq(Menu::getType, "0"));
+ }
return this.baseMapper.findUserMenus(username);
}
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
index 3a12285e1..5b9df32b7 100644
--- 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
@@ -26,7 +26,7 @@ import org.apache.streampark.console.system.mapper.RoleMapper;
import org.apache.streampark.console.system.mapper.RoleMenuMapper;
import org.apache.streampark.console.system.service.RoleMenuServie;
import org.apache.streampark.console.system.service.RoleService;
-import org.apache.streampark.console.system.service.UserRoleService;
+import org.apache.streampark.console.system.service.TeamMemberService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -56,7 +56,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
private RoleMenuMapper roleMenuMapper;
@Autowired
- private UserRoleService userRoleService;
+ private TeamMemberService teamMemberService;
@Autowired
private RoleMenuServie roleMenuService;
@@ -98,7 +98,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
public void deleteRole(Long roleId) {
Role role = Optional.ofNullable(this.getById(roleId))
.orElseThrow(() -> new IllegalArgumentException(String.format("Role id [%s] not found", roleId)));
- List<Long> userIdsByRoleId = userRoleService.findUserIdsByRoleId(roleId);
+ List<Long> userIdsByRoleId = teamMemberService.findUserIdsByRoleId(roleId);
AssertUtils.isTrue(userIdsByRoleId == null || userIdsByRoleId.isEmpty(),
String.format("There are some users are bound to role %s , please unbind it first.", role.getRoleName()));
this.removeById(roleId);
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamMemberServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamMemberServiceImpl.java
new file mode 100644
index 000000000..7ef26efef
--- /dev/null
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamMemberServiceImpl.java
@@ -0,0 +1,145 @@
+/*
+ * 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.system.entity.Team;
+import org.apache.streampark.console.system.entity.TeamMember;
+import org.apache.streampark.console.system.entity.User;
+import org.apache.streampark.console.system.mapper.TeamMemberMapper;
+import org.apache.streampark.console.system.service.RoleService;
+import org.apache.streampark.console.system.service.TeamMemberService;
+import org.apache.streampark.console.system.service.TeamService;
+import org.apache.streampark.console.system.service.UserService;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+@Service
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
+public class TeamMemberServiceImpl extends ServiceImpl<TeamMemberMapper, TeamMember>
+ implements TeamMemberService {
+
+ @Autowired
+ private UserService userService;
+
+ @Autowired
+ private RoleService roleService;
+
+ @Autowired
+ private TeamService teamService;
+
+ @Override
+ @Transactional
+ public void deleteUserRolesByRoleId(String[] roleIds) {
+ Arrays.stream(roleIds).forEach(id -> baseMapper.deleteByRoleId(Long.valueOf(id)));
+ }
+
+ @Override
+ @Transactional
+ public void deleteUserRolesByUserId(String[] userIds) {
+ Arrays.stream(userIds).forEach(id -> baseMapper.deleteByUserId(Long.valueOf(id)));
+ }
+
+ @Override
+ public IPage<TeamMember> findUsers(TeamMember teamMember, RestRequest request) {
+ AssertUtils.isTrue(teamMember.getTeamId() != null, "The team id is required.");
+ Page<TeamMember> page = new Page<>();
+ page.setCurrent(request.getPageNum());
+ page.setSize(request.getPageSize());
+ return baseMapper.findUsers(page, teamMember);
+ }
+
+ @Override
+ public List<Team> findUserTeams(Long userId) {
+ return teamService.findUserTeams(userId);
+ }
+
+ @Override
+ public TeamMember findByTeamAndUserName(Long teamId, String userName) {
+ User user = userService.findByName(userName);
+ if (user == null) {
+ return null;
+ }
+ return findByTeamAndUserId(teamId, user.getUserId());
+ }
+
+ private TeamMember findByTeamAndUserId(Long teamId, Long userId) {
+ return baseMapper.selectOne(
+ new LambdaQueryWrapper<TeamMember>().eq(TeamMember::getTeamId, teamId)
+ .eq(TeamMember::getUserId, userId));
+ }
+
+ @Override
+ public List<Long> findUserIdsByRoleId(Long roleId) {
+ List<TeamMember> list =
+ baseMapper.selectList(
+ new LambdaQueryWrapper<TeamMember>().eq(TeamMember::getRoleId, roleId));
+ return list.stream()
+ .map(TeamMember::getUserId)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public void createTeamMember(TeamMember teamMember) {
+ User user = Optional.ofNullable(userService.findByName(teamMember.getUserName()))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The username [%s] not found", teamMember.getUserName())));
+ Optional.ofNullable(roleService.getById(teamMember.getRoleId()))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The roleId [%s] not found", teamMember.getRoleId())));
+ Team team = Optional.ofNullable(teamService.getById(teamMember.getTeamId()))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The teamId [%s] not found", teamMember.getTeamId())));
+ AssertUtils.isTrue(findByTeamAndUserId(teamMember.getTeamId(), user.getUserId()) == null,
+ String.format("The user [%s] has been added the team [%s], please don't add it again.", teamMember.getUserName(), team.getTeamName()));
+
+ teamMember.setId(null);
+ teamMember.setUserId(user.getUserId());
+ teamMember.setCreateTime(new Date());
+ teamMember.setModifyTime(team.getCreateTime());
+ this.save(teamMember);
+ }
+
+ @Override
+ public void deleteTeamMember(TeamMember teamMember) {
+ this.removeById(teamMember);
+ }
+
+ @Override
+ public void updateTeamMember(TeamMember teamMember) {
+ TeamMember oldTeamMember = Optional.ofNullable(this.getById(teamMember.getId()))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The mapping [id=%s] not found", teamMember.getId())));
+ AssertUtils.isTrue(oldTeamMember.getTeamId().equals(teamMember.getTeamId()), "Team id cannot be changed.");
+ AssertUtils.isTrue(oldTeamMember.getUserId().equals(teamMember.getUserId()), "User id cannot be changed.");
+ Optional.ofNullable(roleService.getById(teamMember.getRoleId()))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The roleId [%s] not found", teamMember.getRoleId())));
+ oldTeamMember.setRoleId(teamMember.getRoleId());
+ updateById(oldTeamMember);
+ }
+}
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
new file mode 100644
index 000000000..46ccc8c94
--- /dev/null
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java
@@ -0,0 +1,102 @@
+/*
+ * 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.core.enums.UserType;
+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.TeamService;
+import org.apache.streampark.console.system.service.UserService;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.Date;
+import java.util.List;
+import java.util.Optional;
+
+@Slf4j
+@Service
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
+public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements TeamService {
+
+ @Autowired
+ private UserService userService;
+
+ @Override
+ public IPage<Team> findTeams(Team team, RestRequest request) {
+ Page<Team> page = new Page<>();
+ page.setCurrent(request.getPageNum());
+ page.setSize(request.getPageSize());
+ return this.baseMapper.findTeam(page, team);
+ }
+
+ @Override
+ public Team findByName(String teamName) {
+ return baseMapper.selectOne(new LambdaQueryWrapper<Team>().eq(Team::getTeamName, teamName));
+ }
+
+ @Override
+ public void createTeam(Team team) {
+ Team existedTeam = findByName(team.getTeamName());
+ if (existedTeam != null) {
+ throw new IllegalArgumentException(String.format("Team name [%s] was found, please rename and try again.", team.getTeamName()));
+ }
+ team.setId(null);
+ team.setCreateTime(new Date());
+ team.setModifyTime(team.getCreateTime());
+ this.save(team);
+ }
+
+ @Override
+ public void deleteTeam(Team team) {
+ // TODO 查询 app 和 project,如果还有 app 或 project 没有删除,则 team 不能被删除。
+ this.removeById(team);
+ }
+
+ @Override
+ public void updateTeam(Team team) {
+ Team oldTeam = Optional.ofNullable(this.getById(team))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("Team id [id=%s] not found", team.getId())));
+ AssertUtils.isTrue(oldTeam.getTeamName().equals(team.getTeamName()), "Team name cannot be changed.");
+ oldTeam.setDescription(team.getDescription());
+ oldTeam.setModifyTime(new Date());
+ updateById(oldTeam);
+ }
+
+ @Override
+ public List<Team> findUserTeams(Long userId) {
+ User user = Optional.ofNullable(userService.getById(userId))
+ .orElseThrow(() -> new IllegalArgumentException(String.format("The userId [%s] not found", userId)));
+ // Admin has the permission for all teams.
+ if (UserType.ADMIN.equals(user.getUserType())) {
+ return this.list();
+ }
+ return baseMapper.findUserTeams(userId);
+ }
+}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserRoleServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserRoleServiceImpl.java
deleted file mode 100644
index ca965d0b3..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserRoleServiceImpl.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.service.impl;
-
-import org.apache.streampark.console.system.entity.UserRole;
-import org.apache.streampark.console.system.mapper.UserRoleMapper;
-import org.apache.streampark.console.system.service.UserRoleService;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-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;
-import java.util.stream.Collectors;
-
-@Service
-@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
-public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole>
- implements UserRoleService {
-
- @Override
- @Transactional
- public void deleteUserRolesByRoleId(String[] roleIds) {
- Arrays.stream(roleIds).forEach(id -> baseMapper.deleteByRoleId(Long.valueOf(id)));
- }
-
- @Override
- @Transactional
- public void deleteUserRolesByUserId(String[] userIds) {
- Arrays.stream(userIds).forEach(id -> baseMapper.deleteByUserId(Long.valueOf(id)));
- }
-
- @Override
- public List<Long> findUserIdsByRoleId(Long roleId) {
- List<UserRole> list =
- baseMapper.selectList(
- new LambdaQueryWrapper<UserRole>().eq(UserRole::getRoleId, roleId));
- return list.stream()
- .map(UserRole::getUserId)
- .collect(Collectors.toList());
- }
-}
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 2c410913f..1aa814edf 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
@@ -21,18 +21,16 @@ import org.apache.streampark.common.util.AssertUtils;
import org.apache.streampark.console.base.domain.RestRequest;
import org.apache.streampark.console.base.util.ShaHashUtils;
import org.apache.streampark.console.system.entity.Menu;
-import org.apache.streampark.console.system.entity.Role;
+import org.apache.streampark.console.system.entity.TeamMember;
import org.apache.streampark.console.system.entity.User;
-import org.apache.streampark.console.system.entity.UserRole;
import org.apache.streampark.console.system.mapper.UserMapper;
import org.apache.streampark.console.system.service.MenuService;
import org.apache.streampark.console.system.service.RoleService;
-import org.apache.streampark.console.system.service.UserRoleService;
+import org.apache.streampark.console.system.service.TeamMemberService;
import org.apache.streampark.console.system.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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;
@@ -54,7 +52,7 @@ import java.util.stream.Collectors;
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Autowired
- private UserRoleService userRoleService;
+ private TeamMemberService teamMemberService;
@Autowired
private RoleService roleService;
@@ -74,17 +72,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
page.setSize(request.getPageSize());
IPage<User> resPage = this.baseMapper.findUserDetail(page, user);
- if (resPage != null && !resPage.getRecords().isEmpty()) {
- List<User> users = resPage.getRecords();
- users.forEach(u -> {
- List<Role> roleList = roleService.findUserRole(u.getUsername());
- String roleIds = roleList.stream().map((iter) -> iter.getRoleId().toString()).collect(Collectors.joining(","));
- String roleNames = roleList.stream().map(Role::getRoleName).collect(Collectors.joining(","));
- u.setRoleId(roleIds);
- u.setRoleName(roleNames);
- });
- resPage.setRecords(users);
- }
AssertUtils.state(resPage != null);
if (resPage.getTotal() == 0) {
resPage.setRecords(Collections.emptyList());
@@ -110,8 +97,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
user.setSalt(salt);
user.setPassword(password);
save(user);
- String[] roles = user.getRoleId().split(StringPool.COMMA);
- setUserRoles(user, roles);
}
@Override
@@ -120,9 +105,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
user.setPassword(null);
user.setModifyTime(new Date());
updateById(user);
- userRoleService.deleteUserRolesByUserId(new String[]{user.getUserId().toString()});
- String[] roles = user.getRoleId().split(StringPool.COMMA);
- setUserRoles(user, roles);
}
@Override
@@ -130,7 +112,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
public void deleteUsers(String[] userIds) throws Exception {
List<String> list = Arrays.asList(userIds);
removeByIds(list);
- this.userRoleService.deleteUserRolesByUserId(userIds);
+ this.teamMemberService.deleteUserRolesByUserId(userIds);
}
@Override
@@ -190,7 +172,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
users.forEach(u -> {
u.setPassword(null);
u.setSalt(null);
- u.setRoleId(null);
});
}
return users;
@@ -198,10 +179,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
private void setUserRoles(User user, String[] roles) {
Arrays.stream(roles).forEach(roleId -> {
- UserRole ur = new UserRole();
+ TeamMember ur = new TeamMember();
ur.setUserId(user.getUserId());
ur.setRoleId(Long.valueOf(roleId));
- this.userRoleService.save(ur);
+ this.teamMemberService.save(ur);
});
}
}
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 d7b97480d..94c3dbdcd 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
@@ -15,10 +15,17 @@
* limitations under the License.
*/
+-- ----------------------------
+-- Records of t_team
+-- ----------------------------
+insert into `t_team` values (100000, 'default', 'The default team', now(), now());
+insert into `t_team` values (100001, 'test_team1', 'The test team1', now(), now());
+
+
-- ----------------------------
-- Records of t_flink_app
-- ----------------------------
-insert into `t_flink_app` values (100000, 2, 4, null, null, 'Flink SQL Demo', null, null, null, null, null, null , null, 100000, null, 1, null, null, null, null, null, null, null, '0', 0, null, null, null, null, null, null, 'Flink SQL Demo', 0, null, 0, null, null, null, null, null, null, 0, 0, now(), now(), null, 1, 1, null, null, null, null, null, null, 0, null, null, null, 'streampark,test');
+insert into `t_flink_app` values (100000, 100000, 2, 4, null, null, 'Flink SQL Demo', null, null, null, null, null, null , null, 100000, null, 1, null, null, null, null, null, null, null, '0', 0, null, null, null, null, null, null, 'Flink SQL Demo', 0, null, 0, null, null, null, null, null, null, 0, 0, now(), now(), null, 1, 1, null, null, null, null, null, null, 0, null, null, null, 'streampark,test');
-- ----------------------------
-- Records of t_flink_effective
@@ -28,7 +35,7 @@ insert into `t_flink_effective` values (100000, 100000, 2, 100000, now());
-- ----------------------------
-- Records of t_flink_project
-- ----------------------------
-insert into `t_flink_project` values (100000, 'streampark-quickstart', 'https://github.com/streamxhub/streampark-quickstart.git', 'main', null, null, null, null, 1, 1, null, 'streampark-quickstart', 1, now(), now());
+insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', 'https://github.com/streamxhub/streampark-quickstart.git', 'main', null, null, null, null, 1, 1, null, 'streampark-quickstart', 1, now(), now());
-- ----------------------------
-- Records of t_flink_sql
@@ -82,58 +89,26 @@ insert into `t_menu` values (100040, 100038, 'delete', null, null, 'token:delete
insert into `t_menu` values (100041, 100013, 'Add Cluster', '/flink/setting/add_cluster', 'flink/setting/AddCluster', 'cluster:create', '', '0', 0, null, now(), now());
insert into `t_menu` values (100042, 100013, 'Edit Cluster', '/flink/setting/edit_cluster', 'flink/setting/EditCluster', 'cluster:update', '', '0', 0, null, now(), now());
insert into `t_menu` values (100043, 100015, 'copy', null, null, 'app:copy', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100044, 100000, 'Team Management', '/system/team', 'system/team/Team', 'team:view', 'team', '0', 1, 2, now(), now());
+insert into `t_menu` values (100045, 100044, 'add', null, null, 'team:add', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100046, 100044, 'update', null, null, 'team:update', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100047, 100044, 'delete', null, null, 'team:delete', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100048, 100000, 'Member Management', '/system/member', 'system/member/Member', 'member:view', 'usergroup-add', '0', 1, 2, now(), now());
+insert into `t_menu` values (100049, 100048, 'add', null, null, 'member:add', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100050, 100048, 'update', null, null, 'member:update', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100051, 100048, 'delete', null, null, 'member:delete', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100052, 100048, 'role view', null, null, 'role:view', null, '1', 1, null, now(), now());
+insert into `t_menu` values (100053, 100001, 'types', null, null, 'user:types', null, '1', 1, null, now(), now());
-- ----------------------------
-- Records of t_role
-- ----------------------------
-insert into `t_role` values (100000, 'admin', 'admin', now(), now(), null);
insert into `t_role` values (100001, 'developer', 'developer', now(), now(), null);
-- ----------------------------
-- Records of t_role_menu
-- ----------------------------
-insert into `t_role_menu` values (100000, 100000, 100000);
-insert into `t_role_menu` values (100001, 100000, 100001);
-insert into `t_role_menu` values (100002, 100000, 100002);
-insert into `t_role_menu` values (100003, 100000, 100003);
-insert into `t_role_menu` values (100004, 100000, 100004);
-insert into `t_role_menu` values (100005, 100000, 100005);
-insert into `t_role_menu` values (100006, 100000, 100006);
-insert into `t_role_menu` values (100007, 100000, 100007);
-insert into `t_role_menu` values (100008, 100000, 100008);
-insert into `t_role_menu` values (100009, 100000, 100009);
-insert into `t_role_menu` values (100010, 100000, 100010);
-insert into `t_role_menu` values (100011, 100000, 100011);
-insert into `t_role_menu` values (100012, 100000, 100012);
-insert into `t_role_menu` values (100013, 100000, 100013);
-insert into `t_role_menu` values (100014, 100000, 100014);
-insert into `t_role_menu` values (100015, 100000, 100015);
-insert into `t_role_menu` values (100016, 100000, 100016);
-insert into `t_role_menu` values (100017, 100000, 100017);
-insert into `t_role_menu` values (100018, 100000, 100018);
-insert into `t_role_menu` values (100019, 100000, 100019);
-insert into `t_role_menu` values (100020, 100000, 100020);
-insert into `t_role_menu` values (100021, 100000, 100021);
-insert into `t_role_menu` values (100022, 100000, 100022);
-insert into `t_role_menu` values (100023, 100000, 100023);
-insert into `t_role_menu` values (100024, 100000, 100024);
-insert into `t_role_menu` values (100025, 100000, 100025);
-insert into `t_role_menu` values (100026, 100000, 100026);
-insert into `t_role_menu` values (100027, 100000, 100027);
-insert into `t_role_menu` values (100028, 100000, 100028);
-insert into `t_role_menu` values (100029, 100000, 100029);
-insert into `t_role_menu` values (100030, 100000, 100030);
-insert into `t_role_menu` values (100031, 100000, 100031);
-insert into `t_role_menu` values (100032, 100000, 100032);
-insert into `t_role_menu` values (100033, 100000, 100033);
-insert into `t_role_menu` values (100034, 100000, 100034);
-insert into `t_role_menu` values (100035, 100000, 100035);
-insert into `t_role_menu` values (100036, 100000, 100036);
-insert into `t_role_menu` values (100037, 100000, 100037);
-insert into `t_role_menu` values (100038, 100000, 100038);
-insert into `t_role_menu` values (100039, 100000, 100039);
-insert into `t_role_menu` values (100040, 100000, 100040);
insert into `t_role_menu` values (100041, 100001, 100014);
insert into `t_role_menu` values (100042, 100001, 100016);
insert into `t_role_menu` values (100043, 100001, 100017);
@@ -153,9 +128,6 @@ insert into `t_role_menu` values (100056, 100001, 100032);
insert into `t_role_menu` values (100057, 100001, 100033);
insert into `t_role_menu` values (100058, 100001, 100013);
insert into `t_role_menu` values (100059, 100001, 100015);
-insert into `t_role_menu` values (100060, 100000, 100041);
-insert into `t_role_menu` values (100061, 100000, 100042);
-insert into `t_role_menu` values (100062, 100000, 100043);
-- ----------------------------
-- Records of t_setting
@@ -179,9 +151,15 @@ insert into `t_setting` values (15, 'docker.register.namespace', null, 'Namespac
-- ----------------------------
-- Records of t_user
-- ----------------------------
-insert into `t_user` values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, '1', now(), now(),null,'0',null,null );
+insert into `t_user` values (100000, 'admin', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 1, '1', now(), now(),null,'0',null,null );
+insert into `t_user` values (100001, 'test_user1', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 2, '1', now(), now(),null,'0',null,null );
+insert into `t_user` values (100002, 'test_user2', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 2, '1', now(), now(),null,'0',null,null );
+insert into `t_user` values (100003, 'test_user3', '', 'rh8b1ojwog777yrg0daesf04gk', '2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f', null, 2, '1', now(), now(),null,'0',null,null );
-- ----------------------------
-- Records of t_user_role
-- ----------------------------
-insert into `t_user_role` values (100000, 100000, 100000);
+insert into `t_user_role` values (100000, 100000, 100001, 100001, now(), now()); -- test_user1 is the developer of the default team
+insert into `t_user_role` values (100001, 100001, 100001, 100001, now(), now()); -- test_user1 is the developer of the test_team1 team
+insert into `t_user_role` values (100002, 100000, 100002, 100001, now(), now()); -- test_user2 is the developer of the test_team1 team
+insert into `t_user_role` values (100003, 100001, 100003, 100001, now(), now()); -- test_user3 is the developer of the test_team1 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 0637edaf9..ebaad6fd2 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
@@ -48,6 +48,7 @@ create table if not exists `t_flame_graph` (
-- ----------------------------
create table if not exists `t_flink_app` (
`id` bigint generated by default as identity not null,
+ `team_id` bigint not null,
`job_type` tinyint default null,
`execution_mode` tinyint default null,
`resource_from` tinyint default null,
@@ -173,6 +174,7 @@ create table if not exists `t_flink_log` (
-- ----------------------------
create table if not exists `t_flink_project` (
`id` bigint generated by default as identity not null,
+ `team_id` bigint not null,
`name` varchar(255) default null,
`url` varchar(1000) default null,
`branches` varchar(1000) default null,
@@ -267,6 +269,19 @@ create table if not exists `t_message` (
primary key(`id`)
);
+-- ----------------------------
+-- Table of t_team
+-- ----------------------------
+create table if not exists `t_team` (
+ `id` bigint generated by default as identity not null comment 'team id',
+ `team_name` varchar(50) not null comment 'team name',
+ `description` varchar(255) default null,
+ `create_time` datetime not null default current_timestamp comment 'create time',
+ `modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
+ primary key (`id`),
+ unique (`team_name`)
+);
+
-- ----------------------------
-- Table structure for t_role
-- ----------------------------
@@ -313,6 +328,7 @@ create table if not exists `t_user` (
`salt` varchar(255) default null comment 'salt',
`password` varchar(128) not null comment 'password',
`email` varchar(128) default null comment 'email',
+ `user_type` int not null comment 'user type 1:admin 2:user',
`status` char(1) not null comment 'status 0:locked 1:active',
`create_time` datetime not null default current_timestamp comment 'create time',
`modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
@@ -329,10 +345,13 @@ create table if not exists `t_user` (
-- ----------------------------
create table if not exists `t_user_role` (
`id` bigint generated by default as identity not null,
- `user_id` bigint default null comment 'user id',
- `role_id` bigint default null comment 'role id',
+ `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 not null default current_timestamp comment 'create time',
+ `modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
primary key(`id`),
- unique (`user_id`,`role_id`)
+ unique (`team_id`, `user_id`,`role_id`)
);
-- ----------------------------
diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml
index b73ef2a5b..aa81b9872 100644
--- a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml
+++ b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml
@@ -21,6 +21,7 @@
<mapper namespace="org.apache.streampark.console.core.mapper.ApplicationMapper">
<resultMap id="BaseResultMap" type="org.apache.streampark.console.core.entity.Application">
<id column="id" jdbcType="BIGINT" property="id"/>
+ <result column="team_id" jdbcType="BIGINT" property="teamId"/>
<result column="project_id" jdbcType="BIGINT" property="projectId"/>
<result column="module" jdbcType="VARCHAR" property="module"/>
<result column="args" jdbcType="LONGVARCHAR" property="args"/>
@@ -94,6 +95,7 @@
left join t_flink_project p
on t.project_id = p.id
<where>
+ t.team_id = #{application.teamId}
<if test="application.jobType != null and application.jobType != ''">
and t.job_type = #{application.jobType}
</if>
diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
index 3924c87fb..caf238727 100644
--- a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
+++ b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
@@ -22,6 +22,7 @@
<resultMap id="BaseResultMap" type="org.apache.streampark.console.core.entity.Project">
<id column="id" jdbcType="INTEGER" property="id"/>
+ <result column="team_id" jdbcType="BIGINT" property="teamId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="url" jdbcType="VARCHAR" property="url"/>
<result column="repository" jdbcType="INTEGER" property="repository"/>
@@ -41,6 +42,7 @@
<select id="page" resultType="project" parameterType="project">
select * from t_flink_project t
<where>
+ t.team_id = #{project.teamId}
<if test="project.name != null and project.name != ''">
and t.name like '%${project.name}%'
</if>
diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMapper.xml
similarity index 51%
copy from streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
copy to streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMapper.xml
index 3924c87fb..b455e75d5 100644
--- a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
+++ b/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMapper.xml
@@ -18,36 +18,37 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.streampark.console.core.mapper.ProjectMapper">
-
- <resultMap id="BaseResultMap" type="org.apache.streampark.console.core.entity.Project">
- <id column="id" jdbcType="INTEGER" property="id"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="url" jdbcType="VARCHAR" property="url"/>
- <result column="repository" jdbcType="INTEGER" property="repository"/>
- <result column="branches" jdbcType="VARCHAR" property="branches"/>
- <result column="user_name" jdbcType="VARCHAR" property="userName"/>
- <result column="password" jdbcType="VARCHAR" property="password"/>
- <result column="pom" jdbcType="VARCHAR" property="pom"/>
- <result column="build_args" jdbcType="VARCHAR" property="buildArgs"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
+<mapper namespace="org.apache.streampark.console.system.mapper.TeamMapper">
+ <resultMap id="BaseResultMap" type="org.apache.streampark.console.system.entity.Team">
+ <id column="id" jdbcType="BIGINT" property="id"/>
+ <result column="team_name" jdbcType="VARCHAR" property="teamName"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
- <result column="last_build" jdbcType="TIMESTAMP" property="lastBuild"/>
- <result column="build_state" jdbcType="INTEGER" property="buildState"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
</resultMap>
- <select id="page" resultType="project" parameterType="project">
- select * from t_flink_project t
+ <select id="findTeam" resultType="team" parameterType="team">
+ select * from t_team
<where>
- <if test="project.name != null and project.name != ''">
- and t.name like '%${project.name}%'
+ <if test="team.teamName != null and team.teamName != ''">
+ and team_name like '%${team.teamName}%'
+ </if>
+ <if test="team.createTimeFrom != null and team.createTimeFrom !=''">
+ and create_time > #{team.createTimeFrom}
</if>
- <if test="project.buildState != null">
- and t.build_state = #{project.buildState}
+ <if test="team.createTimeTo!= null and team.createTimeTo !=''">
+ and create_time < #{team.createTimeTo}
</if>
</where>
+ <if test="team.sortField != null and team.sortField != ''">
+ order by ${team.sortField} ${team.sortOrder}
+ </if>
</select>
+ <select id="findUserTeams" resultType="team" parameterType="team">
+ select t.* from t_team t
+ join t_user_role ur
+ on t.id = ur.team_id
+ where ur.user_id = #{userId}
+ </select>
</mapper>
diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMemberMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMemberMapper.xml
new file mode 100644
index 000000000..62219d39d
--- /dev/null
+++ b/streampark-console/streampark-console-service/src/main/resources/mapper/system/TeamMemberMapper.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.streampark.console.system.mapper.TeamMemberMapper">
+
+ <resultMap id="BaseResultMap" type="org.apache.streampark.console.system.entity.TeamMember">
+ <id column="id" jdbcType="BIGINT" property="id"/>
+ <result column="team_id" jdbcType="BIGINT" property="teamId"/>
+ <result column="user_id" jdbcType="BIGINT" property="userId"/>
+ <result column="role_id" jdbcType="BIGINT" property="roleId"/>
+ <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+ <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
+ </resultMap>
+
+ <delete id="deleteByUserId">
+ delete
+ from t_user_role
+ where user_id = #{userId}
+ </delete>
+
+ <delete id="deleteByRoleId">
+ delete
+ from t_user_role
+ where role_id = #{roleId}
+ </delete>
+
+ <select id="findUsers" resultType="teamMember" parameterType="teamMember">
+ select tur.*,
+ u.username,
+ r.role_name
+ from t_user_role tur
+ join t_user u
+ on u.user_id = tur.user_id
+ join t_role r
+ on r.role_id = tur.role_id
+ <where>
+ tur.team_id = ${teamMember.teamId}
+ <if test="teamMember.userName != null and teamMember.userName != ''">
+ and u.username like '%${teamMember.userName}%'
+ </if>
+ <if test="teamMember.roleName != null and teamMember.roleName != ''">
+ and r.role_name = '${teamMember.roleName}'
+ </if>
+ <if test="teamMember.createTimeFrom != null and teamMember.createTimeFrom !=''">
+ and tur.create_time > #{teamMember.createTimeFrom}
+ </if>
+ <if test="teamMember.createTimeTo!= null and teamMember.createTimeTo !=''">
+ and tur.create_time < #{teamMember.createTimeTo}
+ </if>
+ </where>
+ <if test="teamMember.sortField != null and teamMember.sortField != ''">
+ order by ${teamMember.sortField} ${teamMember.sortOrder}
+ </if>
+ </select>
+
+</mapper>
diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/system/UserRoleMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/system/UserRoleMapper.xml
deleted file mode 100644
index 8bc06c9eb..000000000
--- a/streampark-console/streampark-console-service/src/main/resources/mapper/system/UserRoleMapper.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.apache.streampark.console.system.mapper.UserRoleMapper">
-
- <resultMap id="BaseResultMap" type="org.apache.streampark.console.system.entity.UserRole">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <id column="user_id" property="userId"/>
- <result column="role_id" property="roleId"/>
- </resultMap>
-
- <delete id="deleteByUserId">
- delete
- from t_user_role
- where user_id = #{userId}
- </delete>
-
- <delete id="deleteByRoleId">
- delete
- from t_user_role
- where role_id = #{roleId}
- </delete>
-
- <select id="selectRoleIdList" resultType="java.lang.Long">
- select role_id
- from t_user_role where user_id = #{userId}
- </select>
-
-</mapper>
diff --git a/streampark-console/streampark-console-webapp/src/api/index.js b/streampark-console/streampark-console-webapp/src/api/index.js
index e6c50f5d9..0b287095b 100644
--- a/streampark-console/streampark-console-webapp/src/api/index.js
+++ b/streampark-console/streampark-console-webapp/src/api/index.js
@@ -158,6 +158,7 @@ export default {
},
User: {
LIST: '/user/list',
+ TYPES: '/user/types',
UPDATE: '/user/update',
PASSWORD: '/user/password',
RESET: '/user/password/reset',
@@ -184,6 +185,21 @@ export default {
DELETE: '/role/delete',
MENU: '/role/menu'
},
+ Team: {
+ POST: '/team/post',
+ UPDATE: '/team/update',
+ LIST: '/team/list',
+ CHECK_NAME: '/team/check/name',
+ DELETE: '/team/delete'
+ },
+ Member: {
+ POST: '/member/post',
+ UPDATE: '/member/update',
+ LIST: '/member/list',
+ TEAMS: '/member/teams',
+ CHECK_NAME: '/member/check/name',
+ DELETE: '/member/delete'
+ },
Menu: {
LIST: '/menu/list',
DELETE: '/menu/delete',
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java b/streampark-console/streampark-console-webapp/src/api/member.js
similarity index 57%
rename from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java
rename to streampark-console/streampark-console-webapp/src/api/member.js
index 32d672e4e..8e19f1ac3 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/UserRole.java
+++ b/streampark-console/streampark-console-webapp/src/api/member.js
@@ -15,25 +15,29 @@
* limitations under the License.
*/
-package org.apache.streampark.console.system.entity;
+import api from './index'
+import http from '@/utils/request'
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import java.io.Serializable;
+export function post (queryParam) {
+ return http.post(api.Member.POST, queryParam)
+}
-@TableName("t_user_role")
-@Data
-public class UserRole implements Serializable {
+export function update (queryParam) {
+ return http.put(api.Member.UPDATE, queryParam)
+}
- private static final long serialVersionUID = -3166012934498268403L;
+export function list (queryParam) {
+ return http.post(api.Member.LIST, queryParam)
+}
- @TableId(type = IdType.AUTO)
- private Long id;
+export function teams (queryParam) {
+ return http.post(api.Member.TEAMS, queryParam)
+}
- private Long userId;
+export function checkName (queryParam) {
+ return http.post(api.Member.CHECK_NAME, queryParam)
+}
- private Long roleId;
+export function remove (queryParam) {
+ return http.delete(api.Member.DELETE, queryParam)
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java b/streampark-console/streampark-console-webapp/src/api/team.js
similarity index 61%
rename from streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java
rename to streampark-console/streampark-console-webapp/src/api/team.js
index 9f5a756c6..518b7f16b 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/UserRoleService.java
+++ b/streampark-console/streampark-console-webapp/src/api/team.js
@@ -15,20 +15,25 @@
* limitations under the License.
*/
-package org.apache.streampark.console.system.service;
+import api from './index'
+import http from '@/utils/request'
-import org.apache.streampark.console.system.entity.UserRole;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import java.util.List;
-
-public interface UserRoleService extends IService<UserRole> {
+export function post (queryParam) {
+ return http.post(api.Team.POST, queryParam)
+}
- void deleteUserRolesByRoleId(String[] roleIds);
+export function update (queryParam) {
+ return http.put(api.Team.UPDATE, queryParam)
+}
- void deleteUserRolesByUserId(String[] userIds);
+export function list (queryParam) {
+ return http.post(api.Team.LIST, queryParam)
+}
- List<Long> findUserIdsByRoleId(Long roleId);
+export function checkName (queryParam) {
+ return http.post(api.Team.CHECK_NAME, queryParam)
+}
+export function remove (queryParam) {
+ return http.delete(api.Team.DELETE, queryParam)
}
diff --git a/streampark-console/streampark-console-webapp/src/api/user.js b/streampark-console/streampark-console-webapp/src/api/user.js
index 7c8be08eb..14b61bc48 100644
--- a/streampark-console/streampark-console-webapp/src/api/user.js
+++ b/streampark-console/streampark-console-webapp/src/api/user.js
@@ -57,3 +57,7 @@ export function getRouter (queryParam) {
export function deleteUser (queryParam) {
return http.delete(api.User.DELETE, queryParam)
}
+
+export function types() {
+ return http.post(api.User.TYPES, {})
+}
diff --git a/streampark-console/streampark-console-webapp/src/components/tools/UserMenu.vue b/streampark-console/streampark-console-webapp/src/components/tools/UserMenu.vue
index bef5529e5..7a412ae79 100644
--- a/streampark-console/streampark-console-webapp/src/components/tools/UserMenu.vue
+++ b/streampark-console/streampark-console-webapp/src/components/tools/UserMenu.vue
@@ -67,6 +67,21 @@
<notice class="action"/>
+ <a> Team : </a>
+
+ <a-select
+ mode="single"
+ :allow-clear="false"
+ style="width: 200px"
+ @change="handleChangeTeam"
+ v-decorator="['teamId']">
+ <a-select-option
+ v-for="t in teamList"
+ :key="t.id">
+ {{ t.teamName }}
+ </a-select-option>
+ </a-select>
+
<a-dropdown>
<a class="ant-dropdown-link username" @click="e => e.preventDefault()">
{{ userName }} <a-icon type="caret-down" />
@@ -168,9 +183,10 @@ import SvgIcon from '@/components/SvgIcon'
import { mapState, mapActions } from 'vuex'
import { password } from '@api/user'
+import {teams} from '@/api/member'
import themeUtil from '@/utils/themeUtil'
import storage from '@/utils/storage'
-import {USER_NAME} from '@/store/mutation-types'
+import {TEAM_ID, USER_INFO, USER_NAME} from '@/store/mutation-types'
export default {
name: 'UserMenu',
@@ -184,7 +200,9 @@ export default {
passwordVisible: false,
formPassword: null,
confirmDirty: false,
- themeDark: false
+ themeDark: false,
+ form: this.$form.createForm(this),
+ teamList: []
}
},
@@ -203,6 +221,7 @@ export default {
mounted() {
this.handleChangeTheme(true)
+ this.fetchTeams()
},
methods: {
@@ -296,6 +315,21 @@ export default {
callback()
},
+ handleChangeTeam(teamId) {
+ storage.set(TEAM_ID, teamId)
+ },
+
+ fetchTeams() {
+ teams({
+ userId: storage.get(USER_INFO).userId
+ }).then((r) => {
+ this.teamList = r.data
+ })
+ },
+ },
+ watch: {
+ visible() {
+ }
}
}
</script>
diff --git a/streampark-console/streampark-console-webapp/src/store/modules/user.js b/streampark-console/streampark-console-webapp/src/store/modules/user.js
index 7c53ec691..94433ea93 100644
--- a/streampark-console/streampark-console-webapp/src/store/modules/user.js
+++ b/streampark-console/streampark-console-webapp/src/store/modules/user.js
@@ -16,7 +16,7 @@
*/
import { signin, signout } from '@/api/passport'
-import {TOKEN, EXPIRE, PERMISSIONS, ROLES, USER_INFO,USER_NAME, USER_ROUTER, INVALID} from '@/store/mutation-types'
+import {TOKEN, EXPIRE, PERMISSIONS, ROLES, USER_INFO, USER_NAME, USER_ROUTER, INVALID} from '@/store/mutation-types'
import storage from '@/utils/storage'
import { getRouter } from '@/api/menu'
@@ -70,6 +70,7 @@ const user = {
state.welcome = null
state.avatar = null
storage.rm(USER_INFO)
+ storage.rm(USER_NAME)
storage.rm(USER_ROUTER)
storage.rm(TOKEN)
storage.rm(ROLES)
diff --git a/streampark-console/streampark-console-webapp/src/store/mutation-types.js b/streampark-console/streampark-console-webapp/src/store/mutation-types.js
index df5ca4ba5..6505f2971 100644
--- a/streampark-console/streampark-console-webapp/src/store/mutation-types.js
+++ b/streampark-console/streampark-console-webapp/src/store/mutation-types.js
@@ -22,6 +22,7 @@ export const EXPIRE = 'EXPIRE'
export const ROLES = 'ROLES'
export const USER_INFO = 'USER_INFO'
export const USER_NAME = 'USER_NAME'
+export const TEAM_ID = 'TEAM_ID'
export const INVALID = 'INVALID'
export const SIDEBAR_TYPE = 'SIDEBAR_TYPE'
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/Add.vue b/streampark-console/streampark-console-webapp/src/views/flink/app/Add.vue
index 109125fec..9d538d045 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/app/Add.vue
+++ b/streampark-console/streampark-console-webapp/src/views/flink/app/Add.vue
@@ -1467,6 +1467,7 @@
import configOptions from './Option'
import SvgIcon from '@/components/SvgIcon'
import { sysHadoopConf } from '@api/config'
+ import {TEAM_ID} from '@/store/mutation-types'
import {
uploadJars as histUploadJars,
@@ -2310,6 +2311,7 @@
}
const params = {
jobType: 1,
+ teamId: storage.get(TEAM_ID),
executionMode: values.executionMode,
versionId: values.versionId,
projectId: values.project || null,
@@ -2414,6 +2416,7 @@
const params = {
jobType: 2,
+ teamId: storage.get(TEAM_ID),
executionMode: values.executionMode,
versionId: values.versionId,
flinkSql: this.controller.flinkSql.value,
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue b/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue
index d4ccf0dda..83e1afe80 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue
+++ b/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue
@@ -1143,6 +1143,8 @@ import {Terminal} from 'xterm'
import 'xterm/css/xterm.css'
import SvgIcon from '@/components/SvgIcon'
import {list as listUser} from '@/api/user'
+import storage from '@/utils/storage'
+import {TEAM_ID} from '@/store/mutation-types'
export default {
components: {Ellipsis, State, SvgIcon},
@@ -2007,7 +2009,10 @@ export default {
const params = Object.assign(this.queryParams, {})
params.pageSize = 999999999
params.pageNum = 1
- list({...params}).then((resp) => {
+ list({
+ ...params,
+ teamId: storage.get(TEAM_ID)
+ }).then((resp) => {
const dataSource = resp.data.records
dataSource.forEach(record => {
if (record.tags !== null && record.tags !== undefined && record.tags !== '') {
@@ -2041,7 +2046,10 @@ export default {
params.pageSize = this.pagination.defaultPageSize
params.pageNum = this.pagination.defaultCurrent
}
- list({...params}).then((resp) => {
+ list({
+ ...params,
+ teamId: storage.get(TEAM_ID)
+ }).then((resp) => {
this.loading = false
const pagination = {...this.pagination}
pagination.total = parseInt(resp.data.total)
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue b/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue
index 13c5e97eb..df5d9c50e 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue
@@ -184,6 +184,8 @@
<script>
import { create,branches,gitcheck,exists } from '@api/project'
+import storage from '@/utils/storage'
+import {TEAM_ID} from '@/store/mutation-types'
export default {
name: 'BaseForm',
@@ -265,6 +267,7 @@ export default {
} else {
create({
name: values.name,
+ teamId: storage.get(TEAM_ID),
url: values.url,
repository: values.repository,
type: values.type,
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/View.vue b/streampark-console/streampark-console-webapp/src/views/flink/project/View.vue
index 7f73ba98e..f6f64b79b 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/project/View.vue
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/View.vue
@@ -253,6 +253,8 @@ import { Terminal } from 'xterm'
import 'xterm/css/xterm.css'
import SvgIcon from '@/components/SvgIcon'
+import storage from '@/utils/storage'
+import {TEAM_ID} from '@/store/mutation-types'
export default {
components: { Ellipsis, SvgIcon },
@@ -432,7 +434,8 @@ export default {
// params.pageNum = this.pagination.current
}
list({
- ...params
+ ...params,
+ teamId: storage.get(TEAM_ID)
}).then((resp) => {
const pagination = { ...this.pagination }
pagination.total = parseInt(resp.data.total)
diff --git a/streampark-console/streampark-console-webapp/src/views/system/user/User.vue b/streampark-console/streampark-console-webapp/src/views/system/member/Member.vue
similarity index 51%
copy from streampark-console/streampark-console-webapp/src/views/system/user/User.vue
copy to streampark-console/streampark-console-webapp/src/views/system/member/Member.vue
index eefe9ba15..61a3f7f2b 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/user/User.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/member/Member.vue
@@ -23,19 +23,37 @@
class="table-page-search-wrapper">
<a-form
layout="inline">
- <a-row
- :gutter="48">
+ <a-row>
<div
class="fold">
<a-col
- :md="8"
- :sm="24">
+ :md="4">
<a-form-item
label="User Name"
:label-col="{span: 4}"
- :wrapper-col="{span: 18, offset: 2}">
+ :wrapper-col="{span: 18}">
<a-input
- v-model="queryParams.username" />
+ style="width: 90%"
+ v-model="queryParams.userName"/>
+ </a-form-item>
+ </a-col>
+ <a-col
+ :md="3">
+ <a-form-item
+ label="Role"
+ v-bind="formItemLayout">
+ <a-select
+ mode="single"
+ :allow-clear="true"
+ style="width: 80%"
+ @change="handleQueryRoleChange"
+ v-decorator="['roleName']">
+ <a-select-option
+ v-for="r in roleData"
+ :key="r.roleName">
+ {{ r.roleName }}
+ </a-select-option>
+ </a-select>
</a-form-item>
</a-col>
<template>
@@ -47,8 +65,8 @@
:label-col="{span: 4}"
:wrapper-col="{span: 18, offset: 2}">
<range-date
- @change="handleDateChange"
- ref="createTime" />
+ @change="handleQueryDateChange"
+ ref="createTime"/>
</a-form-item>
</a-col>
</template>
@@ -62,25 +80,25 @@
type="primary"
shape="circle"
icon="search"
- @click="search" />
+ @click="search"/>
<a-button
type="primary"
shape="circle"
icon="rest"
- @click="reset" />
+ @click="reset"/>
<a-button
type="primary"
shape="circle"
icon="plus"
- v-permit="'user:add'"
- @click="handleAdd" />
+ v-permit="'member:add'"
+ @click="handleMemberAdd"/>
</span>
</a-col>
</a-row>
</a-form>
</div>
- <!-- table area -->
+ <!-- Table -->
<a-table
ref="TableInfo"
:columns="columns"
@@ -89,102 +107,69 @@
:loading="loading"
:scroll="{ x: 900 }"
@change="handleTableChange">
- <template
- slot="email"
- slot-scope="text">
- <a-popover
- placement="topLeft">
- <template
- slot="content">
- <div>
- {{ text }}
- </div>
- </template>
- <p
- style="width: 150px;margin-bottom: 0">
- {{ text }}
- </p>
- </a-popover>
- </template>
<template
slot="operation"
- slot-scope="text, record">
+ slot-scope="text, member">
<svg-icon
- v-permit="'user:update'"
- v-if="(record.username !== 'admin' || userName === 'admin')"
+ v-permit="'member:update'"
name="edit"
border
- @click.native="handleEdit(record)"
- title="modify" />
- <svg-icon
- name="see"
- border
- @click.native="handleView(record)"
- title="view" />
- <svg-icon
- v-permit="'user:reset'"
- v-if="(record.username !== 'admin' || userName === 'admin')"
- name="resetpass"
- border
- @click.native="resetPassword(record)"
- title="reset password" />
+ @click.native="handleMemberEdit(member)"
+ title="modify"/>
<a-popconfirm
- v-permit="'user:delete'"
- v-if="record.username !== 'admin'"
- title="Are you sure delete this user ?"
+ v-permit="'member:delete'"
+ title="Are you sure delete this member ?"
cancel-text="No"
ok-text="Yes"
- @confirm="handleDelete(record)">
+ @confirm="handleMemberDelete(member)">
<svg-icon name="remove" border/>
</a-popconfirm>
</template>
</a-table>
- <!-- View user information -->
- <user-info
- :data="userInfo.data"
- :visible="userInfo.visible"
- @close="handleUserInfoClose" />
- <!-- New users -->
- <user-add
- @close="handleUserAddClose"
- @success="handleUserAddSuccess"
- :visible="userAdd.visible" />
- <!-- modify user -->
- <user-edit
- ref="userEdit"
- @close="handleUserEditClose"
- @success="handleUserEditSuccess"
- :visible="userEdit.visible" />
+ <!-- Add member -->
+ <member-add
+ @close="handleMemberAddClose"
+ @success="handleMemberAddSuccess"
+ :visible="memberAdd.visible"/>
+ <!-- Edit member -->
+ <member-edit
+ ref="memberEdit"
+ @close="handleMemberEditClose"
+ @success="handleMemberEditSuccess"
+ :visible="memberEdit.visible"/>
</a-card>
</template>
<script>
-import UserInfo from './UserInfo'
-import UserAdd from './UserAdd'
-import UserEdit from './UserEdit'
+import MemberAdd from './MemberAdd'
+import MemberEdit from './MemberEdit'
import RangeDate from '@/components/DateTime/RangeDate'
import SvgIcon from '@/components/SvgIcon'
-import { list, deleteUser, reset as resetPassword } from '@/api/user'
+import {list, remove} from '@/api/member'
+import {list as getRole} from '@/api/role'
import storage from '@/utils/storage'
-import {USER_NAME} from '@/store/mutation-types'
+import {TEAM_ID} from '@/store/mutation-types'
+const formItemLayout = {
+ labelCol: { span: 4 },
+ wrapperCol: { span: 18 }
+}
export default {
- name: 'User',
- components: { UserInfo, UserAdd, UserEdit, RangeDate, SvgIcon },
- data () {
+ name: 'Member',
+ components: {MemberAdd, MemberEdit, RangeDate, SvgIcon},
+ data() {
return {
- userInfo: {
- visible: false,
- data: {}
- },
- userAdd: {
+ memberAdd: {
visible: false
},
- userEdit: {
+ memberEdit: {
visible: false
},
+ formItemLayout,
+ roleData: [],
+ roleName: null,
queryParams: {},
filteredInfo: null,
sortedInfo: null,
@@ -202,96 +187,83 @@ export default {
}
},
computed: {
- columns () {
- let { sortedInfo, filteredInfo } = this
+ columns() {
+ let {sortedInfo} = this
sortedInfo = sortedInfo || {}
- filteredInfo = filteredInfo || {}
return [{
title: 'User Name',
- dataIndex: 'username',
+ dataIndex: 'userName',
sorter: true,
- sortOrder: sortedInfo.columnKey === 'username' && sortedInfo.order
+ sortOrder: sortedInfo.columnKey === 'userName' && sortedInfo.order
}, {
- title: 'Nick Name',
- dataIndex: 'nickName'
- }, {
- title: 'Status',
- dataIndex: 'status',
- customRender: (text, row, index) => {
- switch (text) {
- case '0': return <a-tag color="red"> Locked </a-tag>
- case '1': return <a-tag color="cyan"> Effective </a-tag>
- default: return text
- }
- },
- filters: [
- { text: 'Effective', value: '1' },
- { text: 'Locked', value: '0' }
- ],
- filterMultiple: false,
- filteredValue: filteredInfo.status || null,
- onFilter: (value, record) => value
+ title: 'Role Name',
+ dataIndex: 'roleName',
+ sorter: true,
+ sortOrder: sortedInfo.columnKey === 'roleName' && sortedInfo.order
}, {
title: 'Create Time',
dataIndex: 'createTime',
sorter: true,
sortOrder: sortedInfo.columnKey === 'createTime' && sortedInfo.order
- },
- {
- title: 'Operation',
- dataIndex: 'operation',
- scopedSlots: { customRender: 'operation' }
- }]
- },
- userName() {
- return storage.get(USER_NAME)
+ }, {
+ title: 'Modify Time',
+ dataIndex: 'modifyTime',
+ sorter: true,
+ sortOrder: sortedInfo.columnKey === 'modifyTime' && sortedInfo.order
+ }, {
+ title: 'Operation',
+ dataIndex: 'operation',
+ scopedSlots: {customRender: 'operation'}
+ }]
}
},
- mounted () {
+ mounted() {
this.fetch()
+ getRole(
+ {'pageSize': '9999'}
+ ).then((resp) => {
+ this.roleData = resp.data.records
+ })
},
methods: {
- handleView (record) {
- this.userInfo.data = record
- this.userInfo.visible = true
- },
- handleAdd () {
- this.userAdd.visible = true
+ handleMemberAdd() {
+ this.memberAdd.visible = true
},
- handleUserAddClose () {
- this.userAdd.visible = false
+ handleMemberAddClose() {
+ this.memberAdd.visible = false
},
- handleUserAddSuccess () {
- this.userAdd.visible = false
- this.$message.success('add user successfully')
+ handleMemberAddSuccess() {
+ this.memberAdd.visible = false
+ this.$message.success('add member successfully')
this.search()
},
- handleEdit (record) {
- this.$refs.userEdit.setFormValues(record)
- this.userEdit.visible = true
+ handleMemberEdit(record) {
+ this.$refs.memberEdit.setFormValues(record)
+ this.memberEdit.visible = true
},
- handleUserEditClose () {
- this.userEdit.visible = false
+ handleMemberEditClose() {
+ this.memberEdit.visible = false
},
- handleUserEditSuccess () {
- this.userEdit.visible = false
- this.$message.success('modify user successfully')
+ handleMemberEditSuccess() {
+ this.memberEdit.visible = false
+ this.$message.success('modify member successfully')
this.search()
},
- handleUserInfoClose () {
- this.userInfo.visible = false
+ handleQueryRoleChange(roleName) {
+ this.roleName = roleName
+ this.search()
},
- handleDateChange (value) {
+ handleQueryDateChange(value) {
if (value) {
this.queryParams.createTimeFrom = value[0]
this.queryParams.createTimeTo = value[1]
}
},
- handleDelete (record) {
- deleteUser({
- userId: record.userId
+ handleMemberDelete(member) {
+ remove({
+ id: member.id
}).then((resp) => {
if (resp.status === 'success') {
this.$message.success('delete successful')
@@ -302,31 +274,9 @@ export default {
})
},
- resetPassword (user) {
- this.$swal.fire({
- title: 'reset password, are yor sure?',
- showCancelButton: true,
- confirmButtonText: `Yes`,
- }).then((result) => {
- if (result.isConfirmed) {
- resetPassword( {
- usernames: user.username
- }).then((resp) => {
- if (resp.status === 'success') {
- this.$swal.fire(
- 'reset password successful, user ['+ user.username + '] new password is streampark666', '',
- 'success'
- )
- }
- })
- }
- })
- },
-
- search () {
- const { sortedInfo, filteredInfo } = this
+ search() {
+ const {sortedInfo, filteredInfo} = this
let sortField, sortOrder
- // Get the sorting of the current column and the filter rules of the column
if (sortedInfo) {
sortField = sortedInfo.field
sortOrder = sortedInfo.order
@@ -338,27 +288,24 @@ export default {
...filteredInfo
})
},
- reset () {
- // Reset pagination
+ reset() {
+ // reset pagination
this.$refs.TableInfo.pagination.current = this.pagination.defaultCurrent
if (this.paginationInfo) {
this.paginationInfo.current = this.pagination.defaultCurrent
this.paginationInfo.pageSize = this.pagination.defaultPageSize
}
- // Reset filteredInfo
+ // reset filteredInfo, sortedInfo and queryParams
this.filteredInfo = null
- // Reset sortedInfo
this.sortedInfo = null
- // Reset queryParams
this.queryParams = {}
this.$refs.createTime.reset()
this.fetch()
},
- handleTableChange (pagination, filters, sorter) {
+ handleTableChange(pagination, filters, sorter) {
this.paginationInfo = pagination
this.filteredInfo = filters
this.sortedInfo = sorter
- this.userInfo.visible = false
this.fetch({
sortField: sorter.field,
sortOrder: sorter.order,
@@ -366,36 +313,48 @@ export default {
...filters
})
},
- fetch (params = {}) {
- // show loading
+ fetch(params = {}) {
this.loading = true
if (this.paginationInfo) {
- // If the paging information is not empty, set the current page of the table, the number of items per page, and set the query paging parameters
+ // Set pagination
this.$refs.TableInfo.pagination.current = this.paginationInfo.current
this.$refs.TableInfo.pagination.pageSize = this.paginationInfo.pageSize
params.pageSize = this.paginationInfo.pageSize
params.pageNum = this.paginationInfo.current
} else {
- // If pagination information is empty, set to default
+ // Set the default pagination
params.pageSize = this.pagination.defaultPageSize
params.pageNum = this.pagination.defaultCurrent
}
- if(params.status != null && params.status.length>0) {
+ if (params.status != null && params.status.length > 0) {
params.status = params.status[0]
} else {
delete params.status
}
+ if (params.sortField === 'roleName') {
+ params.sortField = 'role_name'
+ }
+
if (params.sortField === 'createTime') {
params.sortField = 'create_time'
}
- list({ ...params }).then((resp) => {
- const pagination = { ...this.pagination }
+ if (params.sortField === 'modifyTime') {
+ params.sortField = 'modify_time'
+ }
+
+ list({
+ ...params,
+ teamId: storage.get(TEAM_ID),
+ roleName: this.roleName
+ }).then((resp) => {
+ const pagination = {...this.pagination}
pagination.total = parseInt(resp.data.total)
this.dataSource = resp.data.records
this.pagination = pagination
- // After the data is loaded, close the loading
+ this.loading = false
+ }).catch(() => {
this.loading = false
})
}
diff --git a/streampark-console/streampark-console-webapp/src/views/system/user/UserAdd.vue b/streampark-console/streampark-console-webapp/src/views/system/member/MemberAdd.vue
similarity index 57%
copy from streampark-console/streampark-console-webapp/src/views/system/user/UserAdd.vue
copy to streampark-console/streampark-console-webapp/src/views/system/member/MemberAdd.vue
index 06d49c937..5c3d6c70e 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/user/UserAdd.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/member/MemberAdd.vue
@@ -23,12 +23,12 @@
width="650"
placement="right"
:closable="true"
- @close="onClose"
:visible="visible"
+ @close="onClose"
style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
<template slot="title">
- <a-icon type="user" />
- Add User
+ <a-icon type="user-add"/>
+ Add Member
</template>
<a-form
:form="form">
@@ -40,51 +40,15 @@
<a-input
@blur="handleUserNameBlur"
v-decorator="
- ['username',
- {rules: [{ required: true }]}]" />
- </a-form-item>
- <a-form-item
- label="Nick Name"
- v-bind="formItemLayout"
- :validate-status="validateStatus"
- :help="help">
- <a-input
- v-decorator="['nickName',{rules: [{ required: true }]}]" />
- </a-form-item>
- <a-form-item
- label="Password"
- v-bind="formItemLayout">
- <a-input-password
- placeholder="input password"
- v-decorator="['password',{rules: [
- { required: true, message: 'password is required'},
- { min: 8, message: 'Password length cannot be less than 8 characters'}
- ]}]" />
- </a-form-item>
- <a-form-item
- label="E-Mail"
- v-bind="formItemLayout">
- <a-input
- v-decorator="['email',{rules: [
- { type: 'email', message: 'please enter a valid email address' },
- { max: 50, message: 'exceeds maximum length limit of 50 characters'}
- ]}]" />
- </a-form-item>
- <a-form-item
- label="Description"
- v-bind="formItemLayout">
- <a-input
- v-decorator="['description',{rules: [
- { max: 100, message: 'exceeds maximum length limit of 100 characters'}
- ]}]" />
+ ['userName',
+ {rules: [{ required: true }]}]"/>
</a-form-item>
<a-form-item
label="Role"
v-bind="formItemLayout">
<a-select
- mode="multiple"
+ mode="single"
:allow-clear="true"
- style="width: 100%"
v-decorator="['roleId',{rules: [{ required: true, message: 'please select role' }]}]">
<a-select-option
v-for="r in roleData"
@@ -93,40 +57,6 @@
</a-select-option>
</a-select>
</a-form-item>
- <a-form-item
- label="Status"
- v-bind="formItemLayout">
- <a-radio-group
- v-decorator="['status',{rules: [{ required: true, message: 'please select status'}]}]">
- <a-radio
- value="0">
- locked
- </a-radio>
- <a-radio
- value="1">
- effective
- </a-radio>
- </a-radio-group>
- </a-form-item>
- <a-form-item
- label="Gender"
- v-bind="formItemLayout">
- <a-radio-group
- v-decorator="['sex',{rules: [{ required: true, message: 'please select gender' }]}]">
- <a-radio
- value="0">
- male
- </a-radio>
- <a-radio
- value="1">
- female
- </a-radio>
- <a-radio
- value="2">
- secret
- </a-radio>
- </a-radio-group>
- </a-form-item>
</a-form>
<div
class="drawer-bootom-button">
@@ -144,22 +74,25 @@
</a-drawer>
</template>
<script>
-import { list as getRole } from '@/api/role'
-import { checkUserName, post } from '@/api/user'
+import {post} from '@/api/member'
+import {list as getRole} from '@/api/role'
+import {checkUserName} from '@/api/user'
+import storage from '@/utils/storage'
+import {TEAM_ID} from '@/store/mutation-types'
const formItemLayout = {
- labelCol: { span: 4 },
- wrapperCol: { span: 18 }
+ labelCol: {span: 4},
+ wrapperCol: {span: 18}
}
export default {
- name: 'UserAdd',
+ name: 'MemberAdd',
props: {
visible: {
type: Boolean,
default: false
}
},
- data () {
+ data() {
return {
loading: false,
roleData: [],
@@ -170,24 +103,25 @@ export default {
}
},
methods: {
- reset () {
+ reset() {
this.validateStatus = ''
this.help = ''
this.loading = false
this.form.resetFields()
},
- onClose () {
+ onClose() {
this.reset()
this.$emit('close')
},
handleSubmit() {
- this.form.validateFields((err, user) => {
+ this.form.validateFields((err, member) => {
if (!err && this.validateStatus === 'success') {
- user.roleId = user.roleId.join(',')
+ this.loading = true
post({
- ...user
+ ...member,
+ teamId: storage.get(TEAM_ID)
}).then((r) => {
if (r.status === 'success') {
this.reset()
@@ -199,7 +133,7 @@ export default {
}
})
},
- handleUserNameBlur (e) {
+ handleUserNameBlur(e) {
const username = (e && e.target.value) || ''
if (username.length) {
if (username.length > 20) {
@@ -207,18 +141,18 @@ export default {
this.help = 'User name should not be longer than 20 characters'
} else if (username.length < 4) {
this.validateStatus = 'error'
- this.help = 'Team name should not be less than 4 characters'
+ this.help = 'User name should not be less than 4 characters'
} else {
this.validateStatus = 'validating'
checkUserName({
username: username
}).then((r) => {
if (r.data) {
+ this.validateStatus = 'error'
+ this.help = 'Sorry, the user name doesn\'t exists'
+ } else {
this.validateStatus = 'success'
this.help = ''
- } else {
- this.validateStatus = 'error'
- this.help = 'Sorry, the user name already exists'
}
})
}
@@ -229,10 +163,10 @@ export default {
}
},
watch: {
- visible () {
+ visible() {
if (this.visible) {
getRole(
- { 'pageSize': '9999' }
+ {'pageSize': '9999'}
).then((resp) => {
this.roleData = resp.data.records
})
diff --git a/streampark-console/streampark-console-webapp/src/views/system/member/MemberEdit.vue b/streampark-console/streampark-console-webapp/src/views/system/member/MemberEdit.vue
new file mode 100644
index 000000000..b6867aa49
--- /dev/null
+++ b/streampark-console/streampark-console-webapp/src/views/system/member/MemberEdit.vue
@@ -0,0 +1,157 @@
+<!--
+
+ 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.
+
+-->
+
+<template>
+ <a-drawer
+ :mask-closable="false"
+ width="650"
+ placement="right"
+ :closable="true"
+ :visible="visible"
+ @close="onClose"
+ style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
+ <template slot="title">
+ <a-icon type="user"/>
+ Modify Member
+ </template>
+ <a-form
+ :form="form">
+ <a-form-item
+ label="User Name"
+ v-bind="formItemLayout">
+ <a-input
+ read-only
+ v-decorator="['userName']"/>
+ </a-form-item>
+ <a-form-item
+ label="Role"
+ v-bind="formItemLayout">
+ <a-select
+ mode="single"
+ :allow-clear="true"
+ v-decorator="['roleId',{rules: [{ required: true, message: 'please select role' }]}]">
+ <a-select-option
+ v-for="r in roleData"
+ :key="r.roleId">
+ {{ r.roleName }}
+ </a-select-option>
+ </a-select>
+ </a-form-item>
+ </a-form>
+ <div
+ class="drawer-bootom-button">
+ <a-button
+ @click="onClose">
+ Cancel
+ </a-button>
+ <a-button
+ @click="handleSubmit"
+ type="primary"
+ :loading="loading">
+ Submit
+ </a-button>
+ </div>
+ </a-drawer>
+</template>
+<script>
+import {update} from '@/api/member'
+import {list as getRole} from '@/api/role'
+import storage from '@/utils/storage'
+import {TEAM_ID} from '@/store/mutation-types'
+
+const formItemLayout = {
+ labelCol: {span: 4},
+ wrapperCol: {span: 18}
+}
+export default {
+ name: 'MemberEdit',
+ props: {
+ visible: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data() {
+ return {
+ formItemLayout,
+ form: this.$form.createForm(this),
+ memberId: '',
+ userId: '',
+ roleData: [],
+ loading: false
+ }
+ },
+
+ methods: {
+
+ onClose() {
+ this.loading = false
+ this.form.resetFields()
+ this.$emit('close')
+ },
+
+ setFormValues({...member}) {
+ this.memberId = member.id
+ this.userId = member.userId
+ const fields = ['userName', 'roleId']
+ Object.keys(member).forEach((key) => {
+ if (fields.indexOf(key) !== -1) {
+ this.form.getFieldDecorator(key)
+ const obj = {}
+ obj[key] = member[key]
+ this.form.setFieldsValue(obj)
+ }
+ })
+ },
+
+ handleSubmit() {
+ this.form.validateFields((err, member) => {
+ if (!err) {
+ this.loading = true
+ const member = this.form.getFieldsValue()
+ member.id = this.memberId
+ member.userId = this.userId
+ member.teamId = storage.get(TEAM_ID)
+ update(member).then((r) => {
+ if (r.status === 'success') {
+ this.loading = false
+ this.$emit('success')
+ } else {
+ this.loading = false
+ }
+ }).catch(() => {
+ this.loading = false
+ })
+ }
+ })
+ }
+ },
+ watch: {
+ visible() {
+ if (this.visible) {
+ getRole(
+ {'pageSize': '9999'}
+ ).then((resp) => {
+ this.roleData = resp.data.records
+ })
+ }
+ }
+ }
+}
+</script>
diff --git a/streampark-console/streampark-console-webapp/src/views/system/role/Role.vue b/streampark-console/streampark-console-webapp/src/views/system/role/Role.vue
index de49e710b..dd3e9cfb7 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/role/Role.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/role/Role.vue
@@ -111,7 +111,6 @@
slot="operation"
slot-scope="text, record">
<svg-icon
- v-if="(record.roleName !== 'admin' || userName === 'admin')"
v-permit="'role:update'"
name="edit"
border
@@ -124,7 +123,6 @@
title="View" />
<a-popconfirm
v-permit="'role:delete'"
- v-if="record.roleName !== 'admin'"
title="Are you sure delete this Role ?"
cancel-text="No"
ok-text="Yes"
@@ -160,8 +158,6 @@ import RoleInfo from './RoleInfo'
import RoleEdit from './RoleEdit'
import SvgIcon from '@/components/SvgIcon'
import { list, remove } from '@/api/role'
-import storage from '@/utils/storage'
-import {USER_NAME} from '@/store/mutation-types'
export default {
name: 'Role',
@@ -224,9 +220,6 @@ export default {
dataIndex: 'operation',
scopedSlots: { customRender: 'operation' }
}]
- },
- userName() {
- return storage.get(USER_NAME)
}
},
mounted () {
diff --git a/streampark-console/streampark-console-webapp/src/views/system/user/User.vue b/streampark-console/streampark-console-webapp/src/views/system/team/Team.vue
similarity index 51%
copy from streampark-console/streampark-console-webapp/src/views/system/user/User.vue
copy to streampark-console/streampark-console-webapp/src/views/system/team/Team.vue
index eefe9ba15..cf0326c1b 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/user/User.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/team/Team.vue
@@ -31,11 +31,11 @@
:md="8"
:sm="24">
<a-form-item
- label="User Name"
+ label="Team Name"
:label-col="{span: 4}"
:wrapper-col="{span: 18, offset: 2}">
<a-input
- v-model="queryParams.username" />
+ v-model="queryParams.teamName"/>
</a-form-item>
</a-col>
<template>
@@ -47,8 +47,8 @@
:label-col="{span: 4}"
:wrapper-col="{span: 18, offset: 2}">
<range-date
- @change="handleDateChange"
- ref="createTime" />
+ @change="handleQueryDateChange"
+ ref="createTime"/>
</a-form-item>
</a-col>
</template>
@@ -62,25 +62,25 @@
type="primary"
shape="circle"
icon="search"
- @click="search" />
+ @click="search"/>
<a-button
type="primary"
shape="circle"
icon="rest"
- @click="reset" />
+ @click="reset"/>
<a-button
type="primary"
shape="circle"
icon="plus"
- v-permit="'user:add'"
- @click="handleAdd" />
+ v-permit="'team:add'"
+ @click="handleTeamAdd"/>
</span>
</a-col>
</a-row>
</a-form>
</div>
- <!-- table area -->
+ <!-- Table -->
<a-table
ref="TableInfo"
:columns="columns"
@@ -89,100 +89,57 @@
:loading="loading"
:scroll="{ x: 900 }"
@change="handleTableChange">
- <template
- slot="email"
- slot-scope="text">
- <a-popover
- placement="topLeft">
- <template
- slot="content">
- <div>
- {{ text }}
- </div>
- </template>
- <p
- style="width: 150px;margin-bottom: 0">
- {{ text }}
- </p>
- </a-popover>
- </template>
<template
slot="operation"
- slot-scope="text, record">
+ slot-scope="text, team">
<svg-icon
- v-permit="'user:update'"
- v-if="(record.username !== 'admin' || userName === 'admin')"
+ v-permit="'team:update'"
name="edit"
border
- @click.native="handleEdit(record)"
- title="modify" />
- <svg-icon
- name="see"
- border
- @click.native="handleView(record)"
- title="view" />
- <svg-icon
- v-permit="'user:reset'"
- v-if="(record.username !== 'admin' || userName === 'admin')"
- name="resetpass"
- border
- @click.native="resetPassword(record)"
- title="reset password" />
+ @click.native="handleTeamEdit(team)"
+ title="modify"/>
<a-popconfirm
- v-permit="'user:delete'"
- v-if="record.username !== 'admin'"
- title="Are you sure delete this user ?"
+ v-permit="'team:delete'"
+ title="Are you sure delete this team ?"
cancel-text="No"
ok-text="Yes"
- @confirm="handleDelete(record)">
+ @confirm="handleTeamDelete(team)">
<svg-icon name="remove" border/>
</a-popconfirm>
</template>
</a-table>
- <!-- View user information -->
- <user-info
- :data="userInfo.data"
- :visible="userInfo.visible"
- @close="handleUserInfoClose" />
- <!-- New users -->
- <user-add
- @close="handleUserAddClose"
- @success="handleUserAddSuccess"
- :visible="userAdd.visible" />
- <!-- modify user -->
- <user-edit
- ref="userEdit"
- @close="handleUserEditClose"
- @success="handleUserEditSuccess"
- :visible="userEdit.visible" />
+ <!-- Add team -->
+ <team-add
+ @close="handleTeamAddClose"
+ @success="handleTeamAddSuccess"
+ :visible="teamAdd.visible"/>
+ <!-- Edit team -->
+ <team-edit
+ ref="teamEdit"
+ @close="handleTeamEditClose"
+ @success="handleTeamEditSuccess"
+ :visible="teamEdit.visible"/>
</a-card>
</template>
<script>
-import UserInfo from './UserInfo'
-import UserAdd from './UserAdd'
-import UserEdit from './UserEdit'
+import TeamAdd from './TeamAdd'
+import TeamEdit from './TeamEdit'
import RangeDate from '@/components/DateTime/RangeDate'
import SvgIcon from '@/components/SvgIcon'
-import { list, deleteUser, reset as resetPassword } from '@/api/user'
-import storage from '@/utils/storage'
-import {USER_NAME} from '@/store/mutation-types'
+import {list, remove} from '@/api/team'
export default {
- name: 'User',
- components: { UserInfo, UserAdd, UserEdit, RangeDate, SvgIcon },
- data () {
+ name: 'Team',
+ components: {TeamAdd, TeamEdit, RangeDate, SvgIcon},
+ data() {
return {
- userInfo: {
- visible: false,
- data: {}
- },
- userAdd: {
+ teamAdd: {
visible: false
},
- userEdit: {
+ teamEdit: {
visible: false
},
queryParams: {},
@@ -202,96 +159,74 @@ export default {
}
},
computed: {
- columns () {
- let { sortedInfo, filteredInfo } = this
+ columns() {
+ let {sortedInfo} = this
sortedInfo = sortedInfo || {}
- filteredInfo = filteredInfo || {}
return [{
- title: 'User Name',
- dataIndex: 'username',
+ title: 'Team Name',
+ dataIndex: 'teamName',
sorter: true,
- sortOrder: sortedInfo.columnKey === 'username' && sortedInfo.order
+ sortOrder: sortedInfo.columnKey === 'teamName' && sortedInfo.order
}, {
- title: 'Nick Name',
- dataIndex: 'nickName'
- }, {
- title: 'Status',
- dataIndex: 'status',
- customRender: (text, row, index) => {
- switch (text) {
- case '0': return <a-tag color="red"> Locked </a-tag>
- case '1': return <a-tag color="cyan"> Effective </a-tag>
- default: return text
- }
- },
- filters: [
- { text: 'Effective', value: '1' },
- { text: 'Locked', value: '0' }
- ],
- filterMultiple: false,
- filteredValue: filteredInfo.status || null,
- onFilter: (value, record) => value
+ title: 'Description',
+ dataIndex: 'description',
+ scopedSlots: {customRender: 'description'},
+ width: 350
}, {
title: 'Create Time',
dataIndex: 'createTime',
sorter: true,
sortOrder: sortedInfo.columnKey === 'createTime' && sortedInfo.order
- },
- {
- title: 'Operation',
- dataIndex: 'operation',
- scopedSlots: { customRender: 'operation' }
- }]
- },
- userName() {
- return storage.get(USER_NAME)
+ }, {
+ title: 'Modify Time',
+ dataIndex: 'modifyTime',
+ sorter: true,
+ sortOrder: sortedInfo.columnKey === 'modifyTime' && sortedInfo.order
+ }, {
+ title: 'Operation',
+ dataIndex: 'operation',
+ scopedSlots: {customRender: 'operation'}
+ }]
}
},
- mounted () {
+ mounted() {
this.fetch()
},
methods: {
- handleView (record) {
- this.userInfo.data = record
- this.userInfo.visible = true
+ handleTeamAdd() {
+ this.teamAdd.visible = true
},
- handleAdd () {
- this.userAdd.visible = true
+ handleTeamAddClose() {
+ this.teamAdd.visible = false
},
- handleUserAddClose () {
- this.userAdd.visible = false
- },
- handleUserAddSuccess () {
- this.userAdd.visible = false
- this.$message.success('add user successfully')
+ handleTeamAddSuccess() {
+ this.teamAdd.visible = false
+ this.$message.success('add team successfully')
this.search()
},
- handleEdit (record) {
- this.$refs.userEdit.setFormValues(record)
- this.userEdit.visible = true
+ handleTeamEdit(record) {
+ this.$refs.teamEdit.setFormValues(record)
+ this.teamEdit.visible = true
},
- handleUserEditClose () {
- this.userEdit.visible = false
+ handleTeamEditClose() {
+ this.teamEdit.visible = false
},
- handleUserEditSuccess () {
- this.userEdit.visible = false
- this.$message.success('modify user successfully')
+ handleTeamEditSuccess() {
+ this.teamEdit.visible = false
+ this.$message.success('modify team successfully')
this.search()
},
- handleUserInfoClose () {
- this.userInfo.visible = false
- },
- handleDateChange (value) {
+ handleQueryDateChange(value) {
if (value) {
this.queryParams.createTimeFrom = value[0]
this.queryParams.createTimeTo = value[1]
}
},
- handleDelete (record) {
- deleteUser({
- userId: record.userId
+ handleTeamDelete(team) {
+ remove({
+ id: team.id
}).then((resp) => {
if (resp.status === 'success') {
this.$message.success('delete successful')
@@ -302,31 +237,9 @@ export default {
})
},
- resetPassword (user) {
- this.$swal.fire({
- title: 'reset password, are yor sure?',
- showCancelButton: true,
- confirmButtonText: `Yes`,
- }).then((result) => {
- if (result.isConfirmed) {
- resetPassword( {
- usernames: user.username
- }).then((resp) => {
- if (resp.status === 'success') {
- this.$swal.fire(
- 'reset password successful, user ['+ user.username + '] new password is streampark666', '',
- 'success'
- )
- }
- })
- }
- })
- },
-
- search () {
- const { sortedInfo, filteredInfo } = this
+ search() {
+ const {sortedInfo, filteredInfo} = this
let sortField, sortOrder
- // Get the sorting of the current column and the filter rules of the column
if (sortedInfo) {
sortField = sortedInfo.field
sortOrder = sortedInfo.order
@@ -338,27 +251,24 @@ export default {
...filteredInfo
})
},
- reset () {
- // Reset pagination
+ reset() {
+ // reset pagination
this.$refs.TableInfo.pagination.current = this.pagination.defaultCurrent
if (this.paginationInfo) {
this.paginationInfo.current = this.pagination.defaultCurrent
this.paginationInfo.pageSize = this.pagination.defaultPageSize
}
- // Reset filteredInfo
+ // reset filteredInfo, sortedInfo and queryParams
this.filteredInfo = null
- // Reset sortedInfo
this.sortedInfo = null
- // Reset queryParams
this.queryParams = {}
this.$refs.createTime.reset()
this.fetch()
},
- handleTableChange (pagination, filters, sorter) {
+ handleTableChange(pagination, filters, sorter) {
this.paginationInfo = pagination
this.filteredInfo = filters
this.sortedInfo = sorter
- this.userInfo.visible = false
this.fetch({
sortField: sorter.field,
sortOrder: sorter.order,
@@ -366,36 +276,46 @@ export default {
...filters
})
},
- fetch (params = {}) {
- // show loading
+ fetch(params = {}) {
this.loading = true
if (this.paginationInfo) {
- // If the paging information is not empty, set the current page of the table, the number of items per page, and set the query paging parameters
+ // Set pagination
this.$refs.TableInfo.pagination.current = this.paginationInfo.current
this.$refs.TableInfo.pagination.pageSize = this.paginationInfo.pageSize
params.pageSize = this.paginationInfo.pageSize
params.pageNum = this.paginationInfo.current
} else {
- // If pagination information is empty, set to default
+ // Set the default pagination
params.pageSize = this.pagination.defaultPageSize
params.pageNum = this.pagination.defaultCurrent
}
- if(params.status != null && params.status.length>0) {
+ if (params.status != null && params.status.length > 0) {
params.status = params.status[0]
} else {
delete params.status
}
+ if (params.sortField === 'teamName') {
+ params.sortField = 'team_name'
+ }
+
if (params.sortField === 'createTime') {
params.sortField = 'create_time'
}
- list({ ...params }).then((resp) => {
- const pagination = { ...this.pagination }
+ if (params.sortField === 'modifyTime') {
+ params.sortField = 'modify_time'
+ }
+
+ list({
+ ...params
+ }).then((resp) => {
+ const pagination = {...this.pagination}
pagination.total = parseInt(resp.data.total)
this.dataSource = resp.data.records
this.pagination = pagination
- // After the data is loaded, close the loading
+ this.loading = false
+ }).catch(() => {
this.loading = false
})
}
diff --git a/streampark-console/streampark-console-webapp/src/views/system/team/TeamAdd.vue b/streampark-console/streampark-console-webapp/src/views/system/team/TeamAdd.vue
new file mode 100644
index 000000000..36f50073e
--- /dev/null
+++ b/streampark-console/streampark-console-webapp/src/views/system/team/TeamAdd.vue
@@ -0,0 +1,152 @@
+<!--
+
+ 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.
+
+-->
+
+<template>
+ <a-drawer
+ :mask-closable="false"
+ width="650"
+ placement="right"
+ :closable="true"
+ :visible="visible"
+ @close="onClose"
+ style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
+ <template slot="title">
+ <a-icon type="team"/>
+ Add Team
+ </template>
+ <a-form
+ :form="form">
+ <a-form-item
+ label="Team Name"
+ v-bind="formItemLayout"
+ :validate-status="validateStatus"
+ :help="help">
+ <a-input
+ @blur="handleTeamNameBlur"
+ v-decorator="
+ ['teamName',
+ {rules: [{ required: true }]}]"/>
+ </a-form-item>
+ <a-form-item
+ label="Description"
+ v-bind="formItemLayout">
+ <a-input
+ v-decorator="['description',{rules: [
+ { max: 100, message: 'exceeds maximum length limit of 100 characters'}
+ ]}]"/>
+ </a-form-item>
+ </a-form>
+ <div
+ class="drawer-bootom-button">
+ <a-button
+ @click="onClose">
+ Cancel
+ </a-button>
+ <a-button
+ @click="handleSubmit"
+ type="primary"
+ :loading="loading">
+ Submit
+ </a-button>
+ </div>
+ </a-drawer>
+</template>
+<script>
+import {checkName, post} from '@/api/team'
+
+const formItemLayout = {
+ labelCol: {span: 4},
+ wrapperCol: {span: 18}
+}
+export default {
+ name: 'TeamAdd',
+ props: {
+ visible: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data() {
+ return {
+ loading: false,
+ formItemLayout,
+ form: this.$form.createForm(this),
+ validateStatus: '',
+ help: ''
+ }
+ },
+ methods: {
+ reset() {
+ this.validateStatus = ''
+ this.help = ''
+ this.loading = false
+ this.form.resetFields()
+ },
+
+ onClose() {
+ this.reset()
+ this.$emit('close')
+ },
+
+ handleSubmit() {
+ this.form.validateFields((err, team) => {
+ if (!err && this.validateStatus === 'success') {
+ this.loading = true
+ post(team).then((r) => {
+ if (r.status === 'success') {
+ this.reset()
+ this.$emit('success')
+ }
+ }).catch(() => {
+ this.loading = false
+ })
+ }
+ })
+ },
+ handleTeamNameBlur(e) {
+ const teamName = (e && e.target.value) || ''
+ if (teamName.length) {
+ if (teamName.length > 20) {
+ this.validateStatus = 'error'
+ this.help = 'Team name should not be longer than 20 characters'
+ } else if (teamName.length < 4) {
+ this.validateStatus = 'error'
+ this.help = 'Team name should not be less than 4 characters'
+ } else {
+ this.validateStatus = 'validating'
+ checkName({
+ teamName: teamName
+ }).then((r) => {
+ if (r.data) {
+ this.validateStatus = 'success'
+ this.help = ''
+ } else {
+ this.validateStatus = 'error'
+ this.help = 'Sorry, the team name already exists'
+ }
+ })
+ }
+ } else {
+ this.validateStatus = 'error'
+ this.help = 'Team name cannot be empty'
+ }
+ }
+ }
+}
+</script>
diff --git a/streampark-console/streampark-console-webapp/src/views/system/team/TeamEdit.vue b/streampark-console/streampark-console-webapp/src/views/system/team/TeamEdit.vue
new file mode 100644
index 000000000..b65fcac05
--- /dev/null
+++ b/streampark-console/streampark-console-webapp/src/views/system/team/TeamEdit.vue
@@ -0,0 +1,135 @@
+<!--
+
+ 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.
+
+-->
+
+<template>
+ <a-drawer
+ :mask-closable="false"
+ width="650"
+ placement="right"
+ :closable="true"
+ :visible="visible"
+ @close="onClose"
+ style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
+ <template slot="title">
+ <a-icon type="team"/>
+ Modify Team
+ </template>
+ <a-form
+ :form="form">
+ <a-form-item
+ label="Team Name"
+ v-bind="formItemLayout">
+ <a-input
+ read-only
+ v-decorator="['teamName']"/>
+ </a-form-item>
+ <a-form-item
+ label="Description"
+ v-bind="formItemLayout">
+ <a-textarea
+ :rows="4"
+ v-decorator="[
+ 'description',
+ {rules: [
+ { max: 100, message: 'exceeds maximum length limit of 100 characters'}
+ ]}]"/>
+ </a-form-item>
+ </a-form>
+ <div
+ class="drawer-bootom-button">
+ <a-button
+ @click="onClose">
+ Cancel
+ </a-button>
+ <a-button
+ @click="handleSubmit"
+ type="primary"
+ :loading="loading">
+ Submit
+ </a-button>
+ </div>
+ </a-drawer>
+</template>
+<script>
+import {update} from '@/api/team'
+
+const formItemLayout = {
+ labelCol: {span: 4},
+ wrapperCol: {span: 18}
+}
+export default {
+ name: 'TeamEdit',
+ props: {
+ visible: {
+ type: Boolean,
+ default: false
+ }
+ },
+ data() {
+ return {
+ formItemLayout,
+ form: this.$form.createForm(this),
+ teamId: '',
+ loading: false
+ }
+ },
+
+ methods: {
+
+ onClose() {
+ this.loading = false
+ this.form.resetFields()
+ this.$emit('close')
+ },
+
+ setFormValues({...team}) {
+ this.teamId = team.id
+ const fields = ['teamName', 'description']
+ Object.keys(team).forEach((key) => {
+ if (fields.indexOf(key) !== -1) {
+ this.form.getFieldDecorator(key)
+ const obj = {}
+ obj[key] = team[key]
+ this.form.setFieldsValue(obj)
+ }
+ })
+ },
+
+ handleSubmit() {
+ this.form.validateFields((err, team) => {
+ if (!err) {
+ this.loading = true
+ const team = this.form.getFieldsValue()
+ team.id = this.teamId
+ update(team).then((r) => {
+ if (r.status === 'success') {
+ this.loading = false
+ this.$emit('success')
+ } else {
+ this.loading = false
+ }
+ }).catch(() => {
+ this.loading = false
+ })
+ }
+ })
+ }
+ }
+}
+</script>
diff --git a/streampark-console/streampark-console-webapp/src/views/system/user/User.vue b/streampark-console/streampark-console-webapp/src/views/system/user/User.vue
index eefe9ba15..45e1b96c1 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/user/User.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/user/User.vue
@@ -214,6 +214,9 @@ export default {
}, {
title: 'Nick Name',
dataIndex: 'nickName'
+ }, {
+ title: 'User Type',
+ dataIndex: 'userType'
}, {
title: 'Status',
dataIndex: 'status',
diff --git a/streampark-console/streampark-console-webapp/src/views/system/user/UserAdd.vue b/streampark-console/streampark-console-webapp/src/views/system/user/UserAdd.vue
index 06d49c937..b40feb13c 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/user/UserAdd.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/user/UserAdd.vue
@@ -27,7 +27,7 @@
:visible="visible"
style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
<template slot="title">
- <a-icon type="user" />
+ <a-icon type="user-add" />
Add User
</template>
<a-form
@@ -79,17 +79,17 @@
]}]" />
</a-form-item>
<a-form-item
- label="Role"
+ label="User Type"
v-bind="formItemLayout">
<a-select
- mode="multiple"
- :allow-clear="true"
+ mode="single"
+ :allow-clear="false"
style="width: 100%"
- v-decorator="['roleId',{rules: [{ required: true, message: 'please select role' }]}]">
+ v-decorator="['userType',{rules: [{ required: true, message: 'please select user type' }]}]">
<a-select-option
- v-for="r in roleData"
- :key="r.roleId">
- {{ r.roleName }}
+ v-for="userType in userTypeData"
+ :key="userType">
+ {{ userType }}
</a-select-option>
</a-select>
</a-form-item>
@@ -144,8 +144,7 @@
</a-drawer>
</template>
<script>
-import { list as getRole } from '@/api/role'
-import { checkUserName, post } from '@/api/user'
+import { checkUserName, post, types } from '@/api/user'
const formItemLayout = {
labelCol: { span: 4 },
@@ -162,7 +161,7 @@ export default {
data () {
return {
loading: false,
- roleData: [],
+ userTypeData: [],
formItemLayout,
form: this.$form.createForm(this),
validateStatus: '',
@@ -185,7 +184,6 @@ export default {
handleSubmit() {
this.form.validateFields((err, user) => {
if (!err && this.validateStatus === 'success') {
- user.roleId = user.roleId.join(',')
post({
...user
}).then((r) => {
@@ -207,7 +205,7 @@ export default {
this.help = 'User name should not be longer than 20 characters'
} else if (username.length < 4) {
this.validateStatus = 'error'
- this.help = 'Team name should not be less than 4 characters'
+ this.help = 'User name should not be less than 4 characters'
} else {
this.validateStatus = 'validating'
checkUserName({
@@ -231,10 +229,8 @@ export default {
watch: {
visible () {
if (this.visible) {
- getRole(
- { 'pageSize': '9999' }
- ).then((resp) => {
- this.roleData = resp.data.records
+ types().then((resp) => {
+ this.userTypeData = resp.data
})
}
}
diff --git a/streampark-console/streampark-console-webapp/src/views/system/user/UserEdit.vue b/streampark-console/streampark-console-webapp/src/views/system/user/UserEdit.vue
index 0fdc29648..f8ce8757c 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/user/UserEdit.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/user/UserEdit.vue
@@ -59,20 +59,17 @@
]" />
</a-form-item>
<a-form-item
- label="Role"
+ label="User Type"
v-bind="formItemLayout">
<a-select
- mode="multiple"
- :allow-clear="true"
+ mode="single"
+ :allow-clear="false"
style="width: 100%"
- v-decorator="[
- 'roleId',
- {rules: [{ required: true, message: 'please select role' }]}
- ]">
+ v-decorator="['userType',{rules: [{ required: true, message: 'please select user type' }]}]">
<a-select-option
- v-for="r in roleData"
- :key="r.roleId.toString()">
- {{ r.roleName }}
+ v-for="userType in userTypeData"
+ :key="userType">
+ {{ userType }}
</a-select-option>
</a-select>
</a-form-item>
@@ -135,8 +132,7 @@
</template>
<script>
import { mapState, mapMutations } from 'vuex'
-import { list as getRole } from '@/api/role'
-import { update, get } from '@/api/user'
+import { update, get, types } from '@/api/user'
const formItemLayout = {
labelCol: { span: 4 },
@@ -154,10 +150,7 @@ export default {
return {
formItemLayout,
form: this.$form.createForm(this),
- userTypeData: [
- { 'value': 1, 'name': 'internal user' },
- { 'value': 2, 'name': 'external user' }
- ],
+ userTypeData: [],
roleData: [],
userId: '',
loading: false
@@ -183,8 +176,7 @@ export default {
setFormValues ({ ...user }) {
this.userId = user.userId
- this.userType = user.userType
- const fields = ['username', 'nickName', 'email', 'status', 'sex']
+ const fields = ['username', 'nickName', 'email', 'status', 'sex', 'userType']
Object.keys(user).forEach((key) => {
if (fields.indexOf(key) !== -1) {
this.form.getFieldDecorator(key)
@@ -193,12 +185,6 @@ export default {
this.form.setFieldsValue(obj)
}
})
-
- if (user.roleId) {
- this.form.getFieldDecorator('roleId')
- const roles = user.roleId.split(',')
- this.form.setFieldsValue({ 'roleId': roles })
- }
},
handleSubmit () {
@@ -206,7 +192,6 @@ export default {
if (!err) {
this.loading = true
const user = this.form.getFieldsValue()
- user.roleId = user.roleId.join(',')
user.userId = this.userId
update(user).then((r) => {
if (r.status === 'success') {
@@ -233,8 +218,8 @@ export default {
watch: {
visible () {
if (this.visible) {
- getRole({ 'pageSize': '9999' }).then((resp) => {
- this.roleData = resp.data.records
+ types().then((resp) => {
+ this.userTypeData = resp.data
})
}
}
diff --git a/streampark-console/streampark-console-webapp/src/views/system/user/UserInfo.vue b/streampark-console/streampark-console-webapp/src/views/system/user/UserInfo.vue
index 8ba3cacb9..e1dc40bde 100644
--- a/streampark-console/streampark-console-webapp/src/views/system/user/UserInfo.vue
+++ b/streampark-console/streampark-console-webapp/src/views/system/user/UserInfo.vue
@@ -35,10 +35,9 @@
<a-icon
type="user" />User Name:{{ data.username }}
</p>
- <p
- :title="data.roleName">
+ <p>
<a-icon
- type="star" />Role:{{ data.roleName? data.roleName: '' }}
+ type="star" />User Type:{{ data.userType }}
</p>
<p>
<a-icon