<?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.ruoyi.interfaces.mapper.MyAttentionMapper">

    <resultMap id="BaseResultMap" type="com.ruoyi.interfaces.domain.PtService">
        <id column="ATTENTION_ID" jdbcType="VARCHAR" property="attentionId"/>
        <id column="SRV_ID" jdbcType="VARCHAR" property="srvId"/>
        <result column="CATE_CODE" jdbcType="VARCHAR" property="cateCode"/>
        <result column="NAME" jdbcType="VARCHAR" property="name"/>
        <result column="TYPE" jdbcType="VARCHAR" property="type"/>
        <result column="INTRO" jdbcType="VARCHAR" property="intro"/>
        <result column="URL" jdbcType="VARCHAR" property="url"/>
        <result column="RQTYPE" jdbcType="VARCHAR" property="rqtype"/>
        <result column="RPTYPE" jdbcType="VARCHAR" property="rptype"/>
        <result column="STATUS" jdbcType="VARCHAR" property="status"/>
        <result column="CNT" jdbcType="DECIMAL" property="cnt"/>
        <result column="USER_ID" jdbcType="VARCHAR" property="userId"/>
        <result column="TM" jdbcType="VARCHAR" property="tm"/>
        <result column="RPCONTENT" jdbcType="CLOB" property="rpcontent"/>
        <result column="NOTE" jdbcType="CLOB" property="note"/>
        <result column="EXAMPLE" jdbcType="CLOB" property="example"/>
        <result column="PROXY_ADDRESS" jdbcType="VARCHAR" property="proxyAddress"/>
        <result column="PROXY_PATH" jdbcType="VARCHAR" property="proxyPath"/>
        <result column="SERVICE_SOURCE" jdbcType="VARCHAR" property="serviceSource"/>
        <result property="serviceDept" column="SERVICE_DEPT" jdbcType="VARCHAR"/>
        <result property="manageName" column="MANAGE_NAME" jdbcType="VARCHAR"/>
        <result property="releaseTime" column="RELEASE_TIME" jdbcType="TIMESTAMP"/>
        <result property="developUnit" column="DEVELOP_UNIT" jdbcType="VARCHAR"/>
        <result property="developContacter" column="DEVELOP_CONTACTER" jdbcType="VARCHAR"/>
        <result property="maintainUnit" column="MAINTAIN_UNIT" jdbcType="VARCHAR"/>
        <result property="maintainContacer" column="MAINTAIN_CONTACER" jdbcType="VARCHAR"/>
        <result column="VIEW_NUM" jdbcType="DECIMAL" property="viewNum"/>
        <result column="UP_CYCL" property="upCycl"/>
        <result column="OPEN_CNDTN" property="openCndtn"/>
        <result column="AD_NAME" property="adName"/>
        <result column="DATA_FIELD" property="dataField"/>
        <result column="UPTM" property="uptm"/>
        <result column="RLSTM" property="rlstm"/>
        <result column="DATA_RANGE" property="dataRange"/>
        <result column="APPLY_NUM" property="applyNum"/>
        <result column="DATA_NUM" property="dataNum"/>
    </resultMap>

    <insert id="insert" parameterType="com.ruoyi.interfaces.domain.MyAttention">
        insert into MY_ATTENTION(ID, TITLE, URL, TM, USER_ID, SRV_ID)
        values (#{id}, #{title}, #{url}, #{tm}, #{userId}, #{srvId})
    </insert>

    <delete id="delete" parameterType="java.lang.Long">
        delete
        from MY_ATTENTION
        where ID = #{id}
    </delete>

    <select id="findByUserId" parameterType="java.lang.String" resultMap="BaseResultMap">
        select P.*,A.ID AS ATTENTION_ID
        from MY_ATTENTION A
        JOIN PT_SERVICE P ON A.SRV_ID = P.SRV_ID
        <if test="userId != null and userId !=''">
            where A.USER_ID = #{userId}
        </if>
    </select>

    <select id="findByMaxId" resultType="java.lang.Long">
        select nullif(MAX(ID) + 1, 1)
        from MY_ATTENTION
    </select>

    <select id="findByIsTrue" resultType="java.lang.Integer"
            parameterType="com.ruoyi.interfaces.domain.MyAttention">
        select count(*)
        from MY_ATTENTION
        where URL = #{url}
          and USER_ID = #{userId}
    </select>

    <select id="list" resultMap="BaseResultMap">
        select P.*,A.ID AS ATTENTION_ID
        from MY_ATTENTION A
        JOIN PT_SERVICE P ON A.SRV_ID = P.SRV_ID
        <where>
            <if test="userId != null and userId !=''">
                A.USER_ID = #{userId}
            </if>
            <if test="name != null and name !=''">
                and P.NAME LIKE CONCAT('%', CONCAT(#{name}, '%'))
            </if>
        </where>
    </select>
</mapper>
