StandardMapper.xml 4.51 KB
<?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.yoho.search.dal.StandardMapper">

    <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.Standard">
		<id column="id" property="id" jdbcType="INTEGER" />
		<result column="standard_name" property="standardName"
			jdbcType="VARCHAR" />
		<result column="standard_sort_id" property="standardSortId"
			jdbcType="INTEGER" />
		<result column="sort_id" property="sortId" jdbcType="INTEGER" />
		<result column="order_by" property="orderBy" jdbcType="INTEGER" />
		<result column="unit" property="unit" jdbcType="VARCHAR" />
		<result column="box_view" property="boxView" jdbcType="CHAR" />
		<result column="search_view" property="searchView" jdbcType="CHAR" />
		<result column="parameter_make" property="parameterMake"
			jdbcType="CHAR" />
		<result column="search_make" property="searchMake" jdbcType="CHAR" />
		<result column="search_order_by" property="searchOrderBy"
			jdbcType="INTEGER" />
		<result column="status" property="status" jdbcType="INTEGER" />
	</resultMap>

    <sql id="Base_Column_List">
		id, standard_name, standard_sort_id, sort_id, order_by,
		unit, box_view,
		search_view,
		parameter_make, search_make,
		search_order_by, status
	</sql>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
		parameterType="java.lang.Integer" timeout="20000">
		select
		<include refid="Base_Column_List" />
		from standard
		where id = #{id,jdbcType=INTEGER}
        limit 1
	</select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"
		timeout="20000">
		delete from standard
		where id = #{id,jdbcType=INTEGER}
	</delete>

    <insert id="insert" parameterType="com.yoho.search.dal.model.Standard"
		timeout="20000">
		insert ignore into standard (id, standard_name, standard_sort_id,
		sort_id, order_by, unit,
		box_view, search_view, parameter_make,
		search_make, search_order_by, status
		)
		values (#{id,jdbcType=INTEGER},
		#{standardName,jdbcType=VARCHAR},
		#{standardSortId,jdbcType=INTEGER},
		#{sortId,jdbcType=INTEGER}, #{orderBy,jdbcType=INTEGER},
		#{unit,jdbcType=VARCHAR},
		#{boxView,jdbcType=CHAR},
		#{searchView,jdbcType=CHAR},
		#{parameterMake,jdbcType=CHAR},
		#{searchMake,jdbcType=CHAR}, #{searchOrderBy,jdbcType=INTEGER},
		#{status,jdbcType=INTEGER}
		)
	</insert>

	<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.Standard"
		timeout="20000">
		update standard
		<set>
			<if test="standardName != null">
				standard_name = #{standardName,jdbcType=VARCHAR},
			</if>
			<if test="standardSortId != null">
				standard_sort_id = #{standardSortId,jdbcType=INTEGER},
			</if>
			<if test="sortId != null">
				sort_id = #{sortId,jdbcType=INTEGER},
			</if>
			<if test="orderBy != null">
				order_by = #{orderBy,jdbcType=INTEGER},
			</if>
			<if test="unit != null">
				unit = #{unit,jdbcType=VARCHAR},
			</if>
			<if test="boxView != null">
				box_view = #{boxView,jdbcType=CHAR},
			</if>
			<if test="searchView != null">
				search_view = #{searchView,jdbcType=CHAR},
			</if>
			<if test="parameterMake != null">
				parameter_make = #{parameterMake,jdbcType=CHAR},
			</if>
			<if test="searchMake != null">
				search_make = #{searchMake,jdbcType=CHAR},
			</if>
			<if test="searchOrderBy != null">
				search_order_by = #{searchOrderBy,jdbcType=INTEGER},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=INTEGER},
			</if>
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>


	<resultMap id="standardMap" type="java.util.Map">
		<result column="parameter_id" property="parameterId" jdbcType="INTEGER" />
		<result column="parameter_value" property="parameterValue"
			jdbcType="VARCHAR" />
		<result column="standard_id" property="standardId" jdbcType="INTEGER" />
		<result column="standard_name" property="standardName"
			jdbcType="VARCHAR" />
	</resultMap>
	

    <select id="selectStandardLists" resultMap="standardMap" timeout="20000">
    <![CDATA[SELECT t.id AS parameter_id,t.`parameter_value`,t.`standard_id`,s.`standard_name`
        FROM parameter_make t,standard s WHERE t.`standard_id`=s.id limit #{offset},#{pageSize}
     ]]>
	</select>

    <select id="selectStandardMapCount" resultType="java.lang.Integer"
		timeout="20000">
		SELECT count(1) FROM parameter_make t,standard s WHERE
		t.`standard_id`=s.id
	</select>

    <select id="selectAll" resultMap="BaseResultMap" timeout="20000">
		select
		<include refid="Base_Column_List" />
		from standard
	</select>
</mapper>