<?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.xu.dao.DicDao">
<resultMap id="base" type="com.xu.model.po.Dic">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="type" jdbcType="INTEGER" />
<result column="text" property="text" jdbcType="VARCHAR" />
<result column="value" property="value" jdbcType="VARCHAR" />
<result column="selected" property="selected" jdbcType="BOOLEAN" />
<result column="creator" property="creator" jdbcType="VARCHAR" />
<result column="createDate" property="createDate" jdbcType="VARCHAR" />
<result column="updater" property="updater" jdbcType="VARCHAR" />
<result column="updateDate" property="updateDate" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="bean" type="com.xu.model.po.Dic" extends="base">
<association property="type" column="type" select="com.xu.dao.DicTypeDao.getBase"></association>
</resultMap>
<sql id="Base_Column_List">
id,type,text,value,selected,creator,createDate,updater,updateDate
</sql>
<sql id="table_name">
dic
</sql>
<sql id="likeSearch">
<if test="qs != null">
<foreach collection="qs" open="AND" separator="AND" item="q">
T0.SEARCH LIKE '%${q}%'
</foreach>
</if>
</sql>
<sql id="whereBean">
<if test="bean != null">
<if test="bean.text !=null and bean.text.length() > 0">AND T0.text LIKE '%${bean.text}%'</if>
<if test="bean.type !=null and bean.type.id > 0">AND T0.type = #{bean.type.id}</if>
</if>
</sql>
<select id="get" resultMap="bean" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from
<include refid="table_name" />
where id = #{id,jdbcType=INTEGER}
</select>
<select id="getBase" resultMap="base" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from
<include refid="table_name" />
where id = #{id,jdbcType=INTEGER}
</select>
<select id="getByType" resultMap="base" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from
<include refid="table_name" />
where type = #{type,jdbcType=INTEGER}
</select>
<delete id="delete" parameterType="java.lang.Integer">
delete from
<include refid="table_name" />
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByType" parameterType="java.lang.Integer">
delete from
<include refid="table_name" />
where id = #{type,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.xu.model.po.Dic">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Integer">
SELECT ifnull(max(id),0)+1 as id FROM
<include refid="table_name" />
</selectKey>
insert into
<include refid="table_name" />
(
<include refid="Base_Column_List" />
)
values (
#{id,jdbcType=INTEGER},
#{type.id,jdbcType=INTEGER},
#{text,jdbcType=VARCHAR},
#{value,jdbcType=VARCHAR},
#{selected,jdbcType=BOOLEAN},
#{creator,jdbcType=VARCHAR},
#{createDate,jdbcType=VARCHAR},
#{updater,jdbcType=VARCHAR},
#{updateDate,jdbcType=VARCHAR}
)
</insert>
<update id="update" parameterType="com.xu.model.po.Dic">
update <include refid="table_name" />
set
text = #{text,jdbcType=VARCHAR},
value = #{value,jdbcType=VARCHAR},
selected = #{selected,jdbcType=BOOLEAN},
type = #{type.id,jdbcType=INTEGER},
creator = #{creator,jdbcType=VARCHAR},
createDate = #{createDate,jdbcType=VARCHAR},
updater = #{updater,jdbcType=VARCHAR},
updateDate = #{updateDate,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<sql id="fullTextSql">
SELECT
<include refid="Base_Column_List" />
,CONCAT_WS('|',
<include refid="Base_Column_List" />
) as SEARCH from
<include refid="table_name" />
</sql>
<select id="count" parameterType="com.xu.model.easyui.PageParams" resultType="int" useCache="true">
SELECT COUNT(1) FROM (
SELECT id FROM (
<include refid="fullTextSql" />
) T0
WHERE 1=1
<include refid="likeSearch" />
<include refid="whereBean" />
) T1
</select>
<select id="find" parameterType="com.xu.model.easyui.PageParams" resultMap="bean" useCache="true">
SELECT *
FROM (
<include refid="fullTextSql" />
) T0 WHERE 1=1
<include refid="likeSearch" />
<include refid="whereBean" />
ORDER BY ${sort} ${order}
LIMIT ${startIndex},${rows}
</select>
<select id="getAllDicByType" parameterType="java.lang.String" resultMap="bean" useCache="true">
SELECT T0.id,T0.text,T0.value
FROM <include refid="table_name" /> T0
WHERE T0.type = (
select T1.id from dic_type T1 where T1.text = #{text,jdbcType=VARCHAR}
)
ORDER BY T0.id
</select>
</mapper>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xu.dao.DicDao">
<resultMap id="base" type="com.xu.model.po.Dic">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="type" jdbcType="INTEGER" />
<result column="text" property="text" jdbcType="VARCHAR" />
<result column="value" property="value" jdbcType="VARCHAR" />
<result column="selected" property="selected" jdbcType="BOOLEAN" />
<result column="creator" property="creator" jdbcType="VARCHAR" />
<result column="createDate" property="createDate" jdbcType="VARCHAR" />
<result column="updater" property="updater" jdbcType="VARCHAR" />
<result column="updateDate" property="updateDate" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="bean" type="com.xu.model.po.Dic" extends="base">
<association property="type" column="type" select="com.xu.dao.DicTypeDao.getBase"></association>
</resultMap>
<sql id="Base_Column_List">
id,type,text,value,selected,creator,createDate,updater,updateDate
</sql>
<sql id="table_name">
dic
</sql>
<sql id="likeSearch">
<if test="qs != null">
<foreach collection="qs" open="AND" separator="AND" item="q">
T0.SEARCH LIKE '%${q}%'
</foreach>
</if>
</sql>
<sql id="whereBean">
<if test="bean != null">
<if test="bean.text !=null and bean.text.length() > 0">AND T0.text LIKE '%${bean.text}%'</if>
<if test="bean.type !=null and bean.type.id > 0">AND T0.type = #{bean.type.id}</if>
</if>
</sql>
<select id="get" resultMap="bean" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from
<include refid="table_name" />
where id = #{id,jdbcType=INTEGER}
</select>
<select id="getBase" resultMap="base" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from
<include refid="table_name" />
where id = #{id,jdbcType=INTEGER}
</select>
<select id="getByType" resultMap="base" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from
<include refid="table_name" />
where type = #{type,jdbcType=INTEGER}
</select>
<delete id="delete" parameterType="java.lang.Integer">
delete from
<include refid="table_name" />
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByType" parameterType="java.lang.Integer">
delete from
<include refid="table_name" />
where id = #{type,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.xu.model.po.Dic">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Integer">
SELECT ifnull(max(id),0)+1 as id FROM
<include refid="table_name" />
</selectKey>
insert into
<include refid="table_name" />
(
<include refid="Base_Column_List" />
)
values (
#{id,jdbcType=INTEGER},
#{type.id,jdbcType=INTEGER},
#{text,jdbcType=VARCHAR},
#{value,jdbcType=VARCHAR},
#{selected,jdbcType=BOOLEAN},
#{creator,jdbcType=VARCHAR},
#{createDate,jdbcType=VARCHAR},
#{updater,jdbcType=VARCHAR},
#{updateDate,jdbcType=VARCHAR}
)
</insert>
<update id="update" parameterType="com.xu.model.po.Dic">
update <include refid="table_name" />
set
text = #{text,jdbcType=VARCHAR},
value = #{value,jdbcType=VARCHAR},
selected = #{selected,jdbcType=BOOLEAN},
type = #{type.id,jdbcType=INTEGER},
creator = #{creator,jdbcType=VARCHAR},
createDate = #{createDate,jdbcType=VARCHAR},
updater = #{updater,jdbcType=VARCHAR},
updateDate = #{updateDate,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<sql id="fullTextSql">
SELECT
<include refid="Base_Column_List" />
,CONCAT_WS('|',
<include refid="Base_Column_List" />
) as SEARCH from
<include refid="table_name" />
</sql>
<select id="count" parameterType="com.xu.model.easyui.PageParams" resultType="int" useCache="true">
SELECT COUNT(1) FROM (
SELECT id FROM (
<include refid="fullTextSql" />
) T0
WHERE 1=1
<include refid="likeSearch" />
<include refid="whereBean" />
) T1
</select>
<select id="find" parameterType="com.xu.model.easyui.PageParams" resultMap="bean" useCache="true">
SELECT *
FROM (
<include refid="fullTextSql" />
) T0 WHERE 1=1
<include refid="likeSearch" />
<include refid="whereBean" />
ORDER BY ${sort} ${order}
LIMIT ${startIndex},${rows}
</select>
<select id="getAllDicByType" parameterType="java.lang.String" resultMap="bean" useCache="true">
SELECT T0.id,T0.text,T0.value
FROM <include refid="table_name" /> T0
WHERE T0.type = (
select T1.id from dic_type T1 where T1.text = #{text,jdbcType=VARCHAR}
)
ORDER BY T0.id
</select>
</mapper>