XiaoRuby
2023-08-09 ea1f48f286fa96abcd70f7063c1f5bdc94f13cc5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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.mom.mapper.ProductMapper">
 
    <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.Product">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="name" column="name" jdbcType="VARCHAR"/>
            <result property="father" column="father" jdbcType="VARCHAR"/>
            <result property="unit" column="unit" jdbcType="VARCHAR"/>
            <result property="required" column="required" jdbcType="VARCHAR"/>
            <result property="internal" column="internal" jdbcType="VARCHAR"/>
            <result property="state" column="state" jdbcType="INTEGER"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
            <result property="version" column="version" jdbcType="INTEGER"/>
            <result property="specificationsId" column="specifications_id" jdbcType="INTEGER"/>
    </resultMap>
 
    <resultMap id="selectTreeProduct" type="ProductDto">
        <id property="father" column="father" jdbcType="VARCHAR"/>
        <collection property="children" resultMap="productDto2ListMap"/>
    </resultMap>
 
    <resultMap id="productDto2ListMap" type="ProductDto2">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="unit" column="unit" jdbcType="VARCHAR"/>
        <result property="required" column="required" jdbcType="VARCHAR"/>
        <result property="internal" column="internal" jdbcType="VARCHAR"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
    </resultMap>
 
    <select id="selectTreeProduct" resultMap="selectTreeProduct">
        SELECT p.id, p.`name`, IFNULL(p.`father`,p.`name`) father, p.`unit`, p.`required`, p.`internal`
        FROM product p
        where p.specifications_id = #{specifications}
          <if test="project != null and project != ''">
              AND p.father like concat('%',#{project},'%')
          </if>
        and p.state = 1
    </select>
</mapper>