Browse Source

Added the ability for administrators to view all resource by type

pull/2/head
lgcareer 5 years ago
parent
commit
edd65e74e1
  1. 7
      escheduler-api/src/main/java/cn/escheduler/api/service/ResourcesService.java
  2. 18
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ResourceMapper.java
  3. 15
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ResourceMapperProvider.java

7
escheduler-api/src/main/java/cn/escheduler/api/service/ResourcesService.java

@ -369,7 +369,12 @@ public class ResourcesService extends BaseService {
public Map<String, Object> queryResourceList(User loginUser, ResourceType type) {
Map<String, Object> result = new HashMap<>(5);
List<Resource> resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), type.ordinal());
List<Resource> resourceList;
if(isAdmin(loginUser)){
resourceList = resourcesMapper.listAllResourceByType(type.ordinal());
}else{
resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), type.ordinal());
}
result.put(Constants.DATA_LIST, resourceList);
putMsg(result,Status.SUCCESS);

18
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ResourceMapper.java

@ -274,5 +274,21 @@ public interface ResourceMapper {
@SelectProvider(type = ResourceMapperProvider.class, method = "queryTenantCodeByResourceName")
String queryTenantCodeByResourceName(@Param("resName") String resName);
/**
* query resource list that the appointed user has permission
* @param type
* @return
*/
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
@Result(property = "size", column = "size", javaType = Long.class, jdbcType = JdbcType.BIGINT),
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = ResourceMapperProvider.class, method = "listAllResourceByType")
List<Resource> listAllResourceByType(@Param("type") Integer type);
}

15
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ResourceMapperProvider.java

@ -295,4 +295,19 @@ public class ResourceMapperProvider {
WHERE("type = #{type} and user_id = #{userId}");
}}.toString();
}
/**
* list all resource by type
*
* @param parameter
* @return
*/
public String listAllResourceByType(Map<String, Object> parameter) {
return new SQL() {{
SELECT("*");
FROM(TABLE_NAME);
WHERE("type = #{type}");
}}.toString();
}
}

Loading…
Cancel
Save