<?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.izouma.awesomeadmin.dao.GenCodeMapper" >
	<resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.GenCode" >
		<id column="id" property="id" jdbcType="INTEGER" />
		<result column="tableName" property="tableName" jdbcType="VARCHAR" />
		<result column="className" property="className" jdbcType="VARCHAR" />
		<result column="remark" property="remark" jdbcType="VARCHAR" />
		<result column="genTable" property="genTable" jdbcType="BIT" />
		<result column="genClass" property="genClass" jdbcType="BIT" />
		<result column="genList" property="genList" jdbcType="BIT" />
		<result column="genForm" property="genForm" jdbcType="BIT" />
		<result column="field_id" property="fieldId" jdbcType="VARCHAR" />
		<collection property="fields" column="field_id" ofType="com.izouma.awesomeadmin.model.TableField" select="selectTableField"/>
	</resultMap>
	<select id="selectTableField" parameterType="string" resultType="com.izouma.awesomeadmin.model.TableField">
        select * from table_field where FIND_IN_SET(id, #{field_id})
    </select>
	<sql id="Base_Column_List" >
		 id, tableName, className, remark, genTable, genClass, genList, genForm, field_id
	</sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
		select
		<include refid="Base_Column_List" />
		from gen_code
		where id = #{id,jdbcType=INTEGER}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
		delete from gen_code
		where id = #{id,jdbcType=INTEGER}
	</delete>
	<insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.GenCode" useGeneratedKeys="true" keyProperty="id">
		insert into gen_code
		<trim prefix="(" suffix=")" suffixOverrides="," >
			<if test="id != null" >
				id,	
			</if>
			<if test="tableName != null" >
				tableName,	
			</if>
			<if test="className != null" >
				className,	
			</if>
			<if test="remark != null" >
				remark,	
			</if>
			<if test="genTable != null" >
				genTable,	
			</if>
			<if test="genClass != null" >
				genClass,	
			</if>
			<if test="genList != null" >
				genList,	
			</if>
			<if test="genForm != null" >
				genForm,	
			</if>
			<if test="fieldId != null" >
				field_id,	
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides="," >
			<if test="id != null" >
				#{id,jdbcType=INTEGER},	
			</if>
			<if test="tableName != null" >
				#{tableName,jdbcType=VARCHAR},	
			</if>
			<if test="className != null" >
				#{className,jdbcType=VARCHAR},	
			</if>
			<if test="remark != null" >
				#{remark,jdbcType=VARCHAR},	
			</if>
			<if test="genTable != null" >
				#{genTable,jdbcType=BIT},	
			</if>
			<if test="genClass != null" >
				#{genClass,jdbcType=BIT},	
			</if>
			<if test="genList != null" >
				#{genList,jdbcType=BIT},	
			</if>
			<if test="genForm != null" >
				#{genForm,jdbcType=BIT},	
			</if>
			<if test="fieldId != null" >
				#{fieldId,jdbcType=VARCHAR},	
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.GenCode" >
		update gen_code
		<set >
			<if test="tableName != null" >
				tableName = #{tableName,jdbcType=VARCHAR},	
			</if>
			<if test="className != null" >
				className = #{className,jdbcType=VARCHAR},	
			</if>
			<if test="remark != null" >
				remark = #{remark,jdbcType=VARCHAR},	
			</if>
			<if test="genTable != null" >
				genTable = #{genTable,jdbcType=BIT},	
			</if>
			<if test="genClass != null" >
				genClass = #{genClass,jdbcType=BIT},	
			</if>
			<if test="genList != null" >
				genList = #{genList,jdbcType=BIT},	
			</if>
			<if test="genForm != null" >
				genForm = #{genForm,jdbcType=BIT},	
			</if>
			<if test="fieldId != null" >
				field_id = #{fieldId,jdbcType=VARCHAR},	
			</if>
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>
	<select id="queryGenCodeByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.GenCode">
		select <include refid="Base_Column_List"/> from gen_code
		<where>
			and del_flag = 'N'
			<if test="record.id != null and !&quot;&quot;.equals(record.id)">
				and id = #{record.id}	
			</if>
			<if test="record.tableName != null and !&quot;&quot;.equals(record.tableName)">
				and tableName = #{record.tableName}	
			</if>
			<if test="record.className != null and !&quot;&quot;.equals(record.className)">
				and className = #{record.className}	
			</if>
			<if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
				and remark = #{record.remark}	
			</if>
			<if test="record.genTable != null and !&quot;&quot;.equals(record.genTable)">
				and genTable = #{record.genTable}	
			</if>
			<if test="record.genClass != null and !&quot;&quot;.equals(record.genClass)">
				and genClass = #{record.genClass}	
			</if>
			<if test="record.genList != null and !&quot;&quot;.equals(record.genList)">
				and genList = #{record.genList}	
			</if>
			<if test="record.genForm != null and !&quot;&quot;.equals(record.genForm)">
				and genForm = #{record.genForm}	
			</if>
			<if test="record.fieldId != null and !&quot;&quot;.equals(record.fieldId)">
				and field_id = #{record.fieldId}	
			</if>
		</where>
		order by id desc
	</select>
	<select id="queryAllGenCode" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.GenCode">
		select <include refid="Base_Column_List"/> from gen_code
		<where>
			and del_flag = 'N'
			<if test="id != null and !&quot;&quot;.equals(id)">
				and id = #{id}	
			</if>
			<if test="tableName != null and !&quot;&quot;.equals(tableName)">
				and tableName = #{tableName}	
			</if>
			<if test="className != null and !&quot;&quot;.equals(className)">
				and className = #{className}	
			</if>
			<if test="remark != null and !&quot;&quot;.equals(remark)">
				and remark = #{remark}	
			</if>
			<if test="genTable != null and !&quot;&quot;.equals(genTable)">
				and genTable = #{genTable}	
			</if>
			<if test="genClass != null and !&quot;&quot;.equals(genClass)">
				and genClass = #{genClass}	
			</if>
			<if test="genList != null and !&quot;&quot;.equals(genList)">
				and genList = #{genList}	
			</if>
			<if test="genForm != null and !&quot;&quot;.equals(genForm)">
				and genForm = #{genForm}	
			</if>
			<if test="fieldId != null and !&quot;&quot;.equals(fieldId)">
				and field_id = #{fieldId}	
			</if>
		</where>
		order by id desc
	</select>
	<select id="queryGenCode" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.GenCode">
		select <include refid="Base_Column_List"/> from gen_code
		<where>
			and del_flag = 'N'
			<if test="id != null and !&quot;&quot;.equals(id)">
				and id = #{id}	
			</if>
			<if test="tableName != null and !&quot;&quot;.equals(tableName)">
				and tableName = #{tableName}	
			</if>
			<if test="className != null and !&quot;&quot;.equals(className)">
				and className = #{className}	
			</if>
			<if test="remark != null and !&quot;&quot;.equals(remark)">
				and remark = #{remark}	
			</if>
			<if test="genTable != null and !&quot;&quot;.equals(genTable)">
				and genTable = #{genTable}	
			</if>
			<if test="genClass != null and !&quot;&quot;.equals(genClass)">
				and genClass = #{genClass}	
			</if>
			<if test="genList != null and !&quot;&quot;.equals(genList)">
				and genList = #{genList}	
			</if>
			<if test="genForm != null and !&quot;&quot;.equals(genForm)">
				and genForm = #{genForm}	
			</if>
			<if test="fieldId != null and !&quot;&quot;.equals(fieldId)">
				and field_id = #{fieldId}	
			</if>
		</where>
		LIMIT 1
	</select>
	<update id="delete">
		UPDATE gen_code SET del_flag = 'Y'
		<where>
			AND id = #{id}
		</where>
	</update>
</mapper>

