Просмотр исходного кода

修复门店详情服务类型返回

将 serverType 正确映射到数据库 server_type 字段,并新增映射回归测试。
qmj 18 часов назад
Родитель
Сommit
2f114d44d7

+ 1 - 1
ruoyi-system/src/main/resources/mapper/chanting/PosStoreMapper.xml

@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="zhitsj"    column="zhitsj"    />
         <result property="tgpaixv"    column="tgpaixv"    />
         <result property="state"    column="state"    />
-        <result property="serverType"    column="serverType"    />
+        <result property="serverType"    column="server_type"    />
         <result property="telephone"    column="telephone"    />
         <result property="logo"    column="logo"    />
         <result property="menuPhoto"    column="menu_photo"    />

+ 42 - 0
ruoyi-system/src/test/java/com/ruoyi/system/mapper/PosStoreMapperXmlTest.java

@@ -0,0 +1,42 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.PosStore;
+import org.apache.ibatis.builder.xml.XMLMapperBuilder;
+import org.apache.ibatis.mapping.ResultMapping;
+import org.apache.ibatis.session.Configuration;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class PosStoreMapperXmlTest {
+
+    @Test
+    void storeDetailMapsServerTypeFromDatabaseColumn() throws IOException {
+        Configuration configuration = mapperConfiguration();
+
+        ResultMapping serverTypeMapping = configuration
+                .getResultMap("com.ruoyi.system.mapper.PosStoreMapper.PosStoreResult")
+                .getResultMappings()
+                .stream()
+                .filter(mapping -> "serverType".equals(mapping.getProperty()))
+                .findFirst()
+                .orElseThrow();
+
+        assertEquals("server_type", serverTypeMapping.getColumn());
+    }
+
+    private Configuration mapperConfiguration() throws IOException {
+        Configuration configuration = new Configuration();
+        configuration.getTypeAliasRegistry().registerAlias("PosStore", PosStore.class);
+        String resource = "mapper/chanting/PosStoreMapper.xml";
+        try (InputStream input = getClass().getClassLoader().getResourceAsStream(resource)) {
+            assertNotNull(input);
+            new XMLMapperBuilder(input, configuration, resource, configuration.getSqlFragments()).parse();
+        }
+        return configuration;
+    }
+}