package com.mingzuozhibi.modules.core;

import com.mingzuozhibi.commons.base.BaseKeys.Name;
import com.mingzuozhibi.commons.base.BaseKeys.Type;
import com.mingzuozhibi.commons.base.PageController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class MessageController extends PageController {

    @Autowired
    private MessageRepository messageRepository;

    @GetMapping(value = "/api/messages/{name}", produces = MEDIA_TYPE)
    public String findAll(@PathVariable Name name,
                          @RequestParam(required = false) String search,
                          @RequestParam(required = false) List<Type> types,
                          @RequestParam(defaultValue = "1") int page,
                          @RequestParam(defaultValue = "20") int size) {

        PageRequest pageRequest = PageRequest.of(page - 1, size, Sort.by(Order.desc("id")));
        return pageResult(messageRepository.findBy(name, types, search, pageRequest));

    }

}

@@ -296,64 +296,9 @@
 ain.
-PageRequest;%0Aimport org.springframework.data.domain.Sort
+*
 ;%0Aim
@@ -1079,26 +1079,33 @@
     
-return pageResult(
+Page%3CMessage%3E messages = 
 mess
@@ -1158,16 +1158,52 @@
 Request)
+;%0A        return pageResult(messages
 );%0A%0A    

Format some code