diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java index 03a211c640..2231f7062a 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/Constant.java @@ -32,4 +32,6 @@ public class Constant { public static final String APP_DETAIL_MENU_ID = "100018"; public static final Long DEFAULT_TEAM_ID = 100000L; + + public static final Long DEFAULT_ROLE_ID = 100001L; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleService.java index 0a9e5f3316..1ad8eca0b0 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleService.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/RoleService.java @@ -62,4 +62,10 @@ public interface RoleService extends IService { * @param role Role */ void updateRole(Role role); + + /** + * Get the Default Role + * + */ + Role getSysDefaultRole(); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java index d4c2af83bd..659777d4cb 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 @@ -123,4 +123,9 @@ private void updateRoleMenus(Role role, String[] menuIds) { } roleMenuService.saveBatch(roleMenus); } + + @Override + public Role getSysDefaultRole() { + return baseMapper.selectOne(new LambdaQueryWrapper().eq(Role::getRoleId, Constant.DEFAULT_ROLE_ID)); + } } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java index 3e03e23d43..471cbbb1c8 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 @@ -31,10 +31,13 @@ import org.apache.streampark.console.core.service.application.ApplicationManageService; import org.apache.streampark.console.system.authentication.JWTToken; import org.apache.streampark.console.system.authentication.JWTUtil; +import org.apache.streampark.console.system.entity.Member; +import org.apache.streampark.console.system.entity.Role; import org.apache.streampark.console.system.entity.User; import org.apache.streampark.console.system.mapper.UserMapper; import org.apache.streampark.console.system.service.MemberService; import org.apache.streampark.console.system.service.MenuService; +import org.apache.streampark.console.system.service.RoleService; import org.apache.streampark.console.system.service.TeamService; import org.apache.streampark.console.system.service.UserService; @@ -85,6 +88,9 @@ public class UserServiceImpl extends ServiceImpl implements Us @Autowired private TeamService teamService; + @Autowired + private RoleService roleService; + @Override public User getByUsername(String username) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(User::getUsername, username); @@ -121,6 +127,14 @@ public void createUser(User user) { user.setPassword(password); } save(user); + // set team member + Member member = new Member(); + member.setUserName(user.getUsername()); + member.setTeamId(teamService.getSysDefaultTeam().getId()); + Role role = roleService.getSysDefaultRole(); + member.setRoleId(role.getRoleId()); + member.setRoleName(role.getRoleName()); + memberService.createMember(member); } @Override