XiaoRuby
2023-08-03 fbba4ea24430b14eee18b190b7e08f1a58a8e504
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yuanchu.limslaboratory.mapper.StandardMapper">
 
    <resultMap id="BaseResultMap" type="java.util.Map">
        <id property="specificationsId" column="specificationsId" jdbcType="INTEGER"/>
        <result property="specificationsName" column="specificationsName" jdbcType="VARCHAR"/>
        <collection property="children" resultMap="BaseResultMapChildren" javaType="java.util.List"/>
    </resultMap>
    <resultMap id="BaseResultMapChildren" type="java.util.Map">
        <id property="modelId" column="modelId" jdbcType="INTEGER"/>
        <result property="modelName" column="modelName" jdbcType="VARCHAR"/>
    </resultMap>
 
    <select id="getSpecificationIdAndName" resultMap="BaseResultMap">
        SELECT s.`id` specificationsId, s.`name` specificationsName, f.id modelId, f.name modelName
        FROM standard s
                 LEFT JOIN (SELECT f.`id`, f.`name`, f.`standard_id` FROM specifications f WHERE f.`state` = 1) f
                           ON s.`id` = f.`standard_id`
        WHERE s.`material_id` = #{materialId}
          AND s.`state` = 1
    </select>
</mapper>