package com.boying.controller;
|
|
import com.boying.common.BaseController;
|
import com.boying.entity.Park;
|
import com.boying.service.ParkService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Sort;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
|
@RestController
|
@RequestMapping("park")
|
public class ParkController extends BaseController {
|
|
@Autowired
|
private ParkService parkService;
|
|
@PostMapping("findPage")
|
public Object findPage(int page,int pageSize) {
|
Pageable pageable = PageRequest.of(page-1,pageSize, Sort.Direction.DESC,"id");
|
Page<Park> pages = parkService.findPage(pageable);
|
return success("",pages);
|
}
|
|
@PostMapping("save")
|
public Object save(Park park) {
|
parkService.save(park);
|
return success("保存成功");
|
}
|
|
@PostMapping("delete")
|
public Object delete(Long id) {
|
parkService.delete(id);
|
return success("删除成功");
|
}
|
|
@PostMapping("findAll")
|
public Object findAll() {
|
List all = parkService.findAll();
|
return success("删除成功",all);
|
}
|
}
|