znpt-backend/core/src/main/resources/mapper/PartMapper.xml

35 lines
1.6 KiB
XML

<?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.dite.znpt.mapper.PartMapper">
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.PartListResp">
SELECT
pa.part_id, t.project_id, pr.project_name, t.turbine_id, t.turbine_name, pa.part_name, pa.part_code, pa.part_type, pa.part_desc
FROM part pa
LEFT JOIN turbine t ON pa.turbine_id = t.turbine_id
LEFT JOIN project pr ON t.project_id = pr.project_id
<where>
<if test="keyword != null and keyword != ''">
# and (pa.part_name like concat('%', #{keyword,jdbcType=VARCHAR}, '%') or pa.part_code like concat('%', #{keyword,jdbcType=VARCHAR}, '%'))
</if>
<if test="projectId != null and projectId != ''">
and t.project_id = #{projectId}
</if>
<if test="turbineId != null and turbineId != ''">
and t.turbine_id = #{turbineId}
</if>
<if test="partType != null and partType != ''">
and a.part_type = #{partType}
</if>
<if test="partManufacturer != null and partManufacturer != ''">
and a.part_manufacturer like concat ('%', #{partManufacturer}, '%')
</if>
<if test="partModel != null and partModel != ''">
and a.part_model like concat ('%', #{partModel}, '%')
</if>
</where>
</select>
</mapper>