<?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.invadedefenceresource.dao.InvadeDefenceResourceDao">
  <!-- Result Map -->
  <resultMap id="BaseResultMap" type="com.devplatform.equipment.modules.invadedefenceresource.bean.InvadeDefenceResource">
    <result column="id" property="id"/>
    <result column="defence_id" property="defenceId"/>
    <result column="resource_id" property="resourceId"/>
    <result column="byx1" property="byx1"/>
    <result column="byx2" property="byx2"/>
    <result column="byx3" property="byx3"/>
    <result column="sys_sign" property="sysSign"/>
    <result column="station_id" property="stationId"/>
    <result column="deleted" property="deleted"/>
  </resultMap>

  <!-- invade_defence_resource table all fields -->
  <sql id="Base_Column_List">
		id,defence_id,resource_id,byx1,byx2,byx3,sys_sign,station_id,deleted
	</sql>

  <!-- 公共查询条件 -->
  <sql id="Example_Where_Clause">
    where deleted=0
    <if test="id!=null and id!=''">and id = #{id}</if>
    <if test="defenceId!=null and defenceId!=''">and defence_id = #{defenceId}</if>
    <if test="resourceId!=null and resourceId!=''">and resource_id = #{resourceId}</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="sysSign!=null and sysSign!=''">and sys_sign = #{sysSign}</if>
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
    <if test="deleted!=null ">and deleted = #{deleted}</if>
  </sql>
  <delete id="deleteByDefenceId">
    DELETE FROM invade_defence_resource WHERE defence_id =#{id}
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
  </delete>
  <select id="getByDefenceId"
    resultType="com.devplatform.equipment.modules.invadedefenceresource.bean.InvadeDefenceResource">
    SELECT resource_id FROM invade_defence_resource WHERE defence_id=#{defenceId}
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
  </select>
  <select id="getAllResourceId" parameterType="string" resultType="java.lang.String">
    select resource_id from invade_defence_resource
    where deleted=0
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
    group by resource_id
  </select>
</mapper>


