| | |
| | | mpVisitorMapper.updateById(row); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(Long id, String uuid) { |
| | | MpUser current = miniAuthApplicationService.currentMpUser(); |
| | | MpVisitor row = loadOwnedVisitor(id, uuid, current.getId()); |
| | | boolean wasDefault = isDefault(row); |
| | | mpVisitorMapper.deleteById(row.getId()); |
| | | if (wasDefault) { |
| | | resetEarliestVisitorAsDefault(current.getId()); |
| | | } |
| | | } |
| | | |
| | | public MiniVisitorDetailVo detail(Long id, String uuid) { |
| | | MpUser current = miniAuthApplicationService.currentMpUser(); |
| | | MpVisitor row = loadOwnedVisitor(id, uuid, current.getId()); |
| | |
| | | > 0; |
| | | } |
| | | |
| | | private void resetEarliestVisitorAsDefault(Long mpUserId) { |
| | | MpVisitor next = |
| | | mpVisitorMapper.selectOne( |
| | | new LambdaQueryWrapper<MpVisitor>() |
| | | .eq(MpVisitor::getMpUserId, mpUserId) |
| | | .eq(MpVisitor::getDelFlag, 0) |
| | | .orderByAsc(MpVisitor::getCreateTime) |
| | | .orderByAsc(MpVisitor::getId) |
| | | .last("limit 1")); |
| | | if (next != null) { |
| | | next.setIsDefault(1); |
| | | mpVisitorMapper.updateById(next); |
| | | } |
| | | } |
| | | |
| | | private List<String> resolveMissingFieldCodes(MpVisitor row, Set<String> requiredCodes) { |
| | | List<String> missing = new ArrayList<>(); |
| | | for (String code : requiredCodes) { |