<?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.userJwd.mapper.UserJwdMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="userJwdResultMap" type="org.springblade.modules.userJwd.entity.UserJwdEntity">
        <result column="id" property="id"/>
        <result column="jd" property="jd"/>
        <result column="wd" property="wd"/>
        <result column="create_time" property="createTime"/>
    </resultMap>

    <select id="getUserList" resultType="org.springblade.modules.system.entity.User">
        SELECT
            bu.id,
            bu.dept_id
        FROM
            jdrh.user_jwd jwd
        LEFT JOIN jdrh.blade_user bu ON bu.id = jwd.create_user
        WHERE
            jwd.create_time :: DATE = CURRENT_DATE
        GROUP BY
            bu.id,
            bu.dept_id
    </select>

    <select id="getByUserId" resultType="org.springblade.modules.userJwd.vo.UserJwdVO">
        select
            id,
            '(' || wd || ',' || jd || ')' AS jwd
        from
            jdrh.user_jwd jwd
        where is_deleted = 0 and jwd.create_time :: DATE = CURRENT_DATE and create_user = #{id}
    </select>

    <select id="isContained" resultType="boolean">
        SELECT
            pt_contained_poly ( #{jwd} :: point, #{dkfw} :: polygon )
    </select>

    <update id="updateStatus" parameterType="org.springblade.modules.userJwd.vo.UserJwdVO">
        UPDATE jdrh.user_jwd
        SET status = 15
        WHERE
            id = #{id}
    </update>
</mapper>
