<?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.ruoyi.zdsz.mapper.ZEnginSpecificationsMapper">

    <resultMap type="com.ruoyi.zdsz.domain.ZEnginSpecifications" id="ZEnginSpecificationsResult">
        <result property="id" column="id"/>
        <result property="materId" column="mater_id"/>
        <result property="name" column="name"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <select id="getById" resultType="com.ruoyi.zdsz.domain.vo.ZEnginSpecificationsVo">
        select a.id         as id,
               a.name       as name,
               b.name       as materName,
               b.id         as materId,
               b.engin_type AS enginType
        from z_engin_specifications a
                 left join z_engin_material_quality b on b.id = a.mater_id
        where a.del_flag = '0'
          and a.id = #{id}
        order by a.create_time desc
    </select>
    <select id="getPageList" resultType="com.ruoyi.zdsz.domain.vo.ZEnginSpecificationsVo">
        select a.id as id,
        a.name as name,
        b.name as materName,
        b.id as materId,
        b.engin_type AS enginType
        from z_engin_specifications a
        left join z_engin_material_quality b on b.id = a.mater_id
        <where>
            a.del_flag = '0'
            <if test="p.name != null  and p.name != ''">
                and a.name LIKE CONCAT('%',#{p.name},'%')
            </if>
            <if test="p.materId != null  and p.materId != ''">
                and a.mater_id = #{p.materId}
            </if>
        </where>
        order by a.create_time desc
    </select>

    <select id="getEnginSpecifications" resultType="com.ruoyi.zdsz.domain.vo.ZEnginSpecificationsVo">
        select * from z_engin_specifications as ze where ze.del_flag = '0'
        <if test="materId != null and materId != ''">
            and ze.mater_id = #{materId}
        </if>
        order by ze.create_time desc

    </select>
</mapper>
