<?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.hxhq.business.mapper.GspMapper">
    <select id="queryStudyList" resultType="com.hxhq.business.dto.gsp.GspListDto">
        select t.id,t.mc,t.bh, t.ph, t.gg,t.ggdw, t.yxq,t.kc,t.kcdw,t.zjzt
        FROM  `t_gsp` t
        join  `t_study_gsp` ts on t.id=ts.resource_id
        <if test="ew.sqlSegment != '' and ew.sqlSegment != null">
            <where>
                ${ew.sqlSegment}
            </where>
        </if>
    </select>
    <select id="queryInfo" resultType="com.hxhq.business.dto.gsp.GspDto">
        select t.*,
               (select GROUP_CONCAT(s.name) from t_study s where find_in_set(s.id, t.`md_ids`)) as mdMcs
        FROM `t_gsp` t
        where t.id=#{id}
    </select>

    <update id="updateKcBatch">
        UPDATE t_gsp SET kc = #{kc} WHERE id in
        <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>
    <update id="updateCc">
        UPDATE t_gsp SET cctj = #{cctj}, ccwz = #{ccwz} WHERE id in
        <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>
    <update id="updateKc">
        UPDATE t_gsp SET kc = #{kc} WHERE id = #{id}
    </update>
</mapper>