darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
450 stars 172 forks source link

how to remove the text - filtered from X total entries #139

Closed neonleo closed 2 years ago

neonleo commented 2 years ago

I have create a multi-company shopping cart system, and follow the sample code to fetch the data from RestController, everything work fine, just one thing is the table show "filtered from X total entries" on left-bottom side, it is quite sensitive information , since it disclose how many orders in the database table. How I do hide it and I wonder I already used Specification to filtered on server-side, why Datatable/JPA still return the rows count to clients side? Thanks.

圖片

@RestController
public class OrderRestController {

    @Autowired
    private OrderRepository OrderRepository;

    private String shopDomain = null;

    @RequestMapping(value = "/data/orders", method = RequestMethod.POST)
    public DataTablesOutput<Order> getOrders(@Valid @RequestBody DataTablesInput input, @RequestHeader("shop_domain") String shopDomain) {

        JsonNode shopNode = null;
        this.shopDomain = shopDomain;
        return OrderRepository.findAll(input , new ExcludeDeletedAndShopDomainSpecification());
    }

    private class ExcludeDeletedAndShopDomainSpecification implements Specification<Order> {

        @Override
        public Predicate toPredicate(Root<Order> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {

            final OrderRestController outer = OrderRestController.this;

            Predicate predicateForShopDomain = criteriaBuilder.equal(root.get("shopDomain"), outer.shopDomain);
            Predicate predicateForDeleted = criteriaBuilder.notEqual(root.get("deleted"), 1);
            Predicate predicateForAll = criteriaBuilder.and(predicateForShopDomain, predicateForDeleted);
            return predicateForAll;
        }
    }
}
neonleo commented 2 years ago

Sorry for duplicate question, and this question has been answered, please refer to this post