Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve] Improve streampark-console system package module service query method name base on [3.1 Naming Style] #3304

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ public RestResponse permissionAction(ProceedingJoinPoint joinPoint) throws Throw
break;
case TEAM:
ApiAlertException.throwIfTrue(
memberService.findByUserName(paramId, currentUser.getUsername()) == null,
memberService.getByTeamIdUserName(paramId, currentUser.getUsername()) == null,
"Permission denied, only user belongs to this team can access this permission");
break;
case APP:
Application app = applicationManageService.getById(paramId);
ApiAlertException.throwIfTrue(app == null, "Invalid operation, application is null");
ApiAlertException.throwIfTrue(
memberService.findByUserName(app.getTeamId(), currentUser.getUsername()) == null,
memberService.getByTeamIdUserName(app.getTeamId(), currentUser.getUsername()) == null,
"Permission denied, only user belongs to this team can access this permission");
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection token) {
SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();

// Get user permission set
Set<String> permissionSet = userService.getPermissions(userId, null);
Set<String> permissionSet = userService.listPermissions(userId, null);
simpleAuthorizationInfo.setStringPermissions(permissionSet);
return simpleAuthorizationInfo;
}
Expand All @@ -85,7 +85,7 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authent
throw new AuthenticationException("Token verification failed");
}
// Query user information by username
User user = userService.findByName(username);
User user = userService.getByUsername(username);

