Files
intelligent-application-orc…/src/main/resources/mapper/GpuResourceMapper.xml

66 lines
2.5 KiB
XML
Raw Normal View History

2025-05-25 16:14:04 +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">
2025-06-03 21:28:40 +08:00
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao">
<resultMap id="gpuResourceMap" type="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
<id property="GPUId" column="GPUId" /> <!-- 强制映射 -->
<result property="createTime" column="created_time"/>
<result property="UpdateTime" column="update_time"/>
<result property="GPUModel" column="GPUModel"/>
<result property="GPUMemorySize" column="GPUMemorySize"/>
<result property="Ip" column="Ip"/>
<result property="isDeleted" column="is_deleted"/>
<result property="GPUMaxMemory" column="GPUMaxMemory"/>
</resultMap>
2025-05-25 16:14:04 +08:00
<!-- 动态条件查询 -->
<select id="selectByFields"
resultMap="gpuResourceMap">
2025-05-25 16:14:04 +08:00
SELECT *
2025-05-30 11:40:04 +08:00
FROM Ipz.public.gpu_resource
2025-05-25 16:14:04 +08:00
<where>
is_deleted = 0
<if test="params.model != null and params.model != ''">
AND GPUModel LIKE CONCAT('%', #{params.model}, '%')
</if>
<if test="params.memoryMin != null">
AND GPUMemorySize &gt;= #{params.memoryMin}
</if>
<if test="params.ip != null and params.ip != ''">
AND Ip = #{params.ip}
</if>
<if test="params.startTime != null and params.endTime != null">
AND update_time BETWEEN #{params.startTime} AND #{params.endTime}
</if>
</where>
ORDER BY GPUId DESC
</select>
<!-- 分页查询 -->
<select id="findByPage"
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
2025-05-25 16:14:04 +08:00
SELECT *
2025-05-30 11:40:04 +08:00
FROM gpu_resource
2025-05-25 16:14:04 +08:00
WHERE is_deleted = 0
ORDER BY GPUId ASC
LIMIT #{limit} OFFSET #{offset}
</select>
<!-- 增量同步查询 -->
<select id="findModifiedSince"
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
2025-05-25 16:14:04 +08:00
SELECT *, is_deleted
2025-05-30 11:40:04 +08:00
FROM gpu_resource
2025-05-25 16:14:04 +08:00
WHERE update_time &gt; #{since}
ORDER BY update_time ASC
</select>
<!-- 带锁查询 -->
<select id="selectByIdWithLock"
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
2025-05-25 16:14:04 +08:00
SELECT *
2025-05-30 11:40:04 +08:00
FROM gpu_resource
2025-05-25 16:14:04 +08:00
WHERE GPUId = #{gpuId}
FOR UPDATE NOWAIT
</select>
</mapper>