Explorar o código

feat(property): 新增 AR 户型查询功能并优化相关服务- 在 AHouseTypeController 中添加 getByRoomType 方法,实现按房间类型查询户型
- 在 AHouseTypeService 接口中新增 getByRoomType 方法
- 在 AHouseTypeServiceImpl 中实现 getByRoomType 方法,使用 LambdaQueryWrapper 查询指定房间类型的户型
- 优化 AHouseTypeServiceImpl 中的 removeBatchHouseType 方法,使用 CollUtil 判断列表是否为空
- 移除 application-dev.yml 中的 imgAddress 配置
- 更新 application-prod.yml,配置 MySQL 和 Redis 连接信息
- 新增 CorsConfig 类,配置跨域访问
- 更新 pom.xml,添加 spring-boot-maven-plugin 插件

nahida hai 10 meses
pai
achega
c03bd20095

+ 11 - 0
pom.xml

@@ -90,4 +90,15 @@
             <version>4.1.2</version>
         </dependency>
     </dependencies>
+
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 6 - 4
src/main/java/com/zksy/controller/property/AHouseTypeController.java

@@ -1,7 +1,5 @@
 package com.zksy.controller.property;
 
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.LocalDateTimeUtil;
 import com.zksy.property.domain.AHouseType;
 import com.zksy.property.service.AHouseTypeService;
 import com.zksy.utils.AjaxResult;
@@ -11,9 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.List;
 
 /**
  * @author Administrator
@@ -59,4 +55,10 @@ public class AHouseTypeController {
     public AjaxResult delete(@RequestBody String[] ids) {
         return service.removeBatchHouseType(ids)? AjaxResult.success(): AjaxResult.error("删除失败");
     }
+
+    @GetMapping("/getByRoomType")
+    @ApiOperation(value = "AR户型查询")
+    public AjaxResult getByRoomType(Integer roomType) {
+        return AjaxResult.success(service.getByRoomType(roomType));
+    }
 }

+ 16 - 10
src/main/java/com/zksy/property/service/AHouseTypeService.java

@@ -1,21 +1,27 @@
 package com.zksy.property.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.zksy.property.domain.AHouseType;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zksy.property.domain.AHouseType;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
 /**
-* @author Administrator
-* @description 针对表【a_house_type(户型表)】的数据库操作Service
-* @createDate 2025-06-24 16:24:28
-*/
+ * @author Administrator
+ * @description 针对表【a_house_type(户型表)】的数据库操作Service
+ * @createDate 2025-06-24 16:24:28
+ */
 public interface AHouseTypeService extends IService<AHouseType> {
-        List<AHouseType> getHouseTypeList(String accountNumber);
-        Page<AHouseType> findByPage(long pageNum, long pageSize, String accountNumber);
-        boolean saveHouseType(AHouseType houseType, MultipartFile multipartFile);
-        boolean updateHouseType(AHouseType houseType, MultipartFile multipartFile);
-        boolean removeBatchHouseType(String[] ids);
+    List<AHouseType> getHouseTypeList(String accountNumber);
+
+    Page<AHouseType> findByPage(long pageNum, long pageSize, String accountNumber);
+
+    boolean saveHouseType(AHouseType houseType, MultipartFile multipartFile);
+
+    boolean updateHouseType(AHouseType houseType, MultipartFile multipartFile);
+
+    boolean removeBatchHouseType(String[] ids);
+
+    List<AHouseType> getByRoomType(Integer roomType);
 }

+ 24 - 16
src/main/java/com/zksy/property/service/impl/AHouseTypeServiceImpl.java

@@ -1,13 +1,14 @@
 package com.zksy.property.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zksy.property.domain.AHouseType;
 import com.zksy.property.domain.ARoom;
-import com.zksy.property.service.AHouseTypeService;
 import com.zksy.property.mapper.AHouseTypeMapper;
+import com.zksy.property.service.AHouseTypeService;
 import com.zksy.property.service.ARoomService;
 import com.zksy.service.MinioFileStorageService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,17 +16,16 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.annotation.Resource;
 import java.util.List;
 
 /**
-* @author Administrator
-* @description 针对表【a_house_type(户型表)】的数据库操作Service实现
-* @createDate 2025-06-24 16:24:28
-*/
+ * @author Administrator
+ * @description 针对表【a_house_type(户型表)】的数据库操作Service实现
+ * @createDate 2025-06-24 16:24:28
+ */
 @Service
 public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseType>
