<?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="org.springblade.modules.sqjw.sydw.mapper.CyryMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="blogResultMap" type="org.springblade.modules.sqjw.sydw.pojo.entity.CyryEntity">
        <result column="id" property="id"/>
    </resultMap>

    <update id="updatezxById">
        update jdrh.ybss_cyry set zxyy = #{zxyy}, sjgxbs = '2', is_deleted = 1, update_user = #{updateUser}, update_time = now() where id = #{id}
    </update>

    <select id="selectCyryByXydm" resultType="org.springblade.modules.sqjw.sydw.pojo.entity.CyryEntity">
        select * from jdrh.ybss_cyry where is_deleted = 0 and tyshxydm = #{tyshxydm}
    </select>

    <select id="selectCyryBySfzh" resultType="org.springblade.modules.sqjw.sydw.pojo.entity.CyryEntity">
        select
            yc.*,
            ys.dwmc
        from jdrh.ybss_cyry yc
        left join jdrh.ybss_sydw ys on yc.tyshxydm = ys.tyshxydm
        where yc.is_deleted = 0 and yc.gmsfhm = #{gmsfhm}
    </select>

    <select id="getFwxzByRkDzxx" resultType="java.lang.String">
        select xz from sspt.rk_dzxx where dzbm = #{dzbm} limit 1
    </select>

    <update id="updateCyry">
        update jdrh.ybss_cyry set is_deleted = 1 where gmsfhm = #{gmsfhm}
    </update>

    <select id="djxx" resultType="org.springblade.modules.sqjw.sydw.pojo.vo.UserVO">
        select
            bu.sfzh,
            (select dept_name from jdrh.blade_dept where blade_dept.id = bu.dept_id :: int8) as sssq,
            (select dept_name from jdrh.blade_dept where blade_dept.id = bd.parent_id) as sspcs
        from JDRH.blade_user bu
        left join jdrh.blade_dept bd on bu.dept_id :: int8 = bd.id
        where bu.is_deleted = 0 and bu.id = #{userId}
    </select>
</mapper>
