Unverified Commit 373a2255 authored by lgcareer's avatar lgcareer Committed by GitHub
Browse files

Merge pull request #526 from lgcareer/dev-1.1.0

1.Added the ability for administrators to view all resource by type
2.Remove restrictions on administrators
parents 527291c1 c9120c34
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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);

+17 −1
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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();
  }

}
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
      </div>
    </div>
    <div class="clearfix list">
      <x-button type="info"  style="margin-left:20px" shape="circle" :loading="spinnerLoading" @click="preview()" v-ps="['GENERAL_USER']">执行时间</x-button>
      <x-button type="info"  style="margin-left:20px" shape="circle" :loading="spinnerLoading" @click="preview()">执行时间</x-button>
      <div class="text">
        {{$t('Timing')}}
      </div>
@@ -136,7 +136,7 @@
    </div>
    <div class="submit">
      <x-button type="text" @click="close()"> {{$t('Cancel')}} </x-button>
      <x-button type="primary" shape="circle" :loading="spinnerLoading" @click="ok()" v-ps="['GENERAL_USER']">{{spinnerLoading ? 'Loading...' : (item.crontab ? $t('Edit') : $t('Create'))}} </x-button>
      <x-button type="primary" shape="circle" :loading="spinnerLoading" @click="ok()">{{spinnerLoading ? 'Loading...' : (item.crontab ? $t('Edit') : $t('Create'))}} </x-button>
    </div>
  </div>
</template>