<?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.jeecg.modules.ai.mapper.YsDirectoryMapper">

	<resultMap id="baseResultMap" type="org.jeecg.modules.ai.vo.YsDirectoryVo" >
		<result column="id" property="id" jdbcType="VARCHAR"/>
		<result column="event_name" property="eventName" jdbcType="VARCHAR"/>
		<result column="event_code" property="eventCode" jdbcType="VARCHAR"/>
		<result column="depart_name" property="departName" jdbcType="VARCHAR"/>
		<result column="valid_status" property="validStatus" jdbcType="VARCHAR"/>
		<result column="evtent_type" property="evtentType" jdbcType="INTEGER"/>
		<result column="del_flag" property="delFlag" jdbcType="INTEGER"/>
		<result column="source_of_rights" property="sourceOfRights" jdbcType="INTEGER"/>
	</resultMap>
	
	<sql id="ysdirectory_column_body">
         a.id,a.event_name,a.event_code,a.del_flag,a.evtent_type,b.depart_name,a.source_of_rights,
         a.valid_status
    </sql>
	
	<sql id="ysdirectory_select_body">
    	<where>
    		<if test="query.eventName != null and query.eventName != ''"> and a.event_name like CONCAT('%', #{query.eventName}, '%') </if>
    		<if test="query.orgCode != null and query.orgCode != ''"> and a.sys_org_code = #{query.orgCode,jdbcType=VARCHAR} </if>
    		<if test="query.orgId != null and query.orgId != ''"> and b.id = #{query.orgId,jdbcType=VARCHAR} </if>
    		<if test="query.eventType != null"> and b.event_type = #{query.eventType,jdbcType=INTEGER} </if>
    		<if test="query.delFlag != null"> and a.del_flag = #{query.delFlag,jdbcType=INTEGER} </if>
    		<if test="query.validStatus != null"> and a.valid_status = #{query.validStatus,jdbcType=INTEGER} </if>
    	</where>
    </sql>

	<select id="getYsDirectoryList" resultMap="baseResultMap" >
		select <include refid="ysdirectory_column_body" />
		from ys_directory a 
		left join sys_depart b on a.sys_org_code = b.depart_code
		<include refid="ysdirectory_select_body" /> 
	</select>

	

	<select id="getYsDirectoryByCode" resultType="org.jeecg.modules.ai.entity.YsDirectory">
		select * from  ys_directory  where event_code = #{eventCode}
	</select>

</mapper>