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

85 lines
4.6 KiB
XML
Raw Normal View History

2025-04-10 14:07:11 +08:00
<?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.TurbineMapper">
2025-05-08 00:16:08 +08:00
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.TurbineListResp">
SELECT
t.turbine_id, t.project_id, p.project_name, t.turbine_name, t.turbine_code, t.turbine_desc, t.turbine_manufacturer, t.turbine_model, t.turbine_cover_url
FROM turbine t
LEFT JOIN project p ON t.project_id = p.project_id
2025-04-10 14:07:11 +08:00
<where>
<if test="keyword != null and keyword != ''">
2025-05-08 00:16:08 +08:00
and (t.turbine_name like concat('%', #{keyword,jdbcType=VARCHAR}, '%') or t.turbine_code like concat('%', #{keyword,jdbcType=VARCHAR}, '%'))
2025-04-10 14:07:11 +08:00
</if>
<if test="projectId != null and projectId != ''">
2025-05-08 00:16:08 +08:00
and t.project_id = #{projectId}
2025-04-24 13:54:17 +08:00
</if>
<if test="turbineDesc != null and turbineDesc != ''">
2025-05-08 00:16:08 +08:00
and t.turbine_desc like concat ('%', #{turbineDesc}, '%')
2025-04-24 13:54:17 +08:00
</if>
2025-05-08 00:16:08 +08:00
</where>
</select>
<resultMap id="turbineInfoMap" type="com.dite.znpt.domain.vo.TurbineInfoResp">
<id property="turbineId" column="turbine_id"></id>
<result property="projectId" column="project_id"></result>
<result property="projectName" column="project_name"></result>
<result property="turbineName" column="turbine_name"></result>
<result property="turbineCode" column="turbine_code"></result>
<result property="turbineDesc" column="turbine_desc"></result>
<result property="turbineManufacturer" column="turbine_manufacturer"></result>
<result property="turbineModel" column="turbine_model"></result>
<result property="turbineCoverUrl" column="turbine_coverUrl"></result>
<collection property="partRespList" ofType="com.dite.znpt.domain.vo.PartResp">
<id property="partId" column="part_id"></id>
<result property="projectId" column="project_id"></result>
<result property="projectName" column="project_name"></result>
<result property="turbineId" column="turbine_id"></result>
<result property="turbineName" column="turbine_name"></result>
<result property="partName" column="part_name"></result>
<result property="partCode" column="part_code"></result>
<result property="partType" column="part_type"></result>
<result property="partDesc" column="part_desc"></result>
<result property="partManufacturer" column="part_manufacturer"></result>
<result property="partModel" column="part_model"></result>
</collection>
</resultMap>
<select id="listTurbineInfo" resultMap="turbineInfoMap">
SELECT
t.turbine_id, t.project_id, pr.project_name, t.turbine_name, t.turbine_code, t.turbine_desc, t.turbine_manufacturer, t.turbine_model, t.turbine_cover_url,
pa.part_id, pa.part_name, pa.part_code, pa.part_type, pa.part_desc, pa.part_manufacturer, pa.part_model
FROM turbine t
LEFT JOIN project pr ON t.project_id = pr.project_id
LEFT JOIN part pa ON t.turbine_id = pa.turbine_id
<where>
<if test="keyword != null and keyword != ''">
and (t.turbine_name like concat('%', #{keyword,jdbcType=VARCHAR}, '%') or t.turbine_code like concat('%', #{keyword,jdbcType=VARCHAR}, '%'))
</if>
<if test="projectId != null and projectId != ''">
and t.project_id = #{projectId}
</if>
<if test="turbineDesc != null and turbineDesc != ''">
and t.turbine_desc like concat ('%', #{turbineDesc}, '%')
</if>
<if test="turbineManufacturer != null and turbineManufacturer != ''">
and t.turbine_manufacturer like concat ('%', #{manufacturer}, '%')
</if>
<if test="turbineModel != null and turbineModel != ''">
and t.turbine_model like concat ('%', #{model}, '%')
2025-04-24 13:54:17 +08:00
</if>
2025-04-10 14:07:11 +08:00
</where>
</select>
2025-05-08 00:16:08 +08:00
<select id="getTurbineInfo" resultMap="turbineInfoMap">
SELECT
t.turbine_id, t.project_id, pr.project_name, t.turbine_name, t.turbine_code, t.turbine_desc, t.turbine_manufacturer, t.turbine_model, t.turbine_cover_url,
pa.part_id, pa.part_name, pa.part_code, pa.part_type, pa.part_desc, pa.part_manufacturer, pa.part_model
FROM turbine t
LEFT JOIN project pr ON t.project_id = pr.project_id
LEFT JOIN part pa ON t.turbine_id = pa.turbine_id
WHERE t.turbine_id = #{turbineId}
</select>
2025-04-10 14:07:11 +08:00
</mapper>