Attribute.xml 2.97 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="AttributeDao">

	<sql id="QUERY_WHERE_CLAUSE">
		<where>
			<if test="attrId != null and attrId != ''"><![CDATA[AND id = #{id}]]></if>
			<if test="name != null and name != ''"><![CDATA[AND name = #{name}]]></if>
			<if test="alias != null and alias != ''"><![CDATA[AND alias = #{alias}]]></if>
            <if test="dealType != null"><![CDATA[deal_type = #{dealType},]]></if>
			<if test="inputtype != null and inputtype != ''"><![CDATA[AND inputtype = #{inputtype}]]></if>
			<if test="type != null and type != ''"><![CDATA[AND type = #{type}]]></if>
			<if test="required != null and required != ''"><![CDATA[AND required = #{required}]]></if>
			<if test="status != null and status != ''"><![CDATA[AND status = #{status}]]></if>
			<if test="ctime != null and ctime != ''"><![CDATA[AND ctime = #{ctime}]]></if>
			<if test="utime != null and utime != ''"><![CDATA[AND utime = #{utime}]]></if>
		</where>
	</sql>

	<sql id="QUERY_ORDER_LIMIT_CONDTION">
		<if test="orderField != null and orderField != '' and orderType != null and orderType != ''"><![CDATA[ORDER BY ${orderField} ${orderType}]]></if>
		<if test="startIndex != null and startIndex &gt;= 0 and pageSize != null and pageSize &gt; 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
	</sql>

    <!-- 查询,通过主键IN(array) -->
    <select id="selectEntryArray" parameterType="java.lang.reflect.Array" resultType="attribute">
        <![CDATA[ SELECT id AS attrId,name,alias,deal_type AS dealType,inputtype ,type,required,status,ctime,utime FROM attribute ]]>
        <![CDATA[WHERE id IN]]>
        <foreach collection="array" item="id" open="(" separator="," close=")">
            <![CDATA[#{id}]]>
        </foreach>
    </select>
	<select id="selectEntry" parameterType="long" resultType="attribute">
		<![CDATA[SELECT id AS attrId,name,alias,deal_type AS dealType,inputtype ,type,required,status,ctime,utime FROM attribute WHERE id = #{id}]]>
	</select>

	<select id="selectAllEntry" resultType="attribute">
		<![CDATA[SELECT id AS attrId,name,alias,deal_type AS dealType,inputtype ,type,required,status,ctime,utime FROM attribute]]>
	</select>

	<select id="selectEntryList" parameterType="attribute" resultType="attribute">
		<![CDATA[SELECT id AS attrId,name,alias,deal_type AS dealType,inputtype,type,required,status,ctime,utime FROM attribute]]>
		<include refid="QUERY_WHERE_CLAUSE" />
		<include refid="QUERY_ORDER_LIMIT_CONDTION" />
	</select>

	<select id="selectEntryListCount" parameterType="attribute" resultType="int">
		<![CDATA[SELECT COUNT(id) AS dataCount FROM attribute]]>
		<include refid="QUERY_WHERE_CLAUSE" />
	</select>

	<select id="selectAttributeValue" parameterType="long" resultType="attributeValue">
		<![CDATA[SELECT id AS valueId,attr_id AS attrId,value,`order`,`show`,status FROM attribute_value WHERE attr_id = #{attrId} 	order by `order`]]>
	</select>
	
</mapper>