gtsoft-snail-job-server/easy-retry-datasource/easy-retry-postgres-datasource/src/main/resources/postgres/mapper/ServerNodeMapper.xml

41 lines
2.4 KiB
XML
Raw Normal View History

2023-01-14 21:02:18 +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">
2023-08-04 22:22:47 +08:00
<mapper namespace="com.aizuda.easy.retry.template.datasource.persistence.mapper.ServerNodeMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode">
2023-01-14 21:02:18 +08:00
<id column="id" jdbcType="BIGINT" property="id" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="host_id" jdbcType="VARCHAR" property="hostId" />
<result column="host_ip" jdbcType="VARCHAR" property="hostIp" />
<result column="host_port" jdbcType="INTEGER" property="hostPort" />
<result column="expire_at" jdbcType="TIMESTAMP" property="expireAt" />
<result column="node_type" jdbcType="TINYINT" property="nodeType" />
<result column="context_path" jdbcType="VARCHAR" property="contextPath" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
2023-01-14 21:02:18 +08:00
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
</resultMap>
<sql id="Base_Column_List">
id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt
2023-01-14 21:02:18 +08:00
</sql>
2023-08-04 22:22:47 +08:00
<insert id="insertOrUpdate" parameterType="com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode" useGeneratedKeys="true" keyProperty="id">
INSERT INTO server_node (group_name, host_id, host_ip, host_port,
expire_at, node_type, ext_attrs, context_path, create_dt)
2023-08-04 22:22:47 +08:00
VALUES (#{groupName}, #{hostId}, #{hostIp}, #{hostPort},
#{expireAt}, #{nodeType}, #{extAttrs}, #{contextPath}, #{createDt})
ON CONFLICT (host_id, host_ip) DO UPDATE SET
group_name = EXCLUDED.group_name,
host_id = EXCLUDED.host_id,
host_ip = EXCLUDED.host_ip,
host_port = EXCLUDED.host_port,
expire_at = EXCLUDED.expire_at,
node_type = EXCLUDED.node_type,
ext_attrs = EXCLUDED.ext_attrs,
context_path = EXCLUDED.context_path,
create_dt = EXCLUDED.create_dt
2023-01-14 21:02:18 +08:00
</insert>
<delete id="deleteByExpireAt">
delete from server_node
where expire_at &lt;= #{endTime,jdbcType=TIMESTAMP}
</delete>
</mapper>