<?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.yunzhi.marketing.xlk.mapper.CurriculumMapper">
    <update id="setFieldIncrement">
        UPDATE xlk_curriculum
        SET ${field} = IFNULL(${field}, 0) + #{increment}
        WHERE curriculum_id = #{curriculumId}
    </update>

    <select id="selectMySaveList" resultType="com.yunzhi.marketing.xlk.entity.Curriculum">
        SELECT
            x.*
        FROM
            ta_save t
                LEFT JOIN xlk_curriculum x ON t.saved_target = x.curriculum_id
        WHERE
            t.tagert_type = "curriculum"
          AND t.person_id = #{personId}
    </select>

    <select id="getWxList" resultType="com.yunzhi.marketing.xlk.entity.Curriculum">
        SELECT
        x.*
        FROM
        xlk_curriculum x
        WHERE
        x.ORG_ID = #{orgId}
        AND x.is_publish = 1
        <if test="name != null and name != ''">
            AND x.`name` like concat('%', #{name},'%')
        </if>
        AND x.role_id in
        <foreach collection="roleList" item="role" open="(" close=")" separator=",">
            #{role}
        </foreach>
        ORDER BY x.WEIGHT DESC, CREATED_TIME DESC
    </select>
</mapper>
