| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Role, BaseParam> pageParam = new PageParam<>(baseParam, Role.class); |
| | | return R.ok().add(roleService.page(pageParam, pageParam.buildWrapper(true))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(roleService.page(pageParam, pageParam.buildWrapper(true)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:list')") |
| | | @PostMapping("/role/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(roleService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(roleService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:list')") |
| | | @PostMapping({"/role/many/{ids}", "/roles/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(roleService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(roleService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:list')") |
| | | @GetMapping("/role/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(roleService.getById(id)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(roleService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:save')") |
| | |
| | | if (!roleService.save(role)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(role); |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(role)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:update')") |
| | |
| | | if (!roleService.updateById(role)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(role); |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(role)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:remove')") |
| | |
| | | throw new CoolException("Internal Server Error!"); |
| | | } |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:list')") |
| | |
| | | roleService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getName())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(vos)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:list')") |
| | |
| | | @PreAuthorize("hasAuthority('system:role:list')") |
| | | @GetMapping("/role/scope/list") |
| | | public R scopeList(@RequestParam Long roleId) { |
| | | return R.ok().add(roleMenuService.listStrictlyMenuByRoleId(roleId)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(roleMenuService.listStrictlyMenuByRoleId(roleId))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:role:update')") |
| | |
| | | for (Long id : ids) { |
| | | nameList.add(roleService.getById(id).getName()); |
| | | } |
| | | return R.ok().add(nameList); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(nameList)); |
| | | } |
| | | |
| | | } |