if (user == null) {
throw new AuthenticationException("ERROR Incorrect username or password!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public RestResponse verifyToken() {
@RequiresPermissions("token:view")
public RestResponse tokensList(
RestRequest restRequest, @Parameter(hidden = true) AccessToken accessToken) {
IPage<AccessToken> accessTokens = accessTokenService.findAccessTokens(accessToken, restRequest);
IPage<AccessToken> accessTokens = accessTokenService.getPage(accessToken, restRequest);
return RestResponse.success(accessTokens);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,28 @@ public class MemberController {
@Operation(summary = "List members")
@PostMapping("list")
public RestResponse memberList(RestRequest restRequest, Member member) {
IPage<Member> userList = memberService.findUsers(member, restRequest);
IPage<Member> userList = memberService.getPage(member, restRequest);
return RestResponse.success(userList);
}

@Operation(summary = "List candidate users")
@PostMapping("candidateUsers")
public RestResponse candidateUsers(Long teamId) {
List<User> userList = memberService.findCandidateUsers(teamId);
List<User> userList = memberService.listUsersNotInTeam(teamId);
return RestResponse.success(userList);
}

@Operation(summary = "List teams")
@PostMapping("teams")
public RestResponse listTeams(Long userId) {
List<Team> teamList = memberService.findUserTeams(userId);
List<Team> teamList = memberService.listTeamsByUserId(userId);
return RestResponse.success(teamList);
}

@Operation(summary = "Check the username")
@PostMapping("check/user")
public RestResponse check(@NotBlank(message = "{required}") Long teamId, String userName) {
Member result = this.memberService.findByUserName(teamId, userName);
Member result = this.memberService.getByTeamIdUserName(teamId, userName);
return RestResponse.success(result == null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ public class MenuController {
@PostMapping("router")
public RestResponse getUserRouters(Long teamId) {
// TODO The teamId is required, get routers should be called after choose teamId.
List<VueRouter<Menu>> routers =
this.menuService.getUserRouters(commonService.getUserId(), teamId);
List<VueRouter<Menu>> routers = this.menuService.listRouters(commonService.getUserId(), teamId);
return RestResponse.success(routers);
}

@Operation(summary = "List menus")
@PostMapping("list")
@RequiresPermissions("menu:view")
public RestResponse menuList(Menu menu) {
Map<String, Object> maps = this.menuService.findMenus(menu);
Map<String, Object> maps = this.menuService.listMenuMap(menu);
return RestResponse.success(maps);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ public class RoleController {
@PostMapping("list")
@RequiresPermissions("role:view")
public RestResponse roleList(RestRequest restRequest, Role role) {
IPage<Role> roleList = roleService.findRoles(role, restRequest);
IPage<Role> roleList = roleService.getPage(role, restRequest);
return RestResponse.success(roleList);
}

@Operation(summary = "Check the role name")
@PostMapping("check/name")
public RestResponse checkRoleName(@NotBlank(message = "{required}") String roleName) {
Role result = this.roleService.findByName(roleName);
Role result = this.roleService.getByName(roleName);
return RestResponse.success(result == null);
}

@Operation(summary = "List role menus")
@PostMapping("menu")
public RestResponse getRoleMenus(@NotBlank(message = "{required}") String roleId) {
List<RoleMenu> list = this.roleMenuServie.getByRoleId(roleId);
List<RoleMenu> list = this.roleMenuServie.listByRoleId(roleId);
List<String> roleMenus =
list.stream()
.map(roleMenu -> String.valueOf(roleMenu.getMenuId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public class TeamController {
@Operation(summary = "List teams")
@PostMapping("list")
public RestResponse teamList(RestRequest restRequest, Team team) {
IPage<Team> teamList = teamService.findTeams(team, restRequest);
IPage<Team> teamList = teamService.getPage(team, restRequest);
return RestResponse.success(teamList);
}

@Operation(summary = "Check the team name")
@PostMapping("check/name")
public RestResponse checkTeamName(@NotBlank(message = "{required}") String teamName) {
Team result = this.teamService.findByName(teamName);
Team result = this.teamService.getByName(teamName);
return RestResponse.success(result == null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class UserController {
value = {"user:view", "app:view"},
logical = Logical.OR)
public RestResponse userList(RestRequest restRequest, User user) {
IPage<User> userList = userService.findUserDetail(user, restRequest);
IPage<User> userList = userService.getPage(user, restRequest);
return RestResponse.success(userList);
}

Expand Down Expand Up @@ -100,14 +100,14 @@ public RestResponse transferResource(Long userId, Long targetUserId) {
@Operation(summary = "List without token users")
@PostMapping("getNoTokenUser")
public RestResponse getNoTokenUser() {
List<User> userList = this.userService.getNoTokenUser();
List<User> userList = this.userService.listNoTokenUser();
return RestResponse.success(userList);
}

@Operation(summary = "Check the username")
@PostMapping("check/name")
public RestResponse checkUserName(@NotBlank(message = "{required}") String username) {
boolean result = this.userService.findByName(username) == null;
boolean result = this.userService.getByUsername(username) == null;
return RestResponse.success(result);
}

Expand Down Expand Up @@ -161,7 +161,7 @@ public RestResponse setTeam(Long teamId) {
@Operation(summary = "List the team users")
@PostMapping("appOwners")
public RestResponse appOwners(Long teamId) {
List<User> userList = userService.findByAppOwner(teamId);
List<User> userList = userService.listByTeamId(teamId);
userList.forEach(User::dataMasking);
return RestResponse.success(userList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public User authenticate(String username, String password, String loginType) thr
}

private User passwordAuthenticate(String username, String password) {
User user = usersService.findByName(username);
User user = usersService.getByUsername(username);

ApiAlertException.throwIfNull(user, String.format("User [%s] does not exist", username));

Expand All @@ -81,7 +81,7 @@ private User ldapAuthenticate(String username, String password) throws Exception
return null;
}
// check if user exist
User user = usersService.findByName(username);
User user = usersService.getByUsername(username);

if (user != null) {
ApiAlertException.throwIfTrue(
Expand All @@ -95,7 +95,7 @@ private User ldapAuthenticate(String username, String password) throws Exception

private User ssoAuthenticate(String username) throws Exception {
// check if user exist
User user = usersService.findByName(username);
User user = usersService.getByUsername(username);

if (user != null) {
ApiAlertException.throwIfTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RestResponse generateToken(Long userId, String expireTime, String description)

boolean deleteToken(Long id);

IPage<AccessToken> findAccessTokens(AccessToken tokenParam, RestRequest request);
IPage<AccessToken> getPage(AccessToken tokenParam, RestRequest request);

boolean checkTokenEffective(Long userId, String token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public interface MemberService extends IService<Member> {

void deleteByTeamId(Long teamId);

IPage<Member> findUsers(Member member, RestRequest request);
IPage<Member> getPage(Member member, RestRequest request);

List<User> findCandidateUsers(Long teamId);
List<User> listUsersNotInTeam(Long teamId);

List<Team> findUserTeams(Long userId);
List<Team> listTeamsByUserId(Long userId);

Member findByUserName(Long teamId, String userName);
Member getByTeamIdUserName(Long teamId, String userName);

List<Long> findUserIdsByRoleId(Long roleId);
List<Long> listUserIdsByRoleId(Long roleId);

void createMember(Member member);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public interface MenuService extends IService<Menu> {
* @param teamId team id. If it's null, will find permissions from all teams.
* @return permissions
*/
List<String> findUserPermissions(Long userId, Long teamId);
List<String> listPermissions(Long userId, Long teamId);

List<Menu> findUserMenus(Long userId, Long teamId);
List<Menu> listMenus(Long userId, Long teamId);

Map<String, Object> findMenus(Menu menu);
Map<String, Object> listMenuMap(Menu menu);

List<VueRouter<Menu>> getUserRouters(Long userId, Long teamId);
List<VueRouter<Menu>> listRouters(Long userId, Long teamId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface RoleMenuServie extends IService<RoleMenu> {

void deleteByMenuId(String[] menuIds);

List<RoleMenu> getByRoleId(String roleId);
List<RoleMenu> listByRoleId(String roleId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

public interface RoleService extends IService<Role> {

IPage<Role> findRoles(Role role, RestRequest request);
IPage<Role> getPage(Role role, RestRequest request);

Role findByName(String roleName);
Role getByName(String roleName);

void createRole(Role role);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

public interface TeamService extends IService<Team> {

IPage<Team> findTeams(Team team, RestRequest request);
IPage<Team> getPage(Team team, RestRequest request);

Team findByName(String teamName);
Team getByName(String teamName);

void createTeam(Team team);

void deleteTeam(Long teamId);

void updateTeam(Team team);

List<Team> findUserTeams(Long userId);
List<Team> listByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface UserService extends IService<User> {
* @param username username
* @return user
*/
User findByName(String username);
User getByUsername(String username);

/**
* find uer detail, contains basic info, role, department
Expand All @@ -48,7 +48,7 @@ public interface UserService extends IService<User> {
* @param restRequest queryRequest
* @return IPage
*/
IPage<User> findUserDetail(User user, RestRequest restRequest);
IPage<User> getPage(User user, RestRequest restRequest);

/**
* update login time
Expand Down Expand Up @@ -94,9 +94,9 @@ public interface UserService extends IService<User> {
* @param teamId team id. If it's null, will find permissions from all teams.
* @return permissions
*/
Set<String> getPermissions(Long userId, @Nullable Long teamId);
Set<String> listPermissions(Long userId, @Nullable Long teamId);

List<User> getNoTokenUser();
List<User> listNoTokenUser();

void setLastTeam(Long teamId, Long userId);

Expand All @@ -106,7 +106,7 @@ public interface UserService extends IService<User> {

void fillInTeam(User user);

List<User> findByAppOwner(Long teamId);
List<User> listByTeamId(Long teamId);

Map<String, Object> generateFrontendUserInfo(User user, Long teamId, JWTToken token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public boolean deleteToken(Long id) {
}

@Override
public IPage<AccessToken> findAccessTokens(AccessToken tokenParam, RestRequest request) {
public IPage<AccessToken> getPage(AccessToken tokenParam, RestRequest request) {
Page<AccessToken> page = new MybatisPager<AccessToken>().getDefaultPage(request);
this.baseMapper.selectPage(page, tokenParam);
List<AccessToken> records = page.getRecords();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void deleteByTeamId(Long teamId) {
}

@Override
public IPage<Member> findUsers(Member member, RestRequest request) {
public IPage<Member> getPage(Member member, RestRequest request) {
ApiAlertException.throwIfNull(member.getTeamId(), "The team id is required.");
Page<Member> page = new Page<>();
page.setCurrent(request.getPageNum());
Expand All @@ -83,18 +83,18 @@ public IPage<Member> findUsers(Member member, RestRequest request) {
}

@Override
public List<User> findCandidateUsers(Long teamId) {
public List<User> listUsersNotInTeam(Long teamId) {
return baseMapper.selectUsersNotInTeam(teamId);
}

@Override
public List<Team> findUserTeams(Long userId) {
return teamService.findUserTeams(userId);
public List<Team> listTeamsByUserId(Long userId) {
return teamService.listByUserId(userId);
}

@Override
public Member findByUserName(Long teamId, String userName) {
User user = userService.findByName(userName);
public Member getByTeamIdUserName(Long teamId, String userName) {
User user = userService.getByUsername(userName);
if (user == null) {
return null;
}
Expand All @@ -111,7 +111,7 @@ private Member findByUserId(Long teamId, Long userId) {
}

@Override
public List<Long> findUserIdsByRoleId(Long roleId) {
public List<Long> listUserIdsByRoleId(Long roleId) {
LambdaQueryWrapper<Member> queryWrapper =
new LambdaQueryWrapper<Member>().eq(Member::getRoleId, roleId);
List<Member> list = baseMapper.selectList(queryWrapper);
Expand All @@ -121,7 +121,7 @@ public List<Long> findUserIdsByRoleId(Long roleId) {
@Override
public void createMember(Member member) {
User user =
Optional.ofNullable(userService.findByName(member.getUserName()))
Optional.ofNullable(userService.getByUsername(member.getUserName()))
.orElseThrow(
() ->
new ApiAlertException(
Expand Down
Loading
Loading