Skip to content

Commit

Permalink
[Improve] default team member improvement (#3953)
Browse files Browse the repository at this point in the history
* set default team member

* getTeamId from teamService

---------

Co-authored-by: hechao <[email protected]>
  • Loading branch information
ShawHee and hechao authored Aug 9, 2024
1 parent ab5cc1f commit e4cc7ef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ public interface RoleService extends IService<Role> {
* @param role Role
*/
void updateRole(Role role);

/**
* Get the Default Role
*
*/
Role getSysDefaultRole();
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@ private void updateRoleMenus(Role role, String[] menuIds) {
}
roleMenuService.saveBatch(roleMenus);
}

@Override
public Role getSysDefaultRole() {
return baseMapper.selectOne(new LambdaQueryWrapper<Role>().eq(Role::getRoleId, Constant.DEFAULT_ROLE_ID));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -85,6 +88,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Autowired
private TeamService teamService;

@Autowired
private RoleService roleService;

@Override
public User getByUsername(String username) {
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<User>().eq(User::getUsername, username);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e4cc7ef

Please sign in to comment.