InvestigateMapper.xml 4.93 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.InvestigateMapper">
    <resultMap id="investigatesMap" type="com.project.demo.domain.Investigate">
        <result column="id" property="id" />
        <result column="company_name" property="companyName" />
        <result column="name" property="name" />
        <result column="job" property="job" />
        <result column="mobile" property="mobile" />
        <result column="personnel_matters" property="personnelMatters" />
        <result column="finance" property="finance" />
        <result column="information" property="information" />
        <result column="marketing" property="marketing" />
        <result column="administration" property="administration" />
        <result column="customer_manager" property="customerManager" />
        <result column="manager_mobile" property="managerMobile" />
        <result column="manager_email" property="managerEmail" />
        <result column="user_id" property="userId" />

    </resultMap>

    <sql id="investigate_column_list">
        id,company_name,name,job,mobile,personnel_matters,finance,information,marketing,administration,customer_manager,manager_mobile,manager_email,user_id
    </sql>


    <select id="search" resultMap="investigatesMap" resultType="Map">
        SELECT
        <include refid="investigate_column_list" />
        FROM com_investigation
        where 1=1
        <if test="params.investigateIds != null">
            AND id in
            <foreach collection="params.investigateIds" item="item" index="index"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        ORDER BY id desc
    </select>

    <select id="searchDetails" resultMap="investigatesMap" resultType="com.project.demo.domain.Investigate">
        SELECT
        <include refid="investigate_column_list" />
        FROM com_investigation
        where id = #{id}
    </select>

    <insert id="insert" parameterType="com.project.demo.domain.Investigate">
    insert into com_investigation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyName != null">
                company_name,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="job != null">
                job,
            </if>
            <if test="mobile != null">
                mobile,
            </if>
            <if test="personnelMatters != null">
                personnel_matters,
            </if>
            <if test="finance != null">
                finance,
            </if>
            <if test="information != null">
                information,
            </if>
            <if test="marketing != null">
                marketing,
            </if>
            <if test="administration != null">
                administration,
            </if>
            <if test="customerManager != null">
                customer_manager,
            </if>
            <if test="managerMobile != null">
                manager_mobile,
            </if>
            <if test="managerEmail != null">
                manager_email,
            </if>
            <if test="userId != null">
                user_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyName != null">
                #{companyName},
            </if>
            <if test="name != null">
                #{name},
            </if>
            <if test="job != null">
                #{job},
            </if>
            <if test="mobile != null">
                #{mobile},
            </if>
            <if test="personnelMatters != null">
                #{personnelMatters},
            </if>
            <if test="finance != null">
                #{finance},
            </if>
            <if test="information != null">
                #{information},
            </if>
            <if test="marketing != null">
                #{marketing},
            </if>
            <if test="administration != null">
                #{administration},
            </if>
            <if test="customerManager != null">
                #{customerManager},
            </if>
            <if test="managerMobile != null">
                #{managerMobile},
            </if>
            <if test="managerEmail != null">
                #{managerEmail},
            </if>
            <if test="userId != null">
                #{userId},
            </if>
        </trim>

    </insert>

    <select id="findById" resultMap="investigatesMap">
        SELECT
        *
        FROM com_investigation
        where id = #{id}
    </select>

    <select id="findByUserId" resultMap="investigatesMap">
        SELECT
        *
        FROM com_investigation
        where user_id = #{usersId}
    </select>
</mapper>