<?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.custom.mapper.TrademarkAuthMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="trademarkAuthResultMap" type="org.springblade.modules.custom.entity.TrademarkAuth">
        <result column="id" property="id"/>
        <result column="is_delete" property="isDelete"/>
        <result column="create_user_id" property="createUserId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user_id" property="updateUserId"/>
        <result column="update_time" property="updateTime"/>
        <result column="user_id" property="userId"/>
        <result column="trademark_id" property="trademarkId"/>
        <result column="auth_type" property="authType"/>
        <result column="use_period" property="usePeriod"/>
    </resultMap>


    <select id="selectTrademarkAuthPage" resultMap="trademarkAuthResultMap">
        select * from biz_trademark_auth where is_delete = 0
    </select>
    <select id="authRecord" resultType="org.springblade.modules.custom.vo.TrademarkAuthVO">
        SELECT
            ta.*,
            t.NAME,
            t.logo
        FROM
            biz_trademark_auth ta
            JOIN biz_trademark t ON ta.trademark_id = t.id
        WHERE
            ta.user_id = #{userId}
        <if test="type == 1">
            and ta.use_period <![CDATA[ >= ]]> now()
        </if>
        <if test="type == 2">
            and ta.use_period <![CDATA[ < ]]> now()
        </if>
    </select>


</mapper>
