<?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.changhu.module.securityManagement.mapper.Service_ProjectMapper">
    <select id="pager" resultType="com.changhu.module.securityManagement.pojo.vo.ServiceProjectPagerVo">
        select
        sp.*,
        JSON_ARRAY(eu.province,eu.city,eu.districts,eu.street) as 'enterprisesUnitAdministrativeDivisionCodes',
        eu.name as 'enterprisesUnitName',
        mpu.name as 'projectManagerMiniProgramUserName',
        msuu.name as 'createUserName'
        from service_project sp
        left join enterprises_unit eu on sp.enterprises_unit_id = eu.snow_flake_id
        left join mini_program_user mpu on sp.project_manager_mini_program_user_id = mpu.snow_flake_id
        left join management_security_unit_user msuu on sp.create_by = msuu.snow_flake_id
        where sp.delete_flag = 0
        and sp.security_unit_id = ${@com.changhu.common.utils.UserUtil@getUnitId()}
        <if test="params.name!=null and params.name!=''">
            and sp.name like concat('%',#{params.name},'%')
        </if>
        <if test="params.type!=null">
            and sp.type = #{params.type.value}
        </if>
        <if test="params.remark!=null and params.remark!=''">
            and sp.remark like concat('%',#{params.remark},'%')
        </if>
        <if test="params.projectManagerMiniProgramUserName!=null and params.projectManagerMiniProgramUserName!=''">
            and mpu.name like concat('%',#{params.projectManagerMiniProgramUserName},'%')
        </if>
        order by sp.create_time desc
    </select>
</mapper>