[java]代码库
package com.wyl.vue.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wyl.vue.dao.AdminDao;
import com.wyl.vue.model.Admin;
@RestController
public class AdminController {
@Autowired
private AdminDao adminDao;
@GetMapping(value = "/find")
public Map<String, Object> find(int pageNumber,int pageSize) {
//封装分页对象
Pageable pageable = new PageRequest(pageNumber-1, pageSize, Sort.Direction.ASC, "id");
//调用jpa的sql
Page<Admin> pageAdmin = adminDao.findAll(pageable);
//总数
Long size = pageAdmin.getTotalElements();
//列表
List<Admin> content = pageAdmin.getContent();
Map<String, Object> map = new HashMap<>();
map.put("size", size);
map.put("list", content);
return map;
}
@PutMapping(value = "/save")
public void saveAdmin(Long id) {
}
}
ps:(自己可以把代码放到nginx里面跑,就行了,配个代理)
[代码运行效果截图]
[源代码打包下载]
初级程序员
by: 7VCE 发表于:2019-07-16 20:04:24 顶(2) | 踩(0) 回复
没写完就拿出来骗分吗?
回复评论