Files
KnowStreaming/dao/src/main/resources/mapper/TopicFavoriteDao.xml

44 lines
2.0 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="TopicFavoriteDao">
<resultMap id="TopicFavoriteMap" type="TopicFavoriteDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="gmt_modify" jdbcType="TIMESTAMP" property="gmtModify" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
<result column="topic_name" jdbcType="VARCHAR" property="topicName" />
<result column="username" jdbcType="VARCHAR" property="username" />
</resultMap>
<insert id="batchAdd" parameterType="java.util.List">
REPLACE topic_favorite (cluster_id, topic_name, username)
VALUES
<foreach item="TopicFavoriteDO" index="index" collection="list" separator=",">
(#{TopicFavoriteDO.clusterId}, #{TopicFavoriteDO.topicName}, #{TopicFavoriteDO.username})
</foreach>
</insert>
<insert id="batchAddOnPG" parameterType="java.util.List">
insert into topic_favorite (cluster_id, topic_name, username)
values
<foreach item="TopicFavoriteDO" index="index" collection="list" separator=",">
(#{TopicFavoriteDO.clusterId}, #{TopicFavoriteDO.topicName}, #{TopicFavoriteDO.username})
</foreach>
on conflict (cluster_id, topic_name, username) do update set gmt_modify = now();
</insert>
<delete id="deleteById" parameterType="java.lang.Long">
DELETE FROM topic_favorite WHERE id=#{id}
</delete>
<select id="getByUserName" parameterType="java.lang.String" resultMap="TopicFavoriteMap">
SELECT * FROM topic_favorite WHERE username=#{username}
</select>
<select id="getByUserNameAndClusterId" parameterType="java.util.Map" resultMap="TopicFavoriteMap">
SELECT * FROM topic_favorite WHERE username=#{username} AND cluster_id=#{clusterId}
</select>
</mapper>