Skip to content

Commit

Permalink
refactor($AuthCenter): remove useless API
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
Johnny Miller (锺俊) committed Dec 29, 2020
1 parent aec0662 commit 062ede6
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.jmsoftware.maf.common.bean.ResponseBodyBean;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByUserIdResponse;
import com.jmsoftware.maf.common.domain.authcenter.role.GetRoleListByUserIdResponse;
import com.jmsoftware.maf.common.domain.authcenter.security.ParseJwtPayload;
import com.jmsoftware.maf.common.domain.authcenter.security.ParseJwtResponse;
Expand Down Expand Up @@ -47,15 +46,6 @@ public interface AuthCenterRemoteApi {
@GetMapping("/role-remote-api/roles/{userId}")
Mono<ResponseBodyBean<GetRoleListByUserIdResponse>> getRoleListByUserId(@PathVariable Long userId);

/**
* Get permission list by user id response body bean.
*
* @param userId the user id
* @return the response body bean
*/
@GetMapping("/permission-remote-api/permissions/{userId}")
Mono<ResponseBodyBean<GetPermissionListByUserIdResponse>> getPermissionListByUserId(@PathVariable Long userId);

/**
* Get permission list by role id list
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import com.jmsoftware.maf.common.bean.ResponseBodyBean;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListPayload;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByUserIdResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -35,11 +33,4 @@ public class PermissionRemoteApiController {
public ResponseBodyBean<GetPermissionListByRoleIdListResponse> getPermissionListByRoleIdList(@Valid GetPermissionListByRoleIdListPayload payload) {
return ResponseBodyBean.ofSuccess(permissionService.getPermissionListByRoleIdList(payload));
}

@GetMapping("/permissions/{userId}")
@ApiOperation(value = "Get permission list by user id", notes = "Get permission list by user id")
public ResponseBodyBean<GetPermissionListByUserIdResponse> getPermissionListByUserId(@PathVariable Long userId) {
// auth-center will respond /** for role "admin"
return ResponseBodyBean.ofSuccess(permissionService.getPermissionListByUserId(userId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jmsoftware.maf.authcenter.permission.entity.PermissionPersistence;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

Expand All @@ -24,12 +23,4 @@ public interface PermissionMapper extends BaseMapper<PermissionPersistence> {
* @return the list
*/
List<PermissionPersistence> selectPermissionListByRoleIdList(List<Long> roleIdList);

/**
* Select permission list by user id list.
*
* @param userId the user id
* @return the list
*/
List<PermissionPersistence> selectPermissionListByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import com.jmsoftware.maf.authcenter.permission.entity.PermissionPersistence;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListPayload;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByUserIdResponse;
import com.jmsoftware.maf.common.exception.BusinessException;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
Expand Down Expand Up @@ -40,22 +38,6 @@ public interface PermissionService extends IService<PermissionPersistence> {
*/
List<PermissionPersistence> getPermissionListByRoleIdList(@NotEmpty List<Long> roleIdList);

/**
* Gets permission list by user id.
*
* @param userId the user id
* @return the permission list by user id
*/
GetPermissionListByUserIdResponse getPermissionListByUserId(@NotNull Long userId);

/**
* Gets permission list by user id.
*
* @param userId the user id
* @return the permission list by user id
*/
List<PermissionPersistence> getPermissionPersistenceListByUserId(@NotNull Long userId);

/**
* Gets services info.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.jmsoftware.maf.common.bean.ResponseBodyBean;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListPayload;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse;
import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByUserIdResponse;
import com.jmsoftware.maf.common.domain.authcenter.permission.PermissionType;
import com.jmsoftware.maf.common.domain.springbootstarter.HttpApiResourcesResponse;
import com.jmsoftware.maf.common.exception.BusinessException;
Expand All @@ -27,7 +26,6 @@
import org.springframework.web.client.RestTemplate;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -80,23 +78,6 @@ public List<PermissionPersistence> getPermissionListByRoleIdList(@NonNull List<L
return this.getBaseMapper().selectPermissionListByRoleIdList(roleIdList);
}

@Override
public GetPermissionListByUserIdResponse getPermissionListByUserId(@NotNull Long userId) {
val permissionList = this.getPermissionPersistenceListByUserId(userId);
val response = new GetPermissionListByUserIdResponse();
permissionList.forEach(permissionPersistence -> {
val permission = new GetPermissionListByUserIdResponse.Permission();
BeanUtil.copyProperties(permissionPersistence, permission);
response.getPermissionList().add(permission);
});
return response;
}

@Override
public List<PermissionPersistence> getPermissionPersistenceListByUserId(@NotNull Long userId) {
return this.getBaseMapper().selectPermissionListByUserId(userId);
}

@Override
public GetServicesInfoResponse getServicesInfo() throws BusinessException {
val serviceIdList = discoveryClient.getServices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,4 @@
#{item}
</foreach>
</select>

<select id="selectPermissionListByUserId" resultMap="BaseResultMap">
SELECT permission.id,
permission.url,
permission.type,
permission.permission_expression AS permissionExpression,
permission.method
FROM permission
LEFT JOIN role_permission ON permission.id = role_permission.permission_id
LEFT JOIN role ON role_permission.role_id = role.id
LEFT JOIN user_role ON role.id = user_role.role_id
LEFT JOIN user ON user_role.user_id = user.id
WHERE user.id = #{userId}
</select>
</mapper>

This file was deleted.

0 comments on commit 062ede6

Please sign in to comment.