<?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.zcloud.personnel.positioning.persistence.mapper.UserMapper">
    <select id="selectBiPersonPositionUsers"
            resultType="com.zcloud.personnel.positioning.persistence.dataobject.BiPersonPositionUserDO">
        SELECT
            u.id AS userId,
            u.username AS username,
            u.name AS personName,
            TRIM(u.phone) AS mobileNo,
            u.user_id_card AS idCardNo,
            CAST(u.corpinfo_id AS CHAR) AS corpinfoId,
            ci.corp_name AS corpinfoName
        FROM `user` u
        LEFT JOIN corp_info ci
            ON CAST(ci.corpinfo_id AS CHAR) = CAST(u.corpinfo_id AS CHAR)
        WHERE (u.delete_enum IS NULL OR u.delete_enum = 'FALSE')
          AND CAST(u.corpinfo_id AS CHAR) = CAST(#{corpinfoId} AS CHAR)
        ORDER BY u.id DESC
    </select>
</mapper>
