2025年3月14日17:08:55
parent
182f6b97e9
commit
d313774801
|
|
@ -4,7 +4,12 @@ import com.zhangmeng.online.exam.dao.QuestionDao;
|
|||
import com.zhangmeng.online.exam.dto.Result;
|
||||
import com.zhangmeng.online.exam.entity.Permission;
|
||||
import com.zhangmeng.online.exam.entity.Question;
|
||||
import com.zhangmeng.online.exam.utils.PageUtils;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
|
@ -26,8 +31,10 @@ public class QuestionController {
|
|||
private QuestionDao questionDao;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Result list() {
|
||||
List<Question> list = questionDao.findAll();
|
||||
public Result list(Integer pageNum, Integer pageSize) {
|
||||
Pageable pageable = PageRequest.of(PageUtils.getPageNum(pageNum), pageSize, Sort.Direction.DESC, "addTime");
|
||||
Page<Question> all = questionDao.findAll(pageable);
|
||||
List<Question> list = all.getContent();
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (Question question : list) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
|
@ -37,7 +44,7 @@ public class QuestionController {
|
|||
map.put("subject", question.getSubject().getName());
|
||||
resultList.add(map);
|
||||
}
|
||||
return Result.success(resultList);
|
||||
return Result.success(pageNum, pageSize, all.getTotalElements(), resultList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,15 @@ package com.zhangmeng.online.exam.controller;
|
|||
|
||||
import com.zhangmeng.online.exam.dao.RoleDao;
|
||||
import com.zhangmeng.online.exam.dto.Result;
|
||||
import com.zhangmeng.online.exam.entity.Question;
|
||||
import com.zhangmeng.online.exam.entity.Role;
|
||||
import com.zhangmeng.online.exam.entity.User;
|
||||
import com.zhangmeng.online.exam.utils.PageUtils;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
|
@ -26,8 +32,9 @@ public class RoleController {
|
|||
private RoleDao roleDao;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Result list() {
|
||||
|
||||
public Result list(Integer pageNum, Integer pageSize) {
|
||||
Pageable pageable = PageRequest.of(PageUtils.getPageNum(pageNum), pageSize, Sort.Direction.DESC, "addTime");
|
||||
Page<Role> all = roleDao.findAll(pageable);
|
||||
List<Role> list = roleDao.findAll();
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (Role role : list) {
|
||||
|
|
@ -38,7 +45,7 @@ public class RoleController {
|
|||
map.put("type_name", role.getType().name());
|
||||
resultList.add(map);
|
||||
}
|
||||
return Result.success(resultList);
|
||||
return Result.success(pageNum, pageSize, all.getTotalElements(), resultList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,12 @@ import com.zhangmeng.online.exam.dto.Menu;
|
|||
import com.zhangmeng.online.exam.dto.Result;
|
||||
import com.zhangmeng.online.exam.entity.*;
|
||||
import com.zhangmeng.online.exam.entity.User;
|
||||
import com.zhangmeng.online.exam.utils.PageUtils;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -39,7 +44,10 @@ public class UserController {
|
|||
|
||||
@GetMapping("/list")
|
||||
public Result userList(Integer pageNum,Integer pageSize) {
|
||||
List<User> list = userDao.findAll();
|
||||
|
||||
Pageable pageable = PageRequest.of(PageUtils.getPageNum(pageNum), pageSize, Sort.Direction.DESC, "addTime");
|
||||
Page<User> all = userDao.findAll(pageable);
|
||||
List<User> list = all.getContent();
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (User user : list) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
|
@ -49,7 +57,7 @@ public class UserController {
|
|||
map.put("phone", user.getPhone());
|
||||
resultList.add(map);
|
||||
}
|
||||
return Result.success(resultList);
|
||||
return Result.success(pageNum, pageSize, all.getTotalElements(), resultList);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue