| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | |
| | | @PostMapping("/container/save") |
| | | public R save(@RequestBody Container container) { |
| | | container.setCreateBy(getLoginUserId()); |
| | | container.setCreateTime(new Date()); |
| | | container.setUpdateBy(getLoginUserId()); |
| | | container.setUpdateTime(new Date()); |
| | | if (Objects.isNull(container.getType())) { |
| | | throw new CoolException("容器类型不能为空!!"); |
| | | } |
| | | if (Objects.isNull(container.getUsed())) { |
| | | throw new CoolException("容器使用次数不能为空!!"); |
| | | } |
| | | if (!containerService.save(container)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | |
| | | @OperationLog("Delete 库位信息表") |
| | | @PostMapping("/container/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | List<Container> containers = containerService.list(new LambdaQueryWrapper<Container>().in(Container::getPanrentId, ids)); |
| | | if (containers.isEmpty()) { |
| | | throw new CoolException("当前容器有子容器绑定,不能执行删除操作!!"); |
| | | } |
| | | if (!containerService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | |
| | | @PreAuthorize("hasAuthority('manager:container:list')") |
| | | @PostMapping("/container/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(containerService.list(), Container.class), response); |
| | | List<Container> containers = new ArrayList<>(); |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | containers = containerService.list(new LambdaQueryWrapper<Container>().in(Container::getId, map.get("ids"))); |
| | | } else { |
| | | containers = containerService.list(); |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(containers, Container.class), response); |
| | | } |
| | | |
| | | } |