<?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.mosty.rwzx.mapper.TbRwTaskUserMapper">
    <select id="selectByRwId" resultType="com.mosty.base.model.entity.rwzx.TbRwTaskUser">
        select *
        from tb_rw_task_user a
        where a.xt_scbz = '0'
          and a.xt_sjzt = '1'
          and a.rwid = #{rwid}
          and case
                when a.rwjsdx = '01' then a.jsrsfzh = #{sfzh}

                when a.rwjsdx = '03' then
                        a.jsxzid in (select c.id
                                     from mosty_qwgl.tb_qw_xfbb c,
                                          mosty_qwgl.tb_qw_jl d
                                     where c.id = d.ywid
                                       and c.xt_sjzt = '1'
                                       and c.xt_scbz = '0'
                                       and d.xt_sjzt = '1'
                                       and d.xt_scbz = '0'
                                       and (c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))

                when a.rwjsdx = '02' then
                        a.jsbmdm = #{ssbmid}
                end
    </select>

    <delete id="deleteEntity">
        delete
        from tb_rw_task_user
        where id = #{id}
    </delete>
</mapper>