| | |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<BasContainer, BaseParam> pageParam = new PageParam<>(baseParam, BasContainer.class); |
| | | PageParam<BasContainer, BaseParam> page = basContainerService.page(pageParam, pageParam.buildWrapper(true)); |
| | | for (BasContainer container : page.getRecords()) { |
| | | if (!Cools.isEmpty(container.getAreas())) { |
| | | String content = container.getAreas().substring(1, container.getAreas().length() - 1); |
| | | String[] parts = content.split(","); |
| | | Long[] longArray = new Long[parts.length]; |
| | | for (int i = 0; i < parts.length; i++) { |
| | | longArray[i] = Long.parseLong(parts[i].trim()); |
| | | } |
| | | container.setAreaIds(longArray); |
| | | } |
| | | |
| | | } |
| | | return R.ok().add(page); |
| | | } |
| | | |
| | |
| | | @GetMapping("/basContainer/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | BasContainer basContainer = basContainerService.getById(id); |
| | | String content = basContainer.getAreas().substring(1, basContainer.getAreas().length() - 1); |
| | | String[] parts = content.split(","); |
| | | Long[] longArray = new Long[parts.length]; |
| | | for (int i = 0; i < parts.length; i++) { |
| | | longArray[i] = Long.parseLong(parts[i].trim()); |
| | | } |
| | | basContainer.setAreaIds(longArray); |
| | | return R.ok().add(basContainer); |
| | | } |
| | | |
| | |
| | | if (null != container) { |
| | | return R.error("该类型已被初始化"); |
| | | } |
| | | if (null !=basContainer.getAreaIds()){ |
| | | basContainer.setAreas(Arrays.toString(basContainer.getAreaIds())); |
| | | } |
| | | if (!basContainerService.save(basContainer)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | |
| | | public R update(@RequestBody BasContainer basContainer) { |
| | | basContainer.setUpdateBy(getLoginUserId()); |
| | | basContainer.setUpdateTime(new Date()); |
| | | if (null !=basContainer.getAreaIds()){ |
| | | basContainer.setAreas(Arrays.toString(basContainer.getAreaIds())); |
| | | } |
| | | if (!basContainerService.updateById(basContainer)) { |
| | | return R.error("Update Fail"); |
| | | } |