| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.modules.house.entity.HouseRentalEntity; |
| | | import org.springblade.modules.house.entity.HouseTenantEntity; |
| | | import org.springblade.modules.house.service.IHouseTenantService; |
| | | import org.springblade.modules.house.vo.HouseRentalVO; |
| | | import org.springblade.modules.house.mapper.HouseRentalMapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | // 返回 |
| | | return houseRentalVOS; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean add(HouseRentalVO houseRentalVO) { |
| | | //保存自身 |
| | | boolean save = save(houseRentalVO); |
| | | |
| | | List<HouseTenantEntity> houseTenantEntities = new ArrayList<>(); |
| | | |
| | | houseRentalVO.getHouseTenantVOList().forEach(e->{ |
| | | HouseTenantEntity houseTenant= new HouseTenantEntity(); |
| | | |
| | | houseTenant.setHousingRentalId(houseRentalVO.getId()); |
| | | houseTenant.setName(e.getName()); |
| | | houseTenant.setPhone(e.getPhone()); |
| | | houseTenant.setIdCard(e.getIdCard()); |
| | | houseTenant.setDomicile(e.getDomicile()); |
| | | houseTenant.setWorkUnit(e.getWorkUnit()); |
| | | |
| | | houseTenantEntities.add(houseTenant); |
| | | |
| | | }); |
| | | boolean saveBatch = houseTenantService.saveBatch(houseTenantEntities); |
| | | |
| | | return save&&saveBatch; |
| | | } |
| | | } |