Category.xml 3.25 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.dili.titan.dao.CategoryDao">
	<sql id="QUERY_WHERE_CLAUSE">
		<where>
			<if test="id != null and id != ''"><![CDATA[AND id = #{id}]]></if>
			<if test="name != null and name != ''"><![CDATA[AND name = #{name}]]></if>
            <if test="jp != null and jp != ''"><![CDATA[AND jp = #{jp}]]></if>
			<if test="parent != null and parent != ''"><![CDATA[AND parent = #{parent}]]></if>
            <if test="dealType != null and dealType != ''"><![CDATA[AND deal_type = #{dealType}]]></if>
			<if test="template != null and template != ''"><![CDATA[AND template = #{template}]]></if>
			<if test="status != null and status != ''"><![CDATA[AND status = #{status}]]></if>
			<if test="activate != null and activate != ''"><![CDATA[AND activate = #{activate}]]></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="category">
        <![CDATA[ SELECT id,name, jp ,alias,deal_type AS dealType,icon,parent,template,status,activate,`order` FROM category]]>
        <![CDATA[WHERE id IN]]>
        <foreach collection="array" item="id" open="(" separator="," close=")">
            <![CDATA[#{id}]]>
        </foreach>
    </select>
	<select id="selectEntry" parameterType="int" resultType="category">
		<![CDATA[SELECT id,name, jp ,alias,deal_type AS dealType,icon,parent,template,status,activate,`order` FROM category WHERE id = #{id} order by `order`]]>
	</select>

	<select id="selectEntryList" parameterType="category" resultType="category">
		<![CDATA[SELECT id,name,jp ,alias,deal_type AS dealType,icon,parent,template,status,activate,`order` FROM category ]]>
		<include refid="QUERY_WHERE_CLAUSE" />
		<include refid="QUERY_ORDER_LIMIT_CONDTION" />
		order by `order`
	</select>

	<select id="selectAllEntry" resultType="category">
		<![CDATA[SELECT id,name,jp ,alias,deal_type AS dealType,icon,parent,template,status,activate,`order` FROM category  order by `order`]]>
	</select>

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

	<select id="selectChildById" parameterType="int" resultType="int">
		<![CDATA[SELECT id  FROM category WHERE parent = #{id} AND status=1]]>
	</select>

	<select id="selectCateAttrById" parameterType="int" resultType="categoryAttr">
		<![CDATA[SELECT id,cate_id AS catId,deal_type AS dealType,attr_id AS attrId,searchable,`order` from category_attr where cate_id = #{catId} order by `order`]]>
	</select>

	<select id="selectCateSeacherAttrById" parameterType="int" resultType="categoryAttr">
		<![CDATA[SELECT id,cate_id AS catId,attr_id AS attrId,`order` FROM category_search_attr WHERE cate_id = #{catId} order by `order`]]>
	</select>
	
</mapper>