<?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.zcloud.mapper.dsno2.bus.ClassInfoMapper">

	<!--表名 -->
	<sql id="tableName">
		BUS_CLASS_INFO
	</sql>

	<!--数据字典表名 -->
	<sql id="dicTableName">
		SYS_DICTIONARIES
	</sql>

	<!-- 字段 -->
	<sql id="Field">
		f.CREATE_TIME,
		f.CREATOR,
		f.OPERATE_TIME,
		f.OPERATOR,
		f.ISDELETE,
		f.CORPINFO_ID,
		f.USER_ID,
		f.STATUS,
		f.CLASS_MESSAGE_ID,
		f.CLASS_INFO_ID,
		f.USERNAME,
		f.NAME,
		f.SEX,
		f.CARD_ID,
		f.RELEVANT_UNIT_NAME,
		f.DEPARTMENT_NAME,
		f.PHOTO,
		f.PHONE,
		f.PERSON_WORK_TYPE,
		f.CERTIFICATE,
		f.CLASS_NO,
		f.TRAINUSERS_ID
	</sql>

	<!-- 字段用于新增 -->
	<sql id="Field2">
		CREATE_TIME,
		CREATOR,
		OPERATE_TIME,
		OPERATOR,
		ISDELETE,
		CORPINFO_ID,
		USER_ID,
		STATUS,
		CLASS_MESSAGE_ID,
		CLASS_INFO_ID,
		USERNAME,
		NAME,
		SEX,
		CARD_ID,
		RELEVANT_UNIT_NAME,
		DEPARTMENT_NAME,
		PHOTO,
		PHONE,
		PERSON_WORK_TYPE,
		CERTIFICATE,
		CLASS_NO,
		TRAINUSERS_ID
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{CREATE_TIME},
		#{CREATOR},
		#{OPERATE_TIME},
		#{OPERATOR},
		#{ISDELETE},
		#{CORPINFO_ID},
		#{USER_ID},
		#{STATUS},
		#{CLASS_MESSAGE_ID},
		#{CLASS_INFO_ID},
		#{USERNAME},
		#{NAME},
		#{SEX},
		#{CARD_ID},
		#{RELEVANT_UNIT_NAME},
		#{DEPARTMENT_NAME},
		#{PHOTO},
		#{PHONE},
		#{PERSON_WORK_TYPE},
		#{CERTIFICATE},
		#{CLASS_NO},
		#{TRAINUSERS_ID}
	</sql>


	<!-- 通过ID获取数据 -->
	<select id="getClassinfo" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		where
		f.TRAINUSERS_ID = #{TRAINUSERS_ID} order by OPERATE_TIME limit 1
	</select>


	<select id="findinfoByCondition" resultType="com.zcloud.entity.PageData">
		select distinct
		a.CREATE_TIME,
		a.CREATOR,
		a.OPERATE_TIME,
		a.OPERATOR,
		a.ISDELETE,
		a.CORPINFO_ID,
		a.USER_ID,
		a.STATUS,
		a.CLASS_MESSAGE_ID,
		a.CLASS_INFO_ID,
		a.USERNAME,
		a.NAME,
		a.SEX,
		a.CARD_ID,
		a.RELEVANT_UNIT_NAME,
		a.DEPARTMENT_NAME,
		a.PHOTO,
		a.PHONE,
		a.PERSON_WORK_TYPE as JOBS_TYPE,
		a.CERTIFICATE,
		a.CLASS_NO,
		a.TRAINUSERS_ID,
		b.OPENING_TIME,
		b.VALIDITY_PERIOD_END
		from bus_class_info a
		left join bus_class_message b on a.CLASS_MESSAGE_ID = b.CLASS_MESSAGE_ID
		where a.ISDELETE = '0' and a.STATUS = '1'
		<if test="CLASS_MESSAGE_ID != null and CLASS_MESSAGE_ID != ''">
			and a.CLASS_MESSAGE_ID = #{CLASS_MESSAGE_ID}
		</if>
		<if test="CLASS_INFO_ID != null and CLASS_INFO_ID != ''">
			and a.CLASS_INFO_ID = #{CLASS_INFO_ID}
		</if>
	</select>


</mapper>
