DockingManMapper.xml 2.05 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.DockingManMapper">
    <resultMap id="dockingManMap" type="com.project.demo.domain.DockingMan">
        <result column="id" property="id" />
        <result column="name" property="name" />
        <result column="position" property="position" />
        <result column="projects_id" property="projectsId" />
        <result column="gender" property="gender" />
        <result column="mobile" property="mobile" />
    </resultMap>

    <select id="search" resultMap="dockingManMap" resultType="Map">
        SELECT
          *
        FROM docking_man
        where 1=1
        <if test="params.projectsId != null">
            AND projects_id = #{params.projectsId}
        </if>

    </select>

    <delete id="delete">
        DELETE FROM docking_man where id = #{id}
    </delete>

    <insert id="insert" parameterType="com.project.demo.domain.SalesMan">
        insert into docking_man
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">
                name,
            </if>
            <if test="position != null">
                position,
            </if>
            <if test="projectsId != null">
                projects_id,
            </if>
            <if test="gender != null">
                gender,
            </if>
            <if test="mobile != null">
                mobile,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">
                #{name},
            </if>
            <if test="position != null">
                #{position},
            </if>
            <if test="projectsId != null">
                #{projectsId},
            </if>
            <if test="gender != null">
                #{gender},
            </if>
            <if test="mobile != null">
                #{mobile},
            </if>
        </trim>
    </insert>

</mapper>