TRX 1 年之前
父节点
当前提交
124170758d

+ 8 - 0
centers/AuthCenter/AuthClient/src/main/java/com/github/microservice/auth/client/service/AuthResourcesNameService.java

@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.util.List;
+
 @FeignClient(name = "authserver/manager/authResourcesName")
 public interface AuthResourcesNameService {
 
@@ -29,4 +31,10 @@ public interface AuthResourcesNameService {
             @Parameter(name = "authType", description = "权限类型", example = "Enterprise") @RequestParam("authType") AuthType authType,
             @Parameter(hidden = true) @PageableDefault Pageable pageable
     );
+
+    @Operation(summary = "分页查询所有资源", description = "分页查询所有资源")
+    @RequestMapping(value = "getAll", consumes = {MediaType.ALL_VALUE}, method = RequestMethod.POST)
+    ResultContent<List<AuthResourcesNameModel>> getAll(
+            @Parameter(name = "authType", description = "权限类型", example = "Enterprise") @RequestParam("authType") AuthType authType
+    );
 }

+ 4 - 0
centers/AuthCenter/AuthServer/src/main/java/com/github/microservice/auth/server/core/dao/AuthResourcesNameDao.java

@@ -7,6 +7,8 @@ import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
+import java.util.List;
+
 public interface AuthResourcesNameDao extends MongoDao<AuthResourcesName>, AuthResourcesNameDaoExtend {
 
 
@@ -18,5 +20,7 @@ public interface AuthResourcesNameDao extends MongoDao<AuthResourcesName>, AuthR
      * @return
      */
     Page<AuthResourcesName> findByAuthType(AuthType authType, Pageable pageable);
+    
+    List<AuthResourcesName> findByAuthTypeOrderByCreateTime(AuthType authType);
 
 }

+ 7 - 0
centers/AuthCenter/AuthServer/src/main/java/com/github/microservice/auth/server/core/service/local/AuthResourcesNameServiceImpl.java

@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
 import java.util.Arrays;
+import java.util.List;
 import java.util.stream.Collectors;
 
 @Service
@@ -50,6 +51,12 @@ public class AuthResourcesNameServiceImpl implements AuthResourcesNameService {
         }));
     }
 
+    @Override
+    public ResultContent<List<AuthResourcesNameModel>> getAll(AuthType authType) {
+        List<AuthResourcesName> list = this.authResourcesNameDao.findByAuthTypeOrderByCreateTime(authType);
+        return ResultContent.buildContent(list.stream().map(this::toModel).collect(Collectors.toList()));
+    }
+
     private AuthResourcesNameModel toModel(AuthResourcesName authResourcesName) {
         AuthResourcesNameModel authResourcesNameModel = new AuthResourcesNameModel();
         BeanUtils.copyProperties(authResourcesName, authResourcesNameModel);