|
| 1 | +package com.study.controller; |
| 2 | + |
| 3 | +import com.github.pagehelper.PageInfo; |
| 4 | +import com.study.model.Role; |
| 5 | +import com.study.model.User; |
| 6 | +import com.study.service.RoleService; |
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 8 | +import org.springframework.web.bind.annotation.RequestParam; |
| 9 | +import org.springframework.web.bind.annotation.RestController; |
| 10 | + |
| 11 | +import javax.annotation.Resource; |
| 12 | +import java.util.HashMap; |
| 13 | +import java.util.List; |
| 14 | +import java.util.Map; |
| 15 | + |
| 16 | +/** |
| 17 | + * Created by yangqj on 2017年4月26日. |
| 18 | + */ |
| 19 | +@RestController |
| 20 | +@RequestMapping("/roles") |
| 21 | +public class RoleController { |
| 22 | + @Resource |
| 23 | + private RoleService roleService; |
| 24 | + |
| 25 | + @RequestMapping |
| 26 | + public Map<String,Object> getAll(Role role, String draw, |
| 27 | + @RequestParam(required = false, defaultValue = "1") int start, |
| 28 | + @RequestParam(required = false, defaultValue = "10") int length){ |
| 29 | + |
| 30 | + Map<String,Object> map = new HashMap<>(); |
| 31 | + PageInfo<Role> pageInfo = roleService.selectByPage(role, start, length); |
| 32 | + System.out.println("pageInfo.getTotal():"+pageInfo.getTotal()); |
| 33 | + map.put("draw",draw); |
| 34 | + map.put("recordsTotal",pageInfo.getTotal()); |
| 35 | + map.put("recordsFiltered",pageInfo.getTotal()); |
| 36 | + map.put("data", pageInfo.getList()); |
| 37 | + return map; |
| 38 | + } |
| 39 | + |
| 40 | + @RequestMapping("/rolesWithSelected") |
| 41 | + public List<Role> rolesWithSelected(Integer uid){ |
| 42 | + return roleService.queryRoleListWithSelected(uid); |
| 43 | + } |
| 44 | + |
| 45 | +} |
0 commit comments