| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.property.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.flowable.idm.engine.impl.persistence.entity.UserEntity; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.property.entity.PropertyCompanyDistrictEntity; |
| | | import org.springblade.modules.property.entity.PropertyDistrictUserEntity; |
| | | import org.springblade.modules.property.service.IPropertyDistrictUserService; |
| | | import org.springblade.modules.property.vo.PropertyCompanyDistrictVO; |
| | | import org.springblade.modules.property.mapper.PropertyCompanyDistrictMapper; |
| | | import org.springblade.modules.property.service.IPropertyCompanyDistrictService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.modules.system.entity.UserDept; |
| | | 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; |
| | | |
| | | /** |
| | | * 物业派驻小区表 服务实现类 |
| | |
| | | * @since 2023-11-23 |
| | | */ |
| | | @Service |
| | | public class PropertyCompanyDistrictServiceImpl extends BaseServiceImpl<PropertyCompanyDistrictMapper, PropertyCompanyDistrictEntity> implements IPropertyCompanyDistrictService { |
| | | public class PropertyCompanyDistrictServiceImpl extends ServiceImpl<PropertyCompanyDistrictMapper, PropertyCompanyDistrictEntity> implements IPropertyCompanyDistrictService { |
| | | |
| | | @Autowired |
| | | private IPropertyDistrictUserService propertyDistrictUserService; |
| | | |
| | | /** |
| | | * 自定义分页查询 |
| | | * @param page |
| | | * @param propertyCompanyDistrict |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<PropertyCompanyDistrictVO> selectPropertyCompanyDistrictPage(IPage<PropertyCompanyDistrictVO> page, PropertyCompanyDistrictVO propertyCompanyDistrict) { |
| | | return page.setRecords(baseMapper.selectPropertyCompanyDistrictPage(page, propertyCompanyDistrict)); |
| | | } |
| | | |
| | | /** |
| | | * 物业派驻小区表 自定义新增或修改 |
| | | * @param propertyCompanyDistrict |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveOrUpdatePropertyCompanyDistrict(PropertyCompanyDistrictEntity propertyCompanyDistrict) { |
| | | if (null != propertyCompanyDistrict.getId()) { |
| | | return updateById(propertyCompanyDistrict) && submitPropertyDistrictUser(propertyCompanyDistrict); |
| | | }else { |
| | | return save(propertyCompanyDistrict) && submitPropertyDistrictUser(propertyCompanyDistrict); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 关联关系维护 |
| | | * @param propertyCompanyDistrict |
| | | * @return |
| | | */ |
| | | private boolean submitPropertyDistrictUser(PropertyCompanyDistrictEntity propertyCompanyDistrict) { |
| | | List<Long> userIdList = Func.toLongList(propertyCompanyDistrict.getUserId()); |
| | | List<PropertyDistrictUserEntity> propertyDistrictUserEntityList = new ArrayList<>(); |
| | | userIdList.forEach(userId -> { |
| | | PropertyDistrictUserEntity propertyDistrictUserEntity = new PropertyDistrictUserEntity(); |
| | | propertyDistrictUserEntity.setUserId(userId); |
| | | propertyDistrictUserEntity.setPropertyCompanyDistrictId(propertyCompanyDistrict.getId()); |
| | | propertyDistrictUserEntityList.add(propertyDistrictUserEntity); |
| | | }); |
| | | // 先删除 |
| | | propertyDistrictUserService.remove(Wrappers.<PropertyDistrictUserEntity>update().lambda().eq(PropertyDistrictUserEntity::getPropertyCompanyDistrictId, propertyCompanyDistrict.getId())); |
| | | // 再新增 |
| | | return propertyDistrictUserService.saveBatch(propertyDistrictUserEntityList); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserEntity> getDistictUserByCode(String houseCode) { |
| | | return baseMapper.getDistictUserByCode(houseCode); |
| | | } |
| | | } |