瀏覽代碼

feat(houseRelations): add missing properties realName.

eric 2 年之前
父節點
當前提交
5cf22d652a

+ 9 - 3
src/main/resources/mapper/HouseRelationMapper.xml

@@ -37,9 +37,15 @@
     <select id="selectByState" resultType="com.finikes.oc.management.HouseRelationViewDto">
         SELECT passportId,
         houseId,
-        state,
+        t_house_relation.state,
         certificateNo,
-        certificateUrl
-        FROM t_house_relation WHERE state = #{state}
+        certificateUrl,
+        name realName
+        FROM t_house_relation,
+        t_passport
+        WHERE t_passport.id = t_house_relation.passportId
+        <if test="state != null">
+            AND t_house_relation.state = #{state}
+        </if>
     </select>
 </mapper>

+ 31 - 0
src/test/java/com/finikes/oc/management/dao/HouseRelationDAOTest.java

@@ -0,0 +1,31 @@
+package com.finikes.oc.management.dao;
+
+import com.finikes.oc.App;
+import com.finikes.oc.management.HouseRelationViewDto;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = App.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class HouseRelationDAOTest {
+
+    @Autowired
+    private HouseRelationDAO houseRelationDAO;
+
+    @Test
+    void selectByState() {
+        List<HouseRelationViewDto> viewDtos = houseRelationDAO.selectByState(null);
+        viewDtos.forEach(System.out::println);
+    }
+}