<?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.ruoyi.cms.mapper.UserWorkExperiencesMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="userWorkExperiences" id="userWorkExperiencesResult">
        <result property="id" column="id"/>
        <result property="companyName" column="company_name"/>
        <result property="position" column="position"/>
        <result property="userId" column="user_id"/>
        <result property="startDate" column="start_date"/>
        <result property="endDate" column="end_date"/>
        <result property="description" column="description"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>


    <sql id="selectWorkExperiencesVo">
        select id, company_name, position, user_id, start_date, end_date, description, del_flag, create_by, create_time, update_by, update_time, remark from user_work_experiences
    </sql>

    <select id="getWorkExperiencesList" resultMap="userWorkExperiencesResult" parameterType="userWorkExperiences">
        <include refid="selectWorkExperiencesVo"/>
        <where>  del_flag = '0'
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
        </where>
    </select>

    <insert id="batchInsert" parameterType="java.util.List">
        INSERT INTO user_work_experiences (
        company_name, position, user_id, start_date, end_date, description,
        create_by, create_time, del_flag,remark
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.companyName}, #{item.position}, #{item.userId},#{item.startDate},#{item.endDate},
            #{item.description},#{item.createBy}, #{item.createTime}, #{item.delFlag},#{item.remark}
            )
        </foreach>
    </insert>

</mapper>
