InvestigateUserMapper.xml 1.59 KB
<?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.project.demo.mapper.InvestigateUserMapper">
    <resultMap id="investigateUserMap" type="com.project.demo.domain.InvestigateUser">
        <result column="users_id" property="usersId" />
        <result column="com_investigation_id" property="comInvestigationId" />
    </resultMap>

    <select id="search" resultMap="investigateUserMap" resultType="Map">
        SELECT
          *
        FROM investigate_user
        where 1=1
        <if test="params.usersId != null">
            AND users_id = #{params.usersId}
        </if>
        <if test="params.comInvestigationId != null">
            AND com_investigation_id = #{params.comInvestigationId}
        </if>

    </select>

    <delete id = "delete">
        DELETE FROM investigate_user where users_id=#{usersId} and com_investigation_id = #{comInvestigationId}
    </delete>

    <insert id="insert" parameterType="com.project.demo.domain.InvestigateUser">


    insert into investigate_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
        <if test="usersId != null">
            users_id,
        </if>
        <if test="comInvestigationId != null">
            com_investigation_id,
        </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
        <if test="usersId != null">
            #{usersId},
        </if>
        <if test="comInvestigationId != null">
            #{comInvestigationId},
        </if>
    </trim>
</insert>



</mapper>