| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.exception.ServiceException; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.SystemmanagementConfigVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngStructBuildTypeVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngStructOtherBuildVO; |
| | | import com.panzhihua.service_community.dao.ComMngStructBuildTypeDAO; |
| | |
| | | import com.panzhihua.service_community.service.ComMngStructOtherBuildService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | }); |
| | | return R.ok(comMngStructBuildTypeVOList); |
| | | } |
| | | |
| | | /** |
| | | * 增加删除建筑类型 |
| | | * |
| | | * @param systemmanagementConfigVO 操作内容 |
| | | * @return 操作结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R putComMngStructBuildType(SystemmanagementConfigVO systemmanagementConfigVO) { |
| | | Long communityId = systemmanagementConfigVO.getCommunityId(); |
| | | List<ComMngStructBuildTypeVO> comMngStructBuildTypeVOList = systemmanagementConfigVO.getComMngStructBuildTypeVOList(); |
| | | if (ObjectUtils.isEmpty(comMngStructBuildTypeVOList)) { |
| | | return R.fail("建筑类型不能为空"); |
| | | } |
| | | List<Long> collect = comMngStructBuildTypeVOList.stream().map(comMngStructBuildTypeVO -> comMngStructBuildTypeVO.getId()).collect(Collectors.toList()); |
| | | List<Long> buildTypdIds= comMngStructOtherBuildDAO.selectAllBuildTypeIds(communityId); |
| | | buildTypdIds.forEach(aLong -> { |
| | | if (!collect.contains(aLong)) { |
| | | ComMngStructBuildTypeDO comMngStructBuildTypeDO = comMngStructBuildTypeDAO.selectById(aLong); |
| | | throw new ServiceException(comMngStructBuildTypeDO.getName()+"已经在使用无法删除"); |
| | | } |
| | | }); |
| | | comMngStructBuildTypeDAO.delete(new QueryWrapper<ComMngStructBuildTypeDO>().lambda().eq(ComMngStructBuildTypeDO::getCommunityId, communityId)); |
| | | comMngStructBuildTypeVOList.forEach(comMngStructBuildTypeVO -> { |
| | | String name = comMngStructBuildTypeVO.getName(); |
| | | if (ObjectUtils.isEmpty(name)) { |
| | | throw new RuntimeException("建筑类型名称不能为空"); |
| | | } |
| | | ComMngStructBuildTypeDO comMngStructBuildTypeDO=new ComMngStructBuildTypeDO(); |
| | | comMngStructBuildTypeDO.setCommunityId(communityId); |
| | | comMngStructBuildTypeDO.setName(name); |
| | | comMngStructBuildTypeDAO.insert(comMngStructBuildTypeDO); |
| | | }); |
| | | return R.ok(); |
| | | } |
| | | } |