wl
2022-10-17 d46beba25ccb64a1047a98d642b6ce45e82f0bee
ycl-common/src/main/resources/mapper/depart/UmsDepartMapper.xml
@@ -4,30 +4,57 @@
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.entity.depart.UmsDepart">
        <id column="id" property="id" />
        <result column="depart_name" property="departName" />
        <result column="depart_des" property="departDes" />
        <result column="depart_type" property="departType" />
        <result column="parent_id" property="parentId" />
        <result column="status" property="status" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="is_deleted" property="isDeleted" />
        <id column="id" property="id"/>
        <result column="depart_name" property="departName"/>
        <result column="depart_des" property="departDes"/>
        <result column="depart_type" property="departType"/>
        <result column="parent_id" property="parentId"/>
        <result column="status" property="status"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
    <resultMap type="com.ycl.entity.depart.UmsDepart" id="UserDepartResultMap" extends="BaseResultMap">
        <collection property="userInfoDTOS" javaType="ArrayList" ofType="com.ycl.dto.user.DepartUserDTO">
            <id column="user_id" property="userId" />
            <result column="username" property="username" />
            <id column="user_id" property="userId"/>
            <result column="username" property="username"/>
        </collection>
    </resultMap>
    <select id="selectDepartList"  resultMap="UserDepartResultMap">
        SELECT
            ud.*,ua.id user_id,ua.username
        FROM
            ums_depart ud
                LEFT JOIN ums_depart_manager udm ON ud.id = udm.depart_id
                LEFT JOIN ums_admin ua ON udm.user_id = ua.id
    <resultMap id="DepartVOMap" type="com.ycl.vo.depart.UmsDepartVO" extends="BaseResultMap">
        <result column="depart_type_name" property="departTypeName" jdbcType="VARCHAR"></result>
        <collection property="userInfoDTOS" javaType="ArrayList" ofType="com.ycl.dto.user.DepartUserDTO">
            <id column="user_id" property="userId"/>
            <result column="username" property="username"/>
        </collection>
    </resultMap>
    <select id="selectDepartList" resultMap="UserDepartResultMap">
        SELECT ud.*,
               ua.id user_id,
               ua.username
        FROM ums_depart ud
                 LEFT JOIN ums_depart_manager udm ON ud.id = udm.depart_id
                 LEFT JOIN ums_admin ua ON udm.user_id = ua.id
    </select>
    <select id="selectPageByName" resultMap="DepartVOMap">
        SELECT t_0.*,
        ua.id user_id,
        ua.username,
        dd.`name` as depart_type_name
        FROM (
        SELECT ud.*
        FROM ums_depart ud
        WHERE is_deleted = 0
        <if test="departName!=null and departName!=''">
            and ud.name like CONCAT('%',#{departName},'%')
        </if>
        ORDER BY create_time desc
        LIMIT #{offset}, #{size}
        ) t_0
        LEFT JOIN ums_depart_manager udm ON t_0.id = udm.depart_id
        LEFT JOIN ums_admin ua ON udm.user_id = ua.id
        left join ums_data_dictionary as dd on t_0.depart_type = dd.id
    </select>