Skip to content

Commit

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

* getTeamId from teamService

* code format

---------

Co-authored-by: hechao <[email protected]>
  • Loading branch information
ShawHee and hechao authored Aug 9, 2024
1 parent 51dc66c commit ed19587
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,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 @@ -34,4 +34,6 @@ public interface RoleService extends IService<Role> {
void deleteRole(Long roleId);

void updateRole(Role role);

Role getSysDefaultRole();
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,10 @@ private void setRoleMenus(Role role, String[] menuIds) {
this.roleMenuMapper.insert(rm);
});
}

@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 @@ -23,10 +23,13 @@
import org.apache.streampark.console.base.mybatis.pager.MybatisPager;
import org.apache.streampark.console.base.util.ShaHashUtils;
import org.apache.streampark.console.system.authentication.JWTToken;
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 @@ -63,6 +66,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us

@Autowired private TeamService teamService;

@Autowired private RoleService roleService;

@Override
public User findByName(String username) {
LambdaQueryWrapper<User> queryWrapper =
Expand Down Expand Up @@ -104,6 +109,14 @@ public void createUser(User user) {
user.setLastTeamId(teamService.getSysDefaultTeam().getId());
user.setPassword(password);
save(user);
// set team member
Member member = new Member();
member.setUserName(user.getUsername());
member.setTeamId(teamService.getSysDefaultTeam().getId());
Role role = roleService.getSysDefaultRole();
member.setRoleId(role.getRoleId());
member.setRoleName(role.getRoleName());
memberService.createMember(member);
}

@Override
Expand Down

0 comments on commit ed19587

Please sign in to comment.