<?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.AppSkillMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="AppSkill" id="AppSkillResult">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="name" column="name"/>
        <result property="levels" column="levels"/>
        <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="selectAppSkillVo">
        select id, user_id, name, levels, del_flag, create_by, create_time, update_by, update_time, remark from app_skill
    </sql>

    <select id="getList" parameterType="AppSkill" resultMap="AppSkillResult">
        <include refid="selectAppSkillVo"/>
        <where>  del_flag = '0'
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="levels != null  and levels != ''"> and levels = #{levels}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
        </where>
    </select>

    <insert id="batchInsert" parameterType="AppSkill">
        INSERT INTO app_skill (
        user_id, name, levels, create_by, create_time, del_flag
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.userId}, #{item.name}, #{item.levels},
            #{item.createBy}, #{item.createTime}, #{item.delFlag}
            )
        </foreach>
    </insert>

    <resultMap type="com.ruoyi.cms.domain.vo.AppSkillVo" id="AppSkillVoResult">
        <result property="userId" column="user_id"/>
        <result property="name" column="name"/>
        <result property="levels" column="levels"/>
    </resultMap>

    <select id="getUserSkillList" parameterType="com.ruoyi.cms.domain.vo.AppSkillVo" resultMap="AppSkillVoResult">
        select name, levels,user_id from app_skill
        <where>  del_flag = '0'
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="levels != null  and levels != ''"> and levels = #{levels}</if>
            <if test="userId != null"> and user_id = #{userId}</if>
        </where>
    </select>

</mapper>
