<?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.gxwebsoft.oa.mapper.OaAssetsDomainMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*, b.short_name AS tenantName,b.company_logo as logo
        FROM oa_assets_domain a
      LEFT JOIN gxwebsoft_core.sys_company b ON a.tenant_id = b.tenant_id
        <where>
            <if test="param.domainId != null">
                AND a.domain_id = #{param.domainId}
            </if>
            <if test="param.assetsId != null">
                AND a.assets_id = #{param.assetsId}
            </if>
            <if test="param.name != null">
                AND a.name LIKE CONCAT('%', #{param.name}, '%')
            </if>
            <if test="param.code != null">
                AND a.code LIKE CONCAT('%', #{param.code}, '%')
            </if>
            <if test="param.brand != null">
                AND a.brand LIKE CONCAT('%', #{param.brand}, '%')
            </if>
            <if test="param.account != null">
                AND a.account LIKE CONCAT('%', #{param.account}, '%')
            </if>
            <if test="param.password != null">
                AND a.password LIKE CONCAT('%', #{param.password}, '%')
            </if>
            <if test="param.price != null">
                AND a.price = #{param.price}
            </if>
            <if test="param.startTime != null">
                AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
            </if>
            <if test="param.endTime != null">
                AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
            </if>
            <if test="param.isTop != null">
                AND a.is_top LIKE CONCAT('%', #{param.isTop}, '%')
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.userIds != null">
                AND a.user_ids LIKE CONCAT('%', #{param.userIds}, '%')
            </if>
            <if test="param.status != null">
                AND a.status LIKE CONCAT('%', #{param.status}, '%')
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.OaAssetsDomain">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.oa.entity.OaAssetsDomain">
        <include refid="selectSql"></include>
    </select>

</mapper>
