| | |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Contract, BaseParam> pageParam = new PageParam<>(baseParam, Contract.class); |
| | | PageParam<Contract, BaseParam> page = contractService.page(pageParam, pageParam.buildWrapper(true)); |
| | | buildPageRowsUtils.userNameMap(page.getRecords()); |
| | | return R.ok().add(page); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(page)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:contract:list')") |
| | | @PostMapping("/contract/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(contractService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(contractService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:contract:list')") |
| | | @PostMapping({"/contract/many/{ids}", "/contracts/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(contractService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(contractService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:contract:list')") |
| | | @GetMapping("/contract/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(contractService.getById(id)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(contractService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:contract:save')") |
| | |
| | | if (!contractService.save(contract)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(contract); |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(contract)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:contract:update')") |
| | |
| | | if (!contractService.updateById(contract)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(contract); |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(contract)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:contract:remove')") |
| | |
| | | if (!contractService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:contract:list')") |
| | |
| | | contractService.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('manager:contract:list')") |
| | | @PostMapping("/contract/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(contractService.list(), Contract.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(contractService.list()), Contract.class), response); |
| | | } |
| | | |
| | | } |