| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | @Autowired |
| | | RoleService roleService; |
| | | |
| | | @GetMapping("page-list") |
| | | public PageBean pageList(PageBean pageBean) { |
| | | return roleService.queryByPageBean(pageBean); |
| | | } |
| | | |
| | | @GetMapping("count-by-example") |
| | | public ResultBean<Integer> countByExample(PageBean pageBean){ |
| | | return new ResultBean<Integer>(roleService.countByExample(pageBean)); |
| | | } |
| | | |
| | | @GetMapping("page-list") |
| | | public PageBean pageList(PageBean pageBean) { |
| | | return roleService.queryByPageBean(pageBean); |
| | | @GetMapping("role-list") |
| | | public PageBean getRoleList(PageBean pageBean) { |
| | | return roleService.getRoleList(pageBean); |
| | | } |
| | | |
| | | @PostMapping("add-or-modify") |
| | |
| | | } |
| | | |
| | | @PostMapping("delete-by-ids") |
| | | public ResultBean deleteByIds(@RequestBody List<Integer> ids){ |
| | | public ResultBean deleteByIds(@RequestBody Integer [] ids){ |
| | | roleService.deleteByIds(ids); |
| | | ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); |
| | | return resultBean; |
| | | } |
| | | |
| | | @GetMapping("get-role-ids") |
| | | public List<Integer> getRoleIds(int accountId){ |
| | | return roleService.getRoleIds(accountId); |
| | | } |
| | | |
| | | @PostMapping("allot-role/{id}") |
| | | public ResultBean allotRole(@PathVariable("id") Integer accountId, @RequestBody Integer [] roleIds){ |
| | | ResultBean resultBean = new ResultBean(); |
| | | if(accountId==null){ |
| | | resultBean.setCode(ResultBean.NO_PERMISSION); |
| | | resultBean.setMessage("账户ID不能为null"); |
| | | return resultBean; |
| | | }else{ |
| | | roleService.allotRole(accountId,roleIds); |
| | | resultBean.setCode(ResultBean.SUCCESS); |
| | | } |
| | | return resultBean; |
| | | } |
| | | |
| | | @PostMapping("allot-menu/{id}") |
| | | public ResultBean allotMenu(@PathVariable("id") Integer roleId, @RequestBody Integer [] menuOrders){ |
| | | ResultBean resultBean = new ResultBean(); |
| | | if(roleId==null){ |
| | | resultBean.setCode(ResultBean.NO_PERMISSION); |
| | | resultBean.setMessage("角色ID不能为null"); |
| | | return resultBean; |
| | | }else{ |
| | | roleService.allotMenu(roleId,menuOrders); |
| | | resultBean.setCode(ResultBean.SUCCESS); |
| | | } |
| | | return resultBean; |
| | | } |
| | | |
| | | } |