<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, hnqz All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the pig4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: hnqz
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.qunzhixinxi.hnqz.admin.mapper.WmRelationMapper">

  <resultMap id="wmRelationMap" type="com.qunzhixinxi.hnqz.admin.entity.WmRelation">
                  <id property="upId" column="up_id"/>
                        <result property="downId" column="down_id"/>
            </resultMap>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from wm_relation
    where down_id = #{downId,jdbcType=BIGINT}
  </delete>

	<select id="selectUpIdList" resultMap="wmRelationMap">
		select
		*
		from wm_relation
		where
		up_id = #{query.upId,jdbcType=BIGINT}
	</select>

	<insert id="insert" parameterType="com.qunzhixinxi.hnqz.admin.entity.WmRelation">
    insert into wm_relation (up_id, down_id)
    values (#{upId,jdbcType=INTEGER}, #{downId,jdbcType=INTEGER})
  </insert>
	<insert id="insertSelective" parameterType="com.qunzhixinxi.hnqz.admin.entity.WmRelation">
		insert into wm_relation
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="upId != null">
				up_id,
			</if>
			<if test="downId != null">
				down_id,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="upId != null">
				#{upId,jdbcType=INTEGER},
			</if>
			<if test="downId != null">
				#{downId,jdbcType=INTEGER},
			</if>
		</trim>
	</insert>

	<select id="selectByUpId" resultMap="wmRelationMap" parameterType="java.util.HashMap">
		select * from wm_relation where down_id= #{upId,jdbcType=INTEGER}

	</select>
</mapper>
