|
@@ -1,13 +1,19 @@
|
|
|
package com.zksy.property.service.impl;
|
|
package com.zksy.property.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zksy.property.domain.AHouseType;
|
|
import com.zksy.property.domain.AHouseType;
|
|
|
|
|
+import com.zksy.property.domain.ARoom;
|
|
|
import com.zksy.property.service.AHouseTypeService;
|
|
import com.zksy.property.service.AHouseTypeService;
|
|
|
import com.zksy.property.mapper.AHouseTypeMapper;
|
|
import com.zksy.property.mapper.AHouseTypeMapper;
|
|
|
|
|
+import com.zksy.property.service.ARoomService;
|
|
|
|
|
+import com.zksy.service.MinioFileStorageService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -15,7 +21,7 @@ import java.util.List;
|
|
|
/**
|
|
/**
|
|
|
* @author Administrator
|
|
* @author Administrator
|
|
|
* @description 针对表【a_house_type(户型表)】的数据库操作Service实现
|
|
* @description 针对表【a_house_type(户型表)】的数据库操作Service实现
|
|
|
-* @createDate 2025-06-24 16:24:28
|
|
|
|
|
|
|
+* @createLocalDate 2025-06-24 16:24:28
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseType>
|
|
public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseType>
|
|
@@ -23,11 +29,16 @@ public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseT
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private AHouseTypeMapper mapper;
|
|
private AHouseTypeMapper mapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MinioFileStorageService minioFileStorageService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ARoomService roomService;
|
|
|
@Override
|
|
@Override
|
|
|
public List<AHouseType> getHouseTypeList(String accountNumber) {
|
|
public List<AHouseType> getHouseTypeList(String accountNumber) {
|
|
|
- QueryWrapper<AHouseType> queryWrapper = new QueryWrapper();
|
|
|
|
|
- queryWrapper.like("account_number",accountNumber);
|
|
|
|
|
- List<AHouseType> list = mapper.selectList(queryWrapper);
|
|
|
|
|
|
|
+ LambdaQueryWrapper<AHouseType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ lambdaQueryWrapper.like(accountNumber != null,AHouseType::getAccountNumber,accountNumber);
|
|
|
|
|
+ lambdaQueryWrapper.orderByDesc(AHouseType::getUpLocalDateTime);
|
|
|
|
|
+ List<AHouseType> list = mapper.selectList(lambdaQueryWrapper);
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -35,11 +46,65 @@ public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseT
|
|
|
public Page<AHouseType> findByPage(long pageNum, long pageSize, String accountNumber){
|
|
public Page<AHouseType> findByPage(long pageNum, long pageSize, String accountNumber){
|
|
|
Page<AHouseType> page = new Page<>(pageNum,pageSize);
|
|
Page<AHouseType> page = new Page<>(pageNum,pageSize);
|
|
|
QueryWrapper<AHouseType> queryWrapper = new QueryWrapper();
|
|
QueryWrapper<AHouseType> queryWrapper = new QueryWrapper();
|
|
|
- queryWrapper.like("account_number",accountNumber);
|
|
|
|
|
|
|
+ queryWrapper.like(accountNumber != null ,"account_number",accountNumber);
|
|
|
|
|
+ queryWrapper.orderByDesc("upLocalDate_time");
|
|
|
Page<AHouseType> page1 = mapper.selectPage(page, queryWrapper);
|
|
Page<AHouseType> page1 = mapper.selectPage(page, queryWrapper);
|
|
|
return page1;
|
|
return page1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public boolean saveHouseType(AHouseType houseType, MultipartFile multipartFile) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (multipartFile != null) {
|
|
|
|
|
+ String path = minioFileStorageService.uploadFile(multipartFile, "houseType");
|
|
|
|
|
+ houseType.setAccountUrl(path);
|
|
|
|
|
+ }
|
|
|
|
|
+ return save(houseType);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new RuntimeException("保存失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public boolean upLocalDateHouseType(AHouseType houseType, MultipartFile multipartFile) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (multipartFile != null) {
|
|
|
|
|
+ // 删除minio文件
|
|
|
|
|
+ minioFileStorageService.deleteFile(houseType.getAccountUrl());
|
|
|
|
|
+ String path = minioFileStorageService.uploadFile(multipartFile, "houseType");
|
|
|
|
|
+ houseType.setAccountUrl(path);
|
|
|
|
|
+ }
|
|
|
|
|
+ return updateById(houseType);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new RuntimeException("修改失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public boolean removeBatchHouseType(String[] ids) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ for (String id : ids) {
|
|
|
|
|
+ List<ARoom> houseTypeIds = roomService.getByHouseTypeId( id);
|
|
|
|
|
+ if(houseTypeIds != null){
|
|
|
|
|
+ throw new RuntimeException("请先删除该户型下的所有房间");
|
|
|
|
|
+ }
|
|
|
|
|
+ AHouseType houseType = getById(id);
|
|
|
|
|
+ if (houseType != null) {
|
|
|
|
|
+ minioFileStorageService.deleteFile(houseType.getAccountUrl());
|
|
|
|
|
+ }
|
|
|
|
|
+ removeById(id);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new RuntimeException("删除失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|