-    implements AHouseTypeService{
+        implements AHouseTypeService {
 
     @Autowired
     private AHouseTypeMapper mapper;
@@ -33,20 +33,21 @@ public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseT
     private MinioFileStorageService minioFileStorageService;
     @Autowired
     private ARoomService roomService;
+
     @Override
     public List<AHouseType> getHouseTypeList(String accountNumber) {
         LambdaQueryWrapper<AHouseType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-        lambdaQueryWrapper.like(accountNumber != null,AHouseType::getAccountNumber,accountNumber);
+        lambdaQueryWrapper.like(accountNumber != null, AHouseType::getAccountNumber, accountNumber);
         lambdaQueryWrapper.orderByDesc(AHouseType::getUpdateTime);
         List<AHouseType> list = mapper.selectList(lambdaQueryWrapper);
         return list;
     }
 
     @Override
-    public Page<AHouseType> findByPage(long pageNum, long pageSize, String accountNumber){
-        Page<AHouseType> page = new Page<>(pageNum,pageSize);
+    public Page<AHouseType> findByPage(long pageNum, long pageSize, String accountNumber) {
+        Page<AHouseType> page = new Page<>(pageNum, pageSize);
         QueryWrapper<AHouseType> queryWrapper = new QueryWrapper();
-        queryWrapper.like(accountNumber != null ,"account_number",accountNumber);
+        queryWrapper.like(accountNumber != null, "account_number", accountNumber);
         queryWrapper.orderByDesc("update_time");
         Page<AHouseType> page1 = mapper.selectPage(page, queryWrapper);
         return page1;
@@ -61,7 +62,7 @@ public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseT
                 houseType.setAccountUrl(path);
             }
             return save(houseType);
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             throw new RuntimeException("保存失败");
         }
@@ -78,7 +79,7 @@ public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseT
                 houseType.setAccountUrl(path);
             }
             return updateById(houseType);
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             throw new RuntimeException("修改失败");
         }
@@ -89,8 +90,8 @@ public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseT
     public boolean removeBatchHouseType(String[] ids) {
         try {
             for (String id : ids) {
-                List<ARoom> houseTypeIds = roomService.getByHouseTypeId( id);
-                if(houseTypeIds != null){
+                List<ARoom> houseTypeIds = roomService.getByHouseTypeId(id);
+                if (CollUtil.isNotEmpty(houseTypeIds)) {
                     throw new RuntimeException("请先删除该户型下的所有房间");
                 }
                 AHouseType houseType = getById(id);
@@ -100,11 +101,18 @@ public class AHouseTypeServiceImpl extends ServiceImpl<AHouseTypeMapper, AHouseT
                 removeById(id);
             }
             return true;
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             throw new RuntimeException("删除失败");
         }
     }
+
+    @Override
+    public List<AHouseType> getByRoomType(Integer roomType) {
+        LambdaQueryWrapper<AHouseType> aHouseTypeLambdaQueryWrapper = new LambdaQueryWrapper<AHouseType>()
+                .eq(AHouseType::getRoomType, roomType);
+        return mapper.selectList(aHouseTypeLambdaQueryWrapper);
+    }
 }
 
 

+ 19 - 0
src/main/java/com/zksy/utils/CorsConfig.java

@@ -0,0 +1,19 @@
+package com.zksy.utils;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class CorsConfig implements WebMvcConfigurer {
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**")  // 允许跨域访问的路径
+                .allowedOriginPatterns("*")  // 允许跨域访问的源
+                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")  // 允许请求方法
+                .allowCredentials(true)  // 是否发送Cookie
+                .maxAge(3600)  // 预检间隔时间
+                .allowedHeaders("*");  // 允许头部设置
+    }
+}

+ 0 - 1
src/main/resources/application-dev.yml

@@ -31,7 +31,6 @@ minio:
   secretKey: minio123
   bucket: zksy-file
   readPath: http://192.168.110.30:9000
-imgAddress: D:/Temp/%s.jpg
 
 
 knife4j:

+ 47 - 140
src/main/resources/application-prod.yml

@@ -1,147 +1,54 @@
-imgAddress: /home/img-repository/%s.jpg
-clientKey: 爱与和平
-# 项目相关配置
-zksy:
-  # 名称
-  name: zksy
-  # 版本
-  version: 1.0.0
-  # 版权年份
-  copyrightYear: 2023
-  # 实例演示开关
-  demoEnabled: true
-  # 文件路径 示例( Windows配置D:/zksy/uploadPath,Linux配置 /home/zksy/uploadPath)
-  profile: /home/zksy/uploadPath/creditRating/
-  # 获取ip地址开关
-  addressEnabled: false
-  # 验证码类型 math 数组计算 char 字符验证
-  captchaType: math
-
-
-# 日志配置
-logging:
-  level:
-    com.zksy: debug
-    org.springframework: warn
-
-
-# 数据源配置
 spring:
   datasource:
