网站开发是什么环境,wordpress 头条采集,做网站美工的前途怎么样,网站建设中的风险风险1.删除主表相关子表所有记录
2.再保存一次前端传来的记录
3.如果子表是通过先生成空记录#xff0c;再put修改模式#xff0c;可以在执行1和2两步后再拿模板集合和当前现有子表集合套两个for循环对比判断#xff0c;count记录模板记录和子表记录每次循环重合次数#xff…1.删除主表相关子表所有记录
2.再保存一次前端传来的记录
3.如果子表是通过先生成空记录再put修改模式可以在执行1和2两步后再拿模板集合和当前现有子表集合套两个for循环对比判断count记录模板记录和子表记录每次循环重合次数当发送现有子表中没有模板的情况也就是count0就在一层循环再创建一个模板对象达到效果原有空记录不会因为进来时全删除的操作而抹去因为空记录是页面动态效果的一部分 /*** 更新** param documentEntities* return*/PutMapping(/reference/{projectStageId}/{typeListCode})TransactionalOperation(summary 更新)public ActionResult referenceUpdate(PathVariable String projectStageId,RequestBody Valid ListDocumentListVO documentEntities ) throws DataException {UserInfo userInfo userProvider.get();//删除原有所有记录LambdaQueryWrapperListDocumentFileEntity wrapper new LambdaQueryWrapper();wrapper.eq(ListDocumentFileEntity::getProjectStageId,projectStageId);ListListDocumentFileEntity list listDocumentFileService.list(wrapper);listDocumentFileService.removeBatchByIds(list);//新增此次传来的记录for (DocumentListVO drawingListVO : documentEntities) {for (DocumentVO documentVO : drawingListVO.getChildren()) {ListDocumentFileEntity documentFile new ListDocumentFileEntity(RandomUtil.uuId(),drawingListVO.getProjectStageId(),drawingListVO.getTypeListCode(),drawingListVO.getFSort(),drawingListVO.getFileType(),null,documentVO.getDocumentNumber(), documentVO.getIssuanceDate(),0,userInfo.getUserName(), DateTime.now(),null,null,null,documentVO.getFileId(),documentVO.getSequence(),documentVO.getFileName());if (listDocumentFileService.getInfo(documentVO.getId())null){listDocumentFileService.save(documentFile);}else {documentFile.setId(documentVO.getId());listDocumentFileService.updateById(documentFile);}}}//获取空记录的模板与现在的子表记录对比如果缺了空记录就补充空记录ListListTemplate1Entity listByTypeCode listTemplate1Service.getListByTypeCode(typeListCode);ListListDocumentFileEntity list2 listDocumentFileService.list(wrapper);for (ListTemplate1Entity listTemplate1Entity : listByTypeCode) {int integer 0;for (ListDocumentFileEntity documentFile : list2) {if (documentFile.getFileType().equals(listTemplate1Entity.getFileType())){integer;}}if (integer0){ListDocumentFileEntity listDocumentFileEntity new ListDocumentFileEntity();listDocumentFileEntity.setId(RandomUtil.uuId());listDocumentFileEntity.setProjectStageId(projectStageId);listDocumentFileEntity.setFileType(listTemplate1Entity.getFileType());listDocumentFileEntity.setTypeListCode(listTemplate1Entity.getListTypeCode());listDocumentFileEntity.setFSort(listTemplate1Entity.getFSort());listDocumentFileEntity.setRemark(listTemplate1Entity.getRemark());listDocumentFileEntity.setRequired(listTemplate1Entity.getRequired());listDocumentFileService.save(listDocumentFileEntity);}}return ActionResult.success(更新成功);}方法二
后来想了下直接在第一次的时候判断有没有生成模板的记录如果没生成就生一个这样就避免了第二次遍历 /*** 编辑** param documentEntities* return*/PutMapping(/reference/{projectStageId})TransactionalOperation(summary 更新)public ActionResult referenceUpdate(PathVariable String projectStageId,RequestBody Valid ListDocumentListVO documentEntities ) throws DataException {UserInfo userInfo userProvider.get();//删除原有所有记录LambdaQueryWrapperListDocumentFileEntity wrapper new LambdaQueryWrapper();wrapper.eq(ListDocumentFileEntity::getProjectStageId,projectStageId);ListListDocumentFileEntity list listDocumentFileService.list(wrapper);listDocumentFileService.removeBatchByIds(list);//新增此次传来的记录for (DocumentListVO drawingListVO : documentEntities) {int integer 0;for (DocumentVO documentVO : drawingListVO.getChildren()) {ListDocumentFileEntity documentFile new ListDocumentFileEntity(RandomUtil.uuId(),drawingListVO.getProjectStageId(),drawingListVO.getTypeListCode(),drawingListVO.getFSort(),drawingListVO.getFileType(),null,documentVO.getDocumentNumber(), documentVO.getIssuanceDate(),0,userInfo.getUserName(), DateTime.now(),null,null,null,documentVO.getFileId(),documentVO.getSequence(),documentVO.getFileName());if (listDocumentFileService.getInfo(documentVO.getId())null){listDocumentFileService.save(documentFile);integer;}}//没有就生一个if (integer0){ListDocumentFileEntity listDocumentFileEntity new ListDocumentFileEntity();listDocumentFileEntity.setId(RandomUtil.uuId());listDocumentFileEntity.setProjectStageId(projectStageId);listDocumentFileEntity.setFileType(drawingListVO.getFileType());listDocumentFileEntity.setTypeListCode(drawingListVO.getTypeListCode());listDocumentFileEntity.setFSort(drawingListVO.getFSort());listDocumentFileEntity.setRemark(null);listDocumentFileEntity.setRequired(null);listDocumentFileService.save(listDocumentFileEntity);}}return ActionResult.success(更新成功);}
摸鱼的同志可以看看代码很粗糙应该只是思维符合很多人但实际情况几乎不符