<?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.devplatform.equipment.modules.link.dao.LinkResourceActionDao">
  <!-- Result Map -->
  <resultMap id="BaseResultMap" type="com.devplatform.equipment.modules.link.bean.LinkResourceAction">
    <result column="id" property="id"/>
    <result column="resource_type" property="resourceType"/>
    <result column="action_id" property="actionId"/>
    <result column="sys_sign" property="sysSign"/>
    <result column="byx1" property="byx1"/>
    <result column="byx2" property="byx2"/>
    <result column="byx3" property="byx3"/>
    <result column="deleted" property="deleted"/>
    <result column="station_id" property="stationId"/>
  </resultMap>

  <!-- link_resource_action table all fields -->
  <sql id="Base_Column_List">
        id,resource_type,action_id,sys_sign,byx1,byx2,byx3,deleted,station_id
    </sql>

  <!-- 公共查询条件 -->
  <sql id="Example_Where_Clause">
    where deleted=0
    <if test="id!=null and id!=''">and id = #{id}</if>
    <if test="resourceType!=null and resourceType!=''">and resource_type = #{resourceType}</if>
    <if test="actionId!=null and actionId!=''">and action_id = #{actionId}</if>
    <if test="sysSign!=null and sysSign!=''">and sys_sign = #{sysSign}</if>
    <if test="byx1!=null and byx1!=''">and byx1 = #{byx1}</if>
    <if test="byx2!=null and byx2!=''">and byx2 = #{byx2}</if>
    <if test="byx3!=null and byx3!=''">and byx3 = #{byx3}</if>
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
    <if test="deleted!=null and deleted!=''">and deleted = #{deleted}</if>
  </sql>

  <sql id="Example_Where_Clause1">
    where la.deleted=0
    <if test="model.id!=null and model.id!=''">and t.id = #{model.id}</if>
    <if test="model.resourceType!=null and model.resourceType!=''">and t.resource_type = #{model.resourceType}</if>
    <if test="model.actionId!=null and model.actionId!=''">and t.action_id = #{model.actionId}</if>
    <if test="model.sysSign!=null and model.sysSign!=''">and t.sys_sign = #{model.sysSign}</if>
    <if test="model.byx1!=null and model.byx1!=''">and t.byx1 = #{model.byx1}</if>
    <if test="model.byx2!=null and model.byx2!=''">and t.byx2 = #{model.byx2}</if>
    <if test="model.byx3!=null and model.byx3!=''">and t.byx3 = #{model.byx3}</if>
    <if test="model.stationId!=null and model.stationId!=''">and t.station_id = #{model.stationId}</if>
    <if test="model.deleted!=null and model.deleted!=''">and t.deleted = #{model.deleted}</if>
  </sql>


  <select id="getActionByResourceId" resultType="java.util.Map">
    SELECT t.*, la.action_info,la.params_name1,la.params_name2,la.byx1 AS unit1,
    la.byx2 AS unit2
    FROM link_resource_action t
    LEFT JOIN link_action la ON t.action_id = la.id and t.station_id = la.station_id
    WHERE la.deleted = 0 and t.resource_type = #{resourceType}
    <if test="stationId!=null and stationId!=''">and t.station_id = #{stationId}</if>
  </select>

  <select id="queryPageByCount" resultType="java.lang.Integer">
    select count(1)
    FROM link_resource_action t
    LEFT JOIN link_action la ON t.action_id = la.id and t.station_id = la.station_id
    <include refid="Example_Where_Clause1"/>
  </select>

  <select id="queryPageList" resultType="java.util.Map">
    SELECT t.*, la.action_info,la.params_name1,la.params_name2,la.byx1 AS unit1,
    la.byx2 AS unit2
    FROM link_resource_action t
    LEFT JOIN link_action la ON t.action_id = la.id and t.station_id = la.station_id
    <include refid="Example_Where_Clause1"/>
    <if test="model.pager.orderCondition != null and model.pager.orderCondition != ''">
      ${model.pager.orderCondition}
    </if>
    <if test="model.pager.mysqlQueryCondition != null and model.pager.mysqlQueryCondition != ''">
      ${model.pager.mysqlQueryCondition}
    </if>
  </select>


</mapper>