-    type: com.alibaba.druid.pool.DruidDataSource
-    driverClassName: com.mysql.cj.jdbc.Driver
-    druid:
-      # 主库数据源
-      master:
-        url: jdbc:mysql://10.0.114.7:3307/enterprise_assets?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-        username: root
-        password: 123456
-      # 从库数据源
-      slave:
-        # 从数据源开关/默认关闭
-        enabled: false
-        url:
-        username:
-        password:
-      # 初始连接数
-      initialSize: 5
-      # 最小连接池数量
-      minIdle: 100
-      # 最大连接池数量
-      maxActive: 400
-      # 配置获取连接等待超时的时间
-      maxWait: 60000
-      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
-      timeBetweenEvictionRunsMillis: 60000
-      # 配置一个连接在池中最小生存的时间,单位是毫秒
-      minEvictableIdleTimeMillis: 300000
-      # 配置一个连接在池中最大生存的时间,单位是毫秒
-      maxEvictableIdleTimeMillis: 900000
-      # 配置检测连接是否有效
-      validationQuery: SELECT 1 FROM DUAL
-      testWhileIdle: true
-      testOnBorrow: false
-      testOnReturn: false
-      webStatFilter:
-        enabled: false
-      statViewServlet:
-        enabled: false
-        # 设置白名单,不填则允许所有访问
-        allow:
-        url-pattern: /druid/*
-        # 控制台管理用户名和密码
-        login-username: wsnbb
-        login-password: cnmd123@#$%(cnnn)#
-      filter:
-        stat:
-          enabled: true
-          # 慢SQL记录
-          log-slow-sql: true
-          slow-sql-millis: 1000
-          merge-sql: true
-        wall:
-          config:
-            multi-statement-allow: true
-    # redis 配置
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://172.16.102.51:3306/enterprise_assets?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
+    username: root
+    password: d$3%#*(jnhUDGHB]z0x876c~
+    hikari:
+      minimum-idle: 5
+      maximum-pool-size: 15
+      auto-commit: true
+      idle-timeout: 30000
+      pool-name: HikariCP
+      max-lifetime: 1800000
+      connection-timeout: 30000
+      connection-test-query: SELECT 1
   redis:
-    # 地址
-    host: 10.101.102.10
-    # 端口,默认为6379
+    host: 172.16.102.52
     port: 6379
-    # 数据库索引
+    password:
+    timeout: 10000
     database: 0
-    # 密码
-    #password:
-    # 连接超时时间
-    timeout: 10s
     lettuce:
       pool:
-        # 连接池中的最小空闲连接
-        min-idle: 10
-        # 连接池中的最大空闲连接
-        max-idle: 200
-        # 连接池的最大数据库连接数
-        max-active: 200
-        # #连接池最大阻塞等待时间(使用负值表示没有限制)
-        max-wait: 1000ms
-#  redisson:
-#    # 单机
-#    address: 10.101.102.10:6379
-#    database: 10
-#    #password: dy123@
-
-
-## 文件上传配置
-local:
-  fileserver:
-    path: file:/home/zksy/uploadPath/creditRating/
-    upload:
-      path: /home/zksy/uploadPath/creditRating/
-    baseurl:
-    mapping:
-      path: /profile/zksy/creditRating
-    filetypes: .jpg,.gif,.png,.ico,.bmp,.jpeg,.mp4,.xls,.xlsx,.tif,.pcx,.tga,.exif,.fpx,.svg,.psd,.cdr,.pcd,.dib,.jfif,.jpe,.dxf,.ufo,.eps,.ai,.raw,.et,.WMF,.webp,.avi,.rmvb,.prn,.wps,.vsd,.dps,.avif,.apng,.doc,.docx,.txt,.pdf,.ppt,.exe,.pptx,.rft,.rar,.zip,.dat,.key,.msg,.cad,.btw,
-
-
-#system:
-#  ghQuestionnaire: true
-#  diffpub: true
-#最大连接数
-server:
-  tomcat:
-    max-connections: 2000
-    #最大线程数
-    max-threads: 1000
-    #最大等待数
-    accept-count: 800
-#  servlet:
-#    context-path: /qyxyfjflserver
-#  ssl:
-#    key-store: classpath:tomcat.jks
-#    key-store-password: 20240520!
-#    keyStoreType: JKS
-#    keyAlias: tomcat
-management:
-  health:
-    redis:
-      enabled: false
+        max-active: 8
+        max-wait: -1ms
+        max-idle: 8
+        min-idle: 0
+minio:
+  endpoint: http://172.16.102.52:9000
+  accessKey: minio
+  secretKey: minio123
+  bucket: zksy-file
+  readPath: http://172.16.102.52:9000
+
+
+knife4j:
+  enable: true
+  openapi:
+    title: 资产管理服务接口文档
+    description: 资产管理服务接口文档
+    email: 1019904632@qq.com
+    concat: nahida
+    url: https://www.itcast.cn
+    version: v1.0.0
+    group:
+      default:
+        group-name: default
+        api-rule: package
+        api-rule-resources:
+          - com.zksy.controller
+#logging:
+#  level:
+#    root: debug  # 设置全局日志级别为debug
+#    com.zksy: debug  # 设置特定包的日志级别为